:root {
    --primary: #005da7;
    --primary-light: #d4e3ff;
    --secondary: #fdd73b;
    --tertiary: #21863b;
    --surface: #fbf9f8;
    --surface-container: #efeded;
    --on-surface: #1b1c1c;
    --outline: #717783;
    --error: #ba1a1a;
    --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Quicksand', sans-serif;
    background: var(--surface);
    color: var(--on-surface);
    line-height: 1.5;
}

h1, h2, h3 { font-family: 'Plus Jakarta Sans', sans-serif; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, var(--primary-light), var(--surface));
}

.login-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 8px 32px rgba(0,93,167,0.12);
    width: 100%;
    max-width: 400px;
}

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand .brand-icon { font-size: 3rem; }
.login-brand h1 { color: var(--primary); font-size: 1.75rem; }

.login-card label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; font-size: 0.9rem; }
.login-card input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--surface-container);
    border-radius: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-pwd {
    font-family: inherit;
    -webkit-text-security: disc;
}
.login-card .btn-login {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.85rem 1rem;
    border: none;
    cursor: pointer;
}

/* Layout */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar-brand {
    padding: 1.5rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-brand .sidebar-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar nav a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.15s;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    font-size: 0.85rem;
}
.sidebar-footer a { color: var(--secondary); }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 2rem;
    width: calc(100% - var(--sidebar-w));
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.75rem; color: var(--primary); }

/* Cards & Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    padding: 1.25rem;
    border-radius: 1rem;
    border-bottom: 4px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-card .num { font-size: 2rem; font-weight: 800; font-family: 'Plus Jakarta Sans', sans-serif; color: var(--primary); }
.stat-card .label { color: var(--outline); font-size: 0.85rem; font-weight: 600; }

.card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.card-header h2 { font-size: 1.1rem; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--surface-container);
}
.data-table th { font-weight: 700; color: var(--outline); font-size: 0.8rem; text-transform: uppercase; }
.data-table tr:hover { background: var(--surface); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 0 #004883;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #004883; }
.btn-secondary { background: var(--secondary); color: #715d00; }
.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.4rem 0.6rem; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 2px solid var(--surface-container);
    border-radius: 0.5rem;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary);
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 1rem; color: var(--primary); }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge-active { background: #96f89f; color: #00531d; }
.badge-inactive { background: var(--surface-container); color: var(--outline); }

.alert { padding: 0.75rem 1rem; border-radius: 0.5rem; margin-bottom: 1rem; font-weight: 600; }
.alert-error { background: #ffdad6; color: var(--error); }

.toast {
    position: fixed; bottom: 2rem; right: 2rem;
    background: var(--primary); color: #fff;
    padding: 0.85rem 1.5rem; border-radius: 999px;
    font-weight: 600; z-index: 2000;
    box-shadow: 0 4px 16px rgba(0,93,167,0.3);
    transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

.toggle-switch { position: relative; width: 48px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--surface-container); border-radius: 999px; transition: 0.2s;
}
.toggle-slider:before {
    content: ''; position: absolute; width: 20px; height: 20px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--tertiary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(22px); }

/* Unit detay — iç içe ders / kelime */
.modal.modal-wide { max-width: 960px; }
.unit-detail-header {
    display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
    margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--surface-container);
}
.unit-detail-header h3 { margin: 0; color: var(--primary); flex: 1; min-width: 200px; }
.unit-detail-meta { font-size: 0.85rem; color: var(--outline); }
.lesson-accordion { display: flex; flex-direction: column; gap: 0.5rem; }
.lesson-item {
    border: 2px solid var(--surface-container);
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
}
.lesson-item-head {
    display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    background: var(--surface);
    user-select: none;
}
.lesson-item-head:hover { background: #f0f4f8; }
.lesson-item-head.open { background: #e8f4fd; border-bottom: 1px solid var(--surface-container); }
.lesson-chevron { font-size: 0.75rem; width: 1rem; color: var(--outline); transition: transform 0.15s; }
.lesson-item-head.open .lesson-chevron { transform: rotate(90deg); }
.lesson-title { font-weight: 700; flex: 1; min-width: 120px; }
.lesson-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-left: auto; }
.lesson-body { padding: 0.75rem; display: none; }
.lesson-body.open { display: block; }
.lesson-words-table { width: 100%; font-size: 0.85rem; }
.lesson-words-table th { text-align: left; padding: 0.4rem 0.5rem; background: var(--surface); }
.lesson-words-table td { padding: 0.4rem 0.5rem; border-top: 1px solid var(--surface-container); vertical-align: top; }
.word-sentence { font-size: 0.8rem; color: var(--outline); margin-top: 0.2rem; font-style: italic; }
.word-search-results {
    max-height: 220px; overflow-y: auto;
    border: 2px solid var(--surface-container); border-radius: 0.5rem; margin-top: 0.5rem;
}
.word-search-item {
    padding: 0.5rem 0.75rem; cursor: pointer; border-bottom: 1px solid var(--surface-container);
}
.word-search-item:hover { background: #e8f4fd; }
.word-search-item:last-child { border-bottom: none; }
.tab-bar { display: flex; gap: 0.35rem; margin-bottom: 0.75rem; }
.tab-btn {
    padding: 0.4rem 0.85rem; border: 2px solid var(--surface-container);
    border-radius: 999px; background: #fff; cursor: pointer; font-weight: 600; font-size: 0.85rem;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .main-content { margin-left: 0; width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
}
