/* ═══════════════════════════════════════════════════════════════
   Class Roster Manager — Unified Student/Class Management Modal
   ═══════════════════════════════════════════════════════════════ */

/* ── Overlay ── */
.cr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2147483641;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.cr-overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* ── Container ── */
.cr-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    width: min(900px, 94vw);
    max-height: 88vh;
    background: var(--bg-surface-solid, #1a1b2e);
    border: 1px solid var(--border-glass, rgba(255,255,255,0.08));
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.04);
    z-index: 2147483642;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Outfit', 'Inter', sans-serif;
    color: var(--text-main, #e2e8f0);
}
.cr-container.show {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
}

/* ── Header ── */
.cr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.06));
    background: rgba(255,255,255,0.02);
    flex-shrink: 0;
}
.cr-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.cr-header-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.cr-header-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main, #f1f5f9);
}
.cr-header-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}
.cr-btn-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.04);
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}
.cr-btn-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

/* ── Body ── */
.cr-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Class List Sidebar ── */
.cr-class-sidebar {
    width: 220px;
    border-right: 1px solid var(--border-glass, rgba(255,255,255,0.06));
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: rgba(0,0,0,0.1);
}
.cr-class-sidebar-header {
    padding: 14px 16px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted, #94a3b8);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cr-class-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 10px;
    scrollbar-width: thin;
}
.cr-class-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-main, #e2e8f0);
    position: relative;
}
.cr-class-item:hover {
    background: rgba(99, 102, 241, 0.1);
}
.cr-class-item.active {
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    font-weight: 600;
}
.cr-class-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: #6366f1;
}
.cr-class-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #a5b4fc;
    flex-shrink: 0;
}
.cr-class-item .cr-class-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
    background: rgba(255,255,255,0.05);
    padding: 2px 7px;
    border-radius: 6px;
}
.cr-class-item.archived {
    opacity: 0.72;
    filter: grayscale(0.6);
}
.cr-class-item.archived:hover {
    opacity: 1;
    filter: grayscale(0);
}
.cr-class-item.archived .cr-class-item-icon {
    background: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
}
.cr-archive-group {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-glass, rgba(255,255,255,0.08));
}
.cr-archive-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.cr-archive-header:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main, #e2e8f0);
}
.cr-archive-header .arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.3s;
}
.cr-archive-content {
    margin-top: 6px;
    padding: 4px 0;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 8px;
}
.cr-class-add-btn {
    margin: 8px;
    padding: 10px;
    border-radius: 10px;
    border: 1px dashed rgba(99, 102, 241, 0.3);
    background: transparent;
    color: #a5b4fc;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.cr-class-add-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.5);
}

/* ── Student Panel (Right) ── */
.cr-student-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Empty state */
.cr-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    text-align: center;
    color: var(--text-muted, #94a3b8);
}
.cr-empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}
.cr-empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main, #e2e8f0);
    margin: 0 0 8px;
}
.cr-empty-state p {
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

/* ── Student Header Bar ── */
.cr-student-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.06));
    flex-shrink: 0;
}
.cr-student-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cr-student-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main, #f1f5f9);
    display: flex;
    align-items: center;
    gap: 8px;
}
.cr-student-title .cr-count-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 700;
}
.cr-student-actions {
    display: flex;
    gap: 6px;
}

/* ── Input Row ── */
.cr-add-row {
    display: flex;
    gap: 8px;
}
.cr-add-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-glass, rgba(255,255,255,0.1));
    background: rgba(255,255,255,0.04);
    color: var(--text-main, #e2e8f0);
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}
.cr-add-input:focus {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.cr-add-input::placeholder {
    color: var(--text-muted, #64748b);
}

/* ── Buttons ── */
.cr-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.cr-btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.cr-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}
.cr-btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.cr-btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}
.cr-btn-ghost {
    background: rgba(255,255,255,0.06);
    color: var(--text-muted, #94a3b8);
    border: 1px solid rgba(255,255,255,0.06);
}
.cr-btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main, #e2e8f0);
}
.cr-btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.15);
}
.cr-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}
.cr-btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

/* ── Bulk Add Toggle ── */
.cr-bulk-section {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}
.cr-bulk-section.open {
    max-height: 200px;
    padding: 10px 20px 14px;
}
.cr-bulk-textarea {
    width: 100%;
    height: 80px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-glass, rgba(255,255,255,0.1));
    background: rgba(255,255,255,0.04);
    color: var(--text-main, #e2e8f0);
    font-size: 0.82rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    margin-bottom: 8px;
    box-sizing: border-box;
}
.cr-bulk-textarea:focus {
    border-color: #6366f1;
}
.cr-bulk-hint {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Student List ── */
.cr-student-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    scrollbar-width: thin;
}
.cr-student-row {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    transition: all 0.2s;
    gap: 10px;
    position: relative;
}
.cr-student-row:hover {
    background: rgba(255,255,255,0.04);
}
.cr-student-num {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #a5b4fc;
    flex-shrink: 0;
}
.cr-student-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.cr-student-name {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-main, #e2e8f0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.cr-student-credential {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    letter-spacing: 0.5px;
    white-space: nowrap;
    user-select: all;
    flex-shrink: 0;
    transition: all 0.2s;
}
.cr-student-credential:hover {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(99, 102, 241, 0.4);
    color: #c4b5fd;
}
.cr-cred-edit-input {
    width: 90px;
    background: rgba(0,0,0,0.3);
    border: 1px solid #6366f1;
    color: #e2e8f0;
    font-size: 0.72rem;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    outline: none;
    text-transform: uppercase;
}
.cr-cred-toolbar {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.04);
}
/* ── Selection Mode ── */
.cr-select-bar {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.15);
}
.cr-select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-main, #e2e8f0);
    cursor: pointer;
    user-select: none;
}
.cr-select-all-label input[type="checkbox"] {
    accent-color: #6366f1;
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.cr-select-count {
    flex: 1;
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
}
.cr-student-check {
    accent-color: #6366f1;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}
.cr-student-remove {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
    opacity: 0;
}
.cr-student-row:hover .cr-student-remove {
    opacity: 1;
}
.cr-student-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ── Import from TrackPro banner ── */
.cr-import-banner {
    margin: 8px 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.cr-import-banner:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(139, 92, 246, 0.14));
    border-color: rgba(99, 102, 241, 0.3);
}
.cr-import-banner-icon {
    font-size: 1.2rem;
}
.cr-import-banner-text {
    flex: 1;
}
.cr-import-banner-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #a5b4fc;
}
.cr-import-banner-sub {
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
}

/* ── Footer / Sync Indicator ── */
.cr-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border-glass, rgba(255,255,255,0.06));
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
    flex-shrink: 0;
}
.cr-sync-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    margin-right: 6px;
    animation: cr-pulse 2s ease infinite;
}
@keyframes cr-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Rename inline input ── */
.cr-rename-input {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #6366f1;
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-main, #e2e8f0);
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    width: 100%;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .cr-body {
        flex-direction: column;
    }
    .cr-class-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-glass, rgba(255,255,255,0.06));
        max-height: 150px;
    }
    .cr-class-list {
        display: flex;
        gap: 4px;
        overflow-x: auto;
        padding: 0 8px 8px;
    }
    .cr-class-item {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .cr-container {
        width: 98vw;
        max-height: 92vh;
    }
}
