/**
 * Global Base CSS
 * Variables, resets, typography, layout (.content-wrapper), utilities
 * ONE source of truth for all app-wide foundation styles
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    /* Brand Colors */
    --plava: #879cfe;
    --ljubicasta: #d0a1eb;
    --rosa: #d0a1eb;
    --bijela: #F0F8FC;
    --hover-plava: #a0b1ff;

    /* Semantic Colors */
    --blue: #0096FF;
    --green: #22DD22;
    --yellow: #FFFF00;
    --red: #FF3131;
    --level-a1-bg: #9D8FE8;
    --level-a1-2-bg: #7A6BCE;
    --level-a2-bg: #5BAAE8;
    --level-a2-2-bg: #3A8ACC;
    --level-b1-bg: #3DD9A0;
    --level-b1-2-bg: #1DB880;
    --level-b2-bg: #F5C84E;
    --level-b2-2-bg: #D5A830;
    --level-b2-text: #5a4000;
    --level-c1-bg: #F07068;
    --level-c1-2-bg: #D05040;
    --level-k-bg: #17A898;

    /* Semantic Background/Text/Border Pairs */
    --color-success-bg: #d4edda;
    --color-success-text: #155724;
    --color-success-border: #86efac;
    --color-danger-bg: #f8d7da;
    --color-danger-text: #721c24;
    --color-danger-border: #f5c6cb;
    --color-warning-bg: #fff3cd;
    --color-warning-text: #856404;
    --color-warning-border: #fde68a;
    --color-info-bg: #d1ecf1;
    --color-info-text: #0c5460;
    --color-info-border: #93c5fd;
    --color-outbound-border: #10b981;

    /* Text Colors */
    --text-dark: #333333;
    --text-light: #666666;
    --text-muted: #6c757d;

    /* Neutral */
    --color-neutral-bg: #e2e3e5;
    --color-neutral-text: #383d41;

    /* Button Colors (flat — no gradients) */
    --btn-primary-start: #28a745;
    --btn-primary-hover-start: #218838;
    --btn-primary-active-start: #1e7e34;

    --btn-danger-start: #dc3545;
    --btn-danger-hover-start: #c82333;
    --btn-danger-active-start: #bd2130;

    /* Logout */
    --logout-color: #ff4444;
    --logout-hover-color: #cc0000;

    /* Borders and Shadows */
    --border-color: #dddddd;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Unified Design Tokens (Light) */
    --color-bg: #edf1fb;
    --color-surface: #ffffff;
    --color-surface-muted: #f3f6ff;
    --color-border: #cfd7ee;
    --color-text: #1a2340;
    --color-text-muted: #5b6788;
    --color-on-brand: #ffffff;
    --color-link: #607fe8;
    --color-link-hover: #4f70de;
    --color-focus-ring: rgba(96, 127, 232, 0.28);
    --color-shadow: rgba(22, 34, 66, 0.12);
    --btn-primary-bg: var(--color-link);
    --btn-primary-hover: #4f70de;
    --btn-primary-active: #4665cd;
    --btn-secondary-bg: #495aab;
    --btn-secondary-hover: #3f509d;
    --btn-secondary-active: #39488f;
    --btn-ghost-bg-hover: #e9efff;
}

[data-theme="dark"] {
    --color-bg: #0f1527;
    --color-surface: #171f36;
    --color-surface-muted: #202a44;
    --color-border: #324061;
    --color-text: #eaf0ff;
    --color-text-muted: #9aa8cb;
    --color-on-brand: #ffffff;
    --color-link: #8fa4ff;
    --color-link-hover: #a8b9ff;
    --color-focus-ring: rgba(159, 177, 255, 0.3);
    --color-shadow: rgba(0, 0, 0, 0.45);
    --btn-primary-bg: #7f95f8;
    --btn-primary-hover: #92a5ff;
    --btn-primary-active: #6f84e8;
    --btn-secondary-bg: #4f62bf;
    --btn-secondary-hover: #6174ce;
    --btn-secondary-active: #4759b2;
    --btn-ghost-bg-hover: #2b3757;
    --level-a1-bg: #6b63a8;
    --level-a1-2-bg: #575091;
    --level-a2-bg: #4d83b3;
    --level-a2-2-bg: #3f6f9c;
    --level-b1-bg: #2f9b78;
    --level-b1-2-bg: #257e62;
    --level-b2-bg: #ba9440;
    --level-b2-2-bg: #9a782f;
    --level-b2-text: #f5e6c0;
    --level-c1-bg: #b35b55;
    --level-c1-2-bg: #94463f;
    --level-k-bg: #2f7b72;
    --text-dark: #eaf0ff;
    --text-light: #b2bfdc;
    --text-muted: #9aa8cb;
    --bijela: #202a44;
    --border-color: #324061;
    --shadow: rgba(0, 0, 0, 0.4);
}

/* ========================================
   Global Reset
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================
   Base Styles
   ======================================== */
html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Body lock for modals */
body.modal-open {
    overflow: hidden;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }

/* ========================================
   Links
   ======================================== */
a {
    color: var(--color-link);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-link-hover);
}

/* ========================================
   Content Wrapper - MANDATORY on every page
   ======================================== */
.content-wrapper {
    padding: var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   Utilities
   ======================================== */
.text-muted { color: var(--color-text-muted); }
.inline-form { display: inline; }
.hidden { display: none !important; }

/* ========================================
   Admin / Teacher PWA Install Banner
   Hidden by default; shown only when Chrome
   fires beforeinstallprompt.
   ======================================== */
.admin-pwa-banner,
.teacher-pwa-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--color-surface);
    border-top: 3px solid var(--color-link);
    box-shadow: 0 -4px 20px var(--color-shadow);
}

.admin-pwa-banner-content,
.teacher-pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.admin-pwa-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
}

.admin-pwa-banner-text,
.teacher-pwa-banner-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.admin-pwa-banner-title,
.teacher-pwa-banner-title {
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-pwa-banner-sub,
.teacher-pwa-banner-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-pwa-banner-actions,
.teacher-pwa-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.admin-pwa-dismiss,
.teacher-pwa-dismiss {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

/* Theme switcher shared utility */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--btn-ghost-bg-hover);
    border-color: var(--color-link);
    transform: translateY(-1px);
}

.theme-toggle-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* ========================================
   Responsive
   ======================================== */
@media (min-width: 768px) {
    .content-wrapper {
        padding: var(--spacing-lg);
    }
}

@media (min-width: 1200px) {
    .content-wrapper {
        padding: var(--spacing-lg) var(--spacing-xl);
    }
}

.teacher-main-content {
    padding-bottom: 4.5rem;
}

@media (min-width: 1024px) {
    .teacher-main-content {
        padding-bottom: 0;
    }
}
