/* ============================================
   Admin Panel - Tab-Based Layout
   ============================================ */

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

:root {
    --card-bg: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.18);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Better contrast for dark (dashboard-style) pages */
.dashboard-main .card {
    color: rgba(255, 255, 255, 0.92);
}

.dashboard-main .form-group label {
    color: rgba(255, 255, 255, 0.92);
}

.form-hint {
    margin-top: 6px;
    font-size: 0.9rem;
    color: #666;
}

.dashboard-main .form-hint {
    color: rgba(255, 255, 255, 0.75);
}

.dashboard-main .form-group input,
.dashboard-main .form-group textarea,
.dashboard-main .form-group select {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.92);
}

.dashboard-main .form-group input:focus,
.dashboard-main .form-group textarea:focus,
.dashboard-main .form-group select:focus {
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.35);
}

.dashboard-main input::placeholder,
.dashboard-main textarea::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.dashboard-main code {
    color: rgba(255, 255, 255, 0.92);
}

.dashboard-main pre {
    color: rgba(255, 255, 255, 0.92);
}

/* Page Management */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ============================================
   Login Page
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

.back-home {
    display: inline-block;
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: color 0.3s;
}

.back-home:hover {
    color: #764ba2;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2rem;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.login-header p {
    color: #666;
}

.error-message {
    color: #e74c3c;
    text-align: center;
    margin-top: 15px;
    min-height: 20px;
    font-size: 0.9rem;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

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

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #11998e, #38ef7d);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(17, 153, 142, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-outline-light {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

.btn-block {
    width: 100%;
}

/* ============================================
   Admin Header
   ============================================ */
.admin-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-home {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.header-home:hover {
    color: white;
}

.admin-header h1 {
    font-size: 1.4rem;
    margin: 0;
}

/* ============================================
   Dashboard Page
   ============================================ */
.dashboard-main {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.92);
}

.dashboard-container {
    text-align: center;
    max-width: 800px;
}

.dashboard-container h2 {
    color: white;
    font-size: 2rem;
    margin-bottom: 10px;
}

.dashboard-subtitle {
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}

.dashboard-card {
    background: white;
    border-radius: 16px;
    padding: 35px 30px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.dashboard-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.dashboard-card .card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.dashboard-card h3 {
    font-size: 1.3rem;
    color: #1a1a2e;
    margin-bottom: 10px;
}

.dashboard-card p {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.dashboard-card .card-arrow {
    font-size: 1.5rem;
    color: #667eea;
    transition: transform 0.3s;
}

.dashboard-card:hover .card-arrow {
    transform: translateX(5px);
}

/* ============================================
   Page Layout (Sidebar + Main)
   ============================================ */
.page-layout {
    display: flex;
    min-height: calc(100vh - 60px);
    position: relative;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    left: 280px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    width: 24px;
    height: 48px;
    background: #667eea;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease, background 0.2s;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar-toggle:hover {
    background: #5a6fd6;
}

.sidebar-toggle .toggle-arrow {
    color: white;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.sidebar-toggle.collapsed {
    left: 0;
    border-radius: 0 8px 8px 0;
}

.sidebar-toggle.collapsed .toggle-arrow {
    transform: rotate(180deg);
}

/* Progress bar mini (stats) */
.progress-bar-mini {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0 5px 0;
}

.progress-fill-mini {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.85rem;
    color: #888;
    text-align: center;
}

/* Header hint */
.header-hint {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    font-weight: 400;
}

/* Question card with pending changes */
.question-card.has-pending {
    border-left: 4px solid #f59e0b;
}

.sidebar {
    width: 280px;
    min-width: 280px;
    background: white;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    transition: margin-left 0.3s ease, opacity 0.3s ease;
}

.sidebar.collapsed {
    margin-left: -280px;
    opacity: 0;
    pointer-events: none;
}

.page-layout.sidebar-collapsed .main-content {
    margin-left: 0;
}

.main-content {
    flex: 1;
    padding: 25px 30px;
    background: #f5f7fa;
    overflow-y: auto;
}

/* ============================================
   Tab Navigation
   ============================================ */
.tab-nav {
    background: white;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    padding: 0 30px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
    background: #f8f9ff;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-icon {
    font-size: 1.1rem;
}

/* ============================================
   Tab Content
   ============================================ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-page {
    display: flex;
    min-height: calc(100vh - 120px);
}

/* Sidebar */
.tab-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    position: sticky;
    top: 0;
    height: calc(100vh - 120px);
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-section.collapsible .section-toggle {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    padding: 6px 8px;
    margin: -6px -8px 10px -8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.sidebar-section.collapsible .section-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sidebar-section.collapsible .toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.sidebar-section.collapsible.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.sidebar-section.collapsible .section-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 500px;
    opacity: 1;
}

.sidebar-section.collapsible.collapsed .section-content {
    max-height: 0;
    opacity: 0;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 10px;
}

.subject-dropdown {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
}

.subject-dropdown:focus {
    outline: none;
    border-color: #667eea;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    padding: 8px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    transition: all 0.3s;
}

.filter-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Stats Box */
.stats-box {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stats-box h4 {
    margin: 0 0 10px;
    color: #333;
    font-size: 0.9rem;
}

.stats-box p {
    margin: 5px 0;
    color: #666;
    font-size: 0.875rem;
}

.stats-box .stat-number {
    font-weight: 700;
    color: #667eea;
}

.stats-box .placeholder {
    color: #999;
    font-style: italic;
}

.progress-bar-mini {
    background: #e0e0e0;
    border-radius: 4px;
    height: 8px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #11998e, #38ef7d);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* Main Content */
.tab-main {
    flex: 1;
    padding: 25px 30px;
    overflow-y: auto;
}

.content-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.content-header h2 {
    margin: 0 0 8px;
    color: #1a1a2e;
    font-size: 1.5rem;
}

.content-header p {
    margin: 0;
    color: #666;
}

/* ============================================
   Questions List
   ============================================ */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    color: #999;
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

/* Question Card */
.question-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #e0e0e0;
    transition: all 0.3s;
}

.question-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.question-card.has-answer {
    border-left-color: #11998e;
}

.question-card.no-answer {
    border-left-color: #f39c12;
}

.question-card.selected {
    background: #e8f4ff;
    border-left-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.q-select-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3498db;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.question-id {
    font-size: 0.75rem;
    color: #888;
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.question-text {
    color: #333;
    line-height: 1.7;
    margin-bottom: 15px;
    font-size: 1rem;
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.option-btn {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    color: #333;
    transition: all 0.3s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.option-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.option-btn.selected {
    border-color: #11998e;
    background: #e6fff9;
    color: #0d7a6e;
}

.option-btn.display-only {
    cursor: default;
}

.option-btn.display-only:hover {
    border-color: #e0e0e0;
    background: white;
}

.option-btn.display-only.selected {
    border-color: #11998e;
    background: #e6fff9;
}

.option-letter {
    font-weight: 700;
    min-width: 20px;
}

.option-text {
    flex: 1;
}

/* Question Actions */
.question-actions {
    display: flex;
    gap: 8px;
}

.edit-btn {
    padding: 6px 14px;
    border: 1px solid #667eea;
    border-radius: 6px;
    background: transparent;
    color: #667eea;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s;
}

.edit-btn:hover {
    background: #667eea;
    color: white;
}

/* ============================================
   Save Bar
   ============================================ */
.save-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 100;
}

#changes-count {
    color: #f39c12;
    font-weight: 600;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    margin: 0;
    color: #1a1a2e;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

/* ============================================
   Toast
   ============================================ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

.toast.error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    .tab-page {
        flex-direction: column;
    }

    .tab-sidebar {
        width: 100%;
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .tab-nav {
        padding: 0 15px;
        overflow-x: auto;
    }

    .tab-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .save-bar {
        left: 20px;
        right: 20px;
        transform: none;
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 600px) {
    .admin-header {
        padding: 12px 15px;
        flex-direction: column;
        gap: 10px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    .tab-main {
        padding: 15px;
    }

    .login-card {
        padding: 25px;
    }

    .question-header {
        flex-direction: column;
        gap: 10px;
    }

    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
}
