/* ===== Quiz Application Styles ===== */

:root {
    --sidebar-bg: #2d3e8f;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 60px;
    --topbar-height: 56px;
    --primary: #3949ab;
    --primary-light: #5c6bc0;
    --content-bg: #f0f2f8;
    --card-bg: #ffffff;
    --text-muted-sidebar: rgba(255,255,255,0.65);
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    margin-bottom: 0 !important;
    background-color: var(--content-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
}

/* ===== Layout ===== */
.quiz-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.quiz-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    transition: width 0.25s ease;
    overflow: hidden;
}

.quiz-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: var(--topbar-height);
}

.sidebar-logo {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.quiz-sidebar.collapsed .sidebar-title,
.quiz-sidebar.collapsed .nav-text,
.quiz-sidebar.collapsed .nav-arrow {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted-sidebar);
    padding: 0.75rem 1.1rem 0.25rem;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.1rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.875rem;
    white-space: nowrap;
}

.sidebar-link:hover,
.sidebar-link.active {
    background-color: rgba(255,255,255,0.12);
    color: #fff;
}

.sidebar-link .nav-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.sidebar-link .nav-text {
    flex: 1;
    transition: opacity 0.2s;
}

.sidebar-link .nav-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.sidebar-link[aria-expanded="true"] .nav-arrow {
    transform: rotate(90deg);
}

.sidebar-submenu {
    background-color: rgba(0,0,0,0.15);
}

.sidebar-submenu .sidebar-link {
    padding-left: 2.5rem;
    font-size: 0.82rem;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: flex-end;
}

.sidebar-collapse-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.25s;
}

.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.2); }
.quiz-sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); }

/* ===== Main Content ===== */
.quiz-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.quiz-main.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Top Bar ===== */
.quiz-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e0e4f0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #444;
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ===== Content Area ===== */
.quiz-content {
    padding: 1.75rem;
    flex: 1;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

/* ===== Cards ===== */
.quiz-card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    border-left: 4px solid var(--primary);
    padding: 1rem 1.25rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* ===== Tables ===== */
.quiz-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.quiz-table thead th {
    background: #f8f9fe;
    color: #555;
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid #e0e4f0;
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.quiz-table tbody tr {
    border-bottom: 1px solid #f0f2f8;
    transition: background 0.1s;
}

.quiz-table tbody tr:hover {
    background: #f8f9fe;
}

.quiz-table tbody td {
    padding: 0.55rem 0.75rem;
    vertical-align: top;
}

/* ===== Badges ===== */
.difficulty-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.category-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

/* ===== Buttons ===== */
.btn-primary-quiz {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary-quiz:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-light);
    color: #fff;
}

.btn-add {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-add:hover {
    background: var(--primary-light);
    color: #fff;
}

/* ===== Search bar ===== */
.table-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-box input {
    border: 1px solid #d0d5e8;
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}

.search-box input:focus {
    border-color: var(--primary);
}

.records-per-page select {
    border: 1px solid #d0d5e8;
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

/* ===== Answers list in question table ===== */
.answers-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.answers-list li {
    font-size: 0.82rem;
    color: #444;
    line-height: 1.6;
}

.answers-list li.correct-answer {
    color: var(--primary);
    font-weight: 600;
}

/* ===== User badges in question table ===== */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 0.75rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #555;
}

/* ===== Photo icon ===== */
.has-photo {
    color: #777;
    font-size: 0.9rem;
}

/* ===== Modal styles ===== */
.modal-quiz .modal-header {
    background: var(--primary);
    color: #fff;
    border-radius: 10px 10px 0 0;
}

.modal-quiz .modal-header .btn-close {
    filter: invert(1);
}

.modal-quiz .modal-content {
    border-radius: 10px;
    border: none;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.char-counter {
    font-size: 0.7rem;
    color: #999;
    text-align: right;
}

.char-counter.near-limit { color: #fd7e14; }
.char-counter.at-limit { color: #dc3545; }

.answer-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.answer-row input[type="text"] {
    flex: 1;
}

.correct-check {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.answer-img-btn {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

/* ===== Plan page ===== */
.plan-panel {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.plan-panel-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e4f0;
    flex-shrink: 0;
}

.plan-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.plan-question-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f2f8;
    transition: background 0.1s;
}

.plan-question-row:hover { background: #f8f9fe; }

.plan-order-num {
    font-weight: 700;
    color: #777;
    min-width: 24px;
    font-size: 0.8rem;
    margin-top: 2px;
}

.plan-question-content {
    flex: 1;
    font-size: 0.82rem;
}

.drag-handle {
    cursor: grab;
    color: #ccc;
    font-size: 0.9rem;
    margin-top: 2px;
}

.drag-handle:active { cursor: grabbing; }

/* ===== AI Generate page ===== */
.ai-provider-card {
    border: 2px solid #e0e4f0;
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
}

.ai-provider-card:hover,
.ai-provider-card.selected {
    border-color: var(--primary);
    background: #f0f2ff;
}

.ai-provider-card .provider-name {
    font-weight: 600;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* ===== Export page ===== */
.export-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.875rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .quiz-sidebar {
        width: var(--sidebar-collapsed-width);
    }
    .quiz-main {
        margin-left: var(--sidebar-collapsed-width);
    }
    .quiz-content {
        padding: 1rem;
    }
}

/* ===== Sortable ghost ===== */
.sortable-ghost {
    opacity: 0.4;
    background: #c8ebfb;
}
