/* ============================================================
   EduGen AI — Glavni CSS
   Nadogradnja Bootstrap 5 s custom dizajn sustavom
   ============================================================ */

/* --- CSS Varijable (Light tema) --- */
:root {
    --primary:          #6366f1;
    --primary-dark:     #4f46e5;
    --primary-light:    #e0e7ff;
    --secondary:        #06b6d4;
    --accent:           #f59e0b;
    --accent-light:     #fef3c7;
    --success:          #10b981;
    --danger:           #ef4444;
    --warning:          #f59e0b;
    --info:             #06b6d4;

    --surface:          #ffffff;
    --surface-2:        #f8fafc;
    --surface-3:        #f1f5f9;
    --border:           #e2e8f0;
    --border-dark:      #cbd5e1;

    --text:             #0f172a;
    --text-secondary:   #475569;
    --text-muted:       #94a3b8;

    --sidebar-width:    260px;
    --navbar-height:    64px;
    --border-radius:    12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --shadow-sm:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow:           0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --shadow-lg:        0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    --shadow-xl:        0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);

    --transition:       all .2s ease;
}

/* --- Dark Tema --- */
[data-theme="dark"] {
    --surface:          #0f172a;
    --surface-2:        #1e293b;
    --surface-3:        #334155;
    --border:           #334155;
    --border-dark:      #475569;
    --text:             #f1f5f9;
    --text-secondary:   #cbd5e1;
    --text-muted:       #64748b;
    --primary-light:    #1e1b4b;
}

/* --- Reset i Osnove --- */
* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    transition: background-color .3s ease, color .3s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* --- App Layout --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform .3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.sidebar-logo .logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.3px;
}

.sidebar-logo .logo-text span {
    color: var(--primary);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
    margin-top: 8px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: var(--transition);
    cursor: pointer;
}

.sidebar-item:hover,
.sidebar-item.active {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

.sidebar-item .icon {
    width: 20px;
    height: 20px;
    opacity: .7;
    flex-shrink: 0;
}

.sidebar-item.active .icon { opacity: 1; }

.sidebar-item .badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-user:hover { background: var(--surface-2); }

.sidebar-user .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-plan {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Main Content Area --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
}

.topbar {
    height: var(--navbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    padding: 8px 16px 8px 40px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13.5px;
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

.topbar-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
}

.topbar-btn:hover { background: var(--primary-light); color: var(--primary); }

.topbar-btn .notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

.page-content {
    padding: 28px 32px;
}

/* --- Kartice --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.card-body { padding: 20px; }

/* --- Stat Kartice (Dashboard) --- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.indigo { background: var(--primary-light); color: var(--primary); }
.stat-icon.cyan   { background: #cffafe; color: #0e7490; }
.stat-icon.amber  { background: #fef3c7; color: #b45309; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Gumbi --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--border-radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
    box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-ai {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-weight: 600;
}
.btn-ai:hover {
    box-shadow: 0 4px 16px rgba(99,102,241,.5);
    transform: translateY(-1px);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn-lg {
    padding: 13px 28px;
    font-size: 15px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--border-radius-sm);
}

/* --- Forme --- */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    appearance: none;
}

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Alert poruke --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }
.alert-warning { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }

/* --- AI Loader --- */
.ai-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.ai-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.ai-dots::after {
    content: '';
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0%, 100% { content: ''; }
    33%       { content: '.'; }
    66%       { content: '..'; }
    100%      { content: '...'; }
}

/* --- Credit Bar --- */
.credit-bar {
    padding: 12px 16px;
    background: var(--surface-2);
    border-radius: var(--border-radius-sm);
    margin: 0 12px 8px;
}

.credit-label {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.credit-label strong { color: var(--text); }

.credit-progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.credit-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width .5s ease;
}

.credit-fill.low { background: var(--danger); }
.credit-fill.medium { background: var(--warning); }

/* --- Dokument Kartica --- */
.doc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 16px;
    transition: var(--transition);
    cursor: pointer;
    display: block;
    text-decoration: none;
    color: inherit;
}

.doc-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.doc-card-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.doc-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.doc-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* --- Kviz Player --- */
.quiz-player-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px;
}

.question-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.question-number {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.question-text {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 20px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.answer-option:hover { border-color: var(--primary); background: var(--primary-light); }
.answer-option.selected { border-color: var(--primary); background: var(--primary-light); }
.answer-option.correct { border-color: var(--success); background: #dcfce7; }
.answer-option.incorrect { border-color: var(--danger); background: #fee2e2; }

.answer-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.answer-option.selected .answer-letter {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* --- Timer --- */
.quiz-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.quiz-timer.warning { color: var(--danger); animation: pulse 1s ease infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

/* --- Progress Bar --- */
.quiz-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 24px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 2px;
    transition: width .3s ease;
}

/* --- Toast Notifikacije --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--text);
    color: var(--surface);
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-xl);
    animation: slideUp .3s ease;
    max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* --- Responzivnost --- */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: 20px 16px;
    }
}

@media (max-width: 576px) {
    .topbar { padding: 0 16px; }
    .topbar-search { max-width: none; }
    .page-content { padding: 16px 12px; }
}

/* --- Tipovi dokumenata (boje) --- */
.type-lesson_plan  { background: #e0e7ff; color: var(--primary); }
.type-quiz         { background: #fce7f3; color: #9d174d; }
.type-test         { background: #fee2e2; color: #991b1b; }
.type-presentation { background: #fef3c7; color: #92400e; }
.type-worksheet    { background: #dcfce7; color: #166534; }
.type-homework     { background: #cffafe; color: #155e75; }
.type-yearly_plan  { background: #f3e8ff; color: #6b21a8; }
.type-monthly_plan { background: #ede9fe; color: #5b21b6; }
.type-rubric       { background: #fef9c3; color: #854d0e; }
.type-other        { background: var(--surface-3); color: var(--text-muted); }

/* --- Auth stranice --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo .logo-badge {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 26px;
    color: white;
}

.auth-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.auth-logo p {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 4px 0 0;
}
