/* ============== Variables ============== */
:root {
    --font-family: var(--font-sans);

    /* Colors - Dark theme (Open Props) */
    --bg-primary: var(--gray-12);
    --bg-secondary: var(--gray-11);
    --bg-tertiary: var(--gray-10);
    --bg-elevated: var(--gray-9);

    --text-primary: var(--gray-0);
    --text-secondary: var(--gray-5);
    --text-muted: var(--gray-7);

    --accent-primary: var(--indigo-6);
    --accent-primary-hover: var(--indigo-5);
    --accent-success: var(--green-6);
    --accent-warning: var(--yellow-5);
    --accent-danger: var(--red-6);
    --accent-danger-hover: var(--red-5);

    --border-color: var(--gray-8);
    --border-radius: var(--radius-2);
    --border-radius-sm: var(--radius-1);

    /* Shadows - using Open Props */
    --shadow-sm: var(--shadow-2);
    --shadow-md: var(--shadow-3);
    --shadow-lg: var(--shadow-4);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--indigo-6) 0%, var(--violet-6) 100%);
    --gradient-card: linear-gradient(145deg, hsl(var(--indigo-6-hsl) / 0.1) 0%, hsl(var(--violet-6-hsl) / 0.05) 100%);
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-primary: var(--gray-0);
    --bg-secondary: var(--gray-1);
    --bg-tertiary: var(--gray-2);
    --bg-elevated: var(--gray-3);

    --text-primary: var(--gray-9);
    --text-secondary: var(--gray-7);
    --text-muted: var(--gray-5);

    --border-color: var(--gray-4);

    --accent-primary: var(--indigo-7);
    --accent-primary-hover: var(--indigo-8);
    --accent-success: var(--green-7);
    --accent-warning: var(--yellow-7);
    --accent-danger: var(--red-7);
    --accent-danger-hover: var(--red-8);

    --gradient-card: linear-gradient(145deg, hsl(var(--indigo-7-hsl) / 0.05) 0%, hsl(var(--violet-7-hsl) / 0.02) 100%);
}

/* ============== Reset ============== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

/* ============== Utilities ============== */
.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
}

/* ============== Login / Setup ============== */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--size-8);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: var(--font-size-8);
    margin-bottom: var(--size-4);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.login-header h1 {
    font-size: var(--font-size-5);
    font-weight: var(--font-weight-7);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.login-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--size-8);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: var(--size-4);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px hsl(var(--indigo-6-hsl) / 20%);
}

.form-group small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.input-display {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
}

.error-message {
    color: var(--accent-danger);
    font-size: 0.875rem;
    margin-top: 1rem;
    text-align: center;
}

.login-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
}

.login-separator::before,
.login-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.login-separator span {
    margin: 0 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============== Buttons ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--accent-danger-hover);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
}

.btn-github {
    background: var(--gray-9);
    color: var(--gray-0);
    font-size: var(--font-size-2);
    padding: var(--size-4) var(--size-6);
}

.btn-github:hover {
    background: var(--gray-8);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-github svg {
    margin-right: 0.5rem;
}

.login-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 1rem;
}

/* ============== Header ============== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--size-3) var(--size-6);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: var(--layer-top);
    backdrop-filter: blur(10px);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.logo-small {
    font-size: 1.5rem;
}

.user-badge {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 2rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============== Main Content ============== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--size-8);
}

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 2rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============== Groups Section ============== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--size-5);
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.groups-list {
    display: flex;
    flex-direction: column;
    gap: var(--size-2);
}

.group-card {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: var(--size-3);
    padding: var(--size-4) var(--size-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.group-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.group-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.group-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.group-stats {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.group-status {
    padding: var(--size-1) var(--size-3);
    border-radius: var(--radius-round);
    font-size: var(--font-size-0);
    font-weight: var(--font-weight-5);
}

.group-status.active {
    background: hsl(var(--green-6-hsl) / 0.15);
    color: var(--accent-success);
}

.group-status.paused {
    background: hsl(var(--yellow-5-hsl) / 0.15);
    color: var(--accent-warning);
}

/* ============== Editor ============== */
.config-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.config-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.config-row .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.select-status {
    min-width: 150px;
}

.url-display {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.url-display code {
    display: inline-block;
    margin-left: var(--size-2);
    padding: var(--size-1) var(--size-2);
    background: var(--bg-tertiary);
    border-radius: var(--radius-1);
    font-family: var(--font-mono);
    color: var(--accent-primary);
    word-break: break-all;
}

/* ============== Tabs ============== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.tab {
    display: flex;
    align-items: center;
    gap: var(--size-2);
    padding: var(--size-2) var(--size-4);
    font-size: var(--font-size-1);
    font-weight: var(--font-weight-5);
    font-family: var(--font-family);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

.badge {
    padding: var(--size-1) var(--size-2);
    background: hsl(0 0% 100% / 20%);
    border-radius: var(--radius-round);
    font-size: var(--font-size-0);
}

.tab:not(.active) .badge {
    background: var(--bg-tertiary);
}

/* ============== Rules ============== */
.rules-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--size-5);
}

.rules-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: var(--size-2) var(--size-4);
    font-size: var(--font-size-1);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.rule-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--size-2) var(--size-4);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    transition: background 0.2s;
}

.rule-item:hover {
    background: var(--bg-elevated);
}

.rule-value {
    font-family: var(--font-mono);
    font-size: var(--font-size-1);
}

.rule-delete {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.rule-item:hover .rule-delete {
    opacity: 1;
}

.empty-state {
    text-align: center;
    padding: var(--size-8);
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 1rem;
}

/* ============== Modal ============== */
.modal {
    position: fixed;
    inset: 0;
    background: hsl(0 0% 0% / 75%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--layer-important);
    padding: var(--size-4);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

.modal-large {
    max-width: 600px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--size-4) var(--size-5);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal form {
    padding: var(--size-5);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--size-3);
    margin-top: var(--size-5);
}

/* ============== Toast ============== */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: var(--size-3) var(--size-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--accent-success);
}

.toast.error {
    border-left: 4px solid var(--accent-danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============== System Toggle ============== */
.system-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--size-2);
    padding: var(--size-2) var(--size-4);
    font-weight: var(--font-weight-6);
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
}

.system-toggle .toggle-icon {
    font-size: 1.1rem;
}

.system-toggle.active {
    background: var(--accent-success);
    color: white;
}

.system-toggle.active:hover {
    background: var(--green-7);
}

.system-toggle.inactive {
    background: var(--accent-danger);
    color: white;
    animation: pulse-danger 2s infinite;
}

.system-toggle.inactive:hover {
    background: var(--accent-danger-hover);
}

@keyframes pulse-danger {

    0%,
    100% {
        box-shadow: 0 0 0 0 hsl(var(--red-6-hsl) / 40%);
    }

    50% {
        box-shadow: 0 0 0 8px hsl(var(--red-6-hsl) / 0%);
    }
}

/* ============== System Status Banner ============== */
.system-status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--size-3) var(--size-4);
    margin-bottom: var(--size-5);
    background: linear-gradient(135deg, hsl(var(--red-6-hsl) / 15%) 0%, hsl(var(--yellow-5-hsl) / 10%) 100%);
    border: 1px solid var(--accent-danger);
    border-radius: var(--border-radius);
    animation: banner-pulse 3s infinite;
}

@keyframes banner-pulse {

    0%,
    100% {
        border-color: var(--accent-danger);
    }

    50% {
        border-color: var(--accent-warning);
    }
}

.system-status-banner .status-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.system-status-banner .status-icon {
    font-size: 1.5rem;
    animation: shake 0.5s ease-in-out infinite alternate;
}

@keyframes shake {
    from {
        transform: rotate(-5deg);
    }

    to {
        transform: rotate(5deg);
    }
}

.system-status-banner .status-text {
    font-weight: 600;
    color: var(--accent-danger);
}

.btn-success {
    background: var(--accent-success);
    color: white;
}

.btn-success:hover {
    background: var(--green-7);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ============== Requests Section ============== */
.requests-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--size-5);
    margin-bottom: var(--size-7);
    border: 1px solid var(--border-color);
}

.requests-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.requests-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.requests-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--accent-success);
    box-shadow: 0 0 var(--size-2) var(--accent-success);
}

.status-dot.offline {
    background: var(--accent-danger);
}

.requests-config {
    display: flex;
    flex-wrap: wrap;
    gap: var(--size-3);
    padding: var(--size-3);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--size-3);
}

.requests-config .form-group.inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.requests-config label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.requests-config input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
}

.requests-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.requests-list .empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.requests-list .empty-message.error {
    color: var(--accent-danger);
}

.request-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--size-3);
    padding: var(--size-3);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.request-item.read-only {
    opacity: 0.7;
    background: var(--bg-secondary);
}

.request-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.request-domain {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-6);
    color: var(--accent-primary);
}

.request-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.request-group {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.request-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.request-group-select {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* Stat card for requests */
.stat-card.stat-requests {
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card.stat-requests:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.stat-card.stat-requests.has-pending {
    border-color: var(--accent-warning);
    background: linear-gradient(145deg, hsl(var(--yellow-5-hsl) / 10%) 0%, hsl(var(--yellow-5-hsl) / 5%) 100%);
}

.stat-card.stat-requests.has-pending .stat-icon {
    animation: bounce 1s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* ============== Responsive ============== */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .group-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .config-row {
        flex-direction: column;
    }

    .config-row .btn {
        width: 100%;
    }

    .tabs {
        flex-wrap: nowrap;
    }

    .rules-toolbar {
        flex-direction: column;
    }

    .system-toggle .toggle-text {
        display: none;
    }

    .system-status-banner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .request-item {
        flex-direction: column;
        align-items: stretch;
    }

    .request-actions {
        justify-content: flex-end;
    }

    .requests-config {
        flex-direction: column;
    }

    .requests-config .form-group.inline {
        flex-direction: column;
        align-items: stretch;
    }

    /* Mobile-first teacher quick actions */
    .quick-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }

    .quick-actions .btn {
        flex: 1;
        padding: 0.875rem;
        font-size: 1rem;
    }
}

/* ============== Users Section ============== */
.users-section {
    margin-top: var(--size-7);
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--size-4) var(--size-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.user-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.user-info {
    flex: 1;
}

.user-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.user-roles {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============== Role Badges ============== */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--size-1);
    padding: var(--size-1) var(--size-3);
    border-radius: var(--radius-round);
    font-size: var(--font-size-0);
    font-weight: var(--font-weight-5);
}

.role-badge.admin {
    background: hsl(var(--yellow-4-hsl) / 0.15);
    color: var(--yellow-4);
}

.role-badge.teacher {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.role-badge.student {
    background: hsl(var(--green-6-hsl) / 0.15);
    color: var(--accent-success);
}

.role-badge .group-count {
    padding: var(--size-1) calc(var(--size-1) * 1.5);
    background: hsl(0 0% 100% / 0.1);
    border-radius: var(--radius-pill);
    font-size: var(--font-size-00);
}

/* ============== Status Badges ============== */
.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-success);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}

.status-badge.pending {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-warning);
}

/* ============== Checkbox List ============== */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: var(--size-2);
    max-height: 200px;
    overflow-y: auto;
    padding: var(--size-2);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-item:hover {
    background: var(--bg-elevated);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.checkbox-item label {
    flex: 1;
    cursor: pointer;
    font-size: 0.875rem;
}

/* ============== Teacher View ============== */
.teacher-view .admin-only {
    display: none !important;
}

.teacher-banner {
    display: flex;
    align-items: center;
    gap: var(--size-3);
    padding: var(--size-3) var(--size-5);
    margin-bottom: var(--size-5);
    background: linear-gradient(135deg, hsl(var(--indigo-6-hsl) / 0.15) 0%, hsl(var(--violet-6-hsl) / 0.1) 100%);
    border: 1px solid var(--accent-primary);
    border-radius: var(--border-radius);
}

.teacher-banner .icon {
    font-size: 1.5rem;
}

.teacher-banner .info {
    flex: 1;
}

.teacher-banner .info strong {
    display: block;
    margin-bottom: 0.25rem;
}

.teacher-banner .info span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============== Quick Approval Buttons ============== */
.btn-approve {
    background: var(--accent-success);
    color: white;
}

.btn-approve:hover {
    background: var(--green-7);
}

.btn-reject {
    background: var(--accent-danger);
    color: white;
}

.btn-reject:hover {
    background: var(--accent-danger-hover);
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
}

.btn-success {
    background: var(--accent-success);
    color: white;
}

.btn-success:hover {
    background: var(--green-7);
}

/* ============== Empty State ============== */
.empty-message {
    text-align: center;
    padding: var(--size-8);
    color: var(--text-muted);
    font-style: italic;
}

/* ============== Teacher Dashboard Enhancements ============== */
/* Success empty state for teachers */
.empty-message.success {
    color: var(--accent-success);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.empty-message.success::before {
    content: '✅';
    font-size: 2rem;
}

/* Request card improvements for quick approval */
.request-item {
    position: relative;
}

.request-item .request-domain {
    font-size: 1.1rem;
    word-break: break-all;
}

.request-item .request-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: inline-block;
    margin-left: 0.5rem;
}

.request-item .request-time::before {
    content: '⏱️ ';
}

/* Action buttons - 44px minimum for touch targets */
.request-actions .btn {
    min-height: 44px;
    min-width: 44px;
    font-size: var(--font-size-3);
    padding: var(--size-2) var(--size-3);
}

.request-actions .approve-request-btn {
    background: var(--accent-success);
    color: white;
}

.request-actions .approve-request-btn:hover {
    background: var(--green-7);
    transform: scale(1.05);
}

.request-actions .reject-request-btn {
    background: var(--accent-danger);
    color: white;
}

.request-actions .reject-request-btn:hover {
    background: var(--accent-danger-hover);
    transform: scale(1.05);
}

.request-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Status badge for read-only requests */
.status-badge {
    padding: var(--size-1) var(--size-3);
    border-radius: var(--radius-round);
    font-size: var(--font-size-0);
    font-weight: var(--font-weight-5);
}

.status-badge.pending {
    background: hsl(var(--yellow-5-hsl) / 0.15);
    color: var(--accent-warning);
}

.status-badge.active {
    background: hsl(var(--green-6-hsl) / 0.15);
    color: var(--accent-success);
}

.status-badge.inactive {
    background: hsl(var(--gray-5-hsl) / 0.15);
    color: var(--text-muted);
}

/* Mobile: Full-width action buttons */
@media (max-width: 480px) {
    .request-item {
        padding: 1rem;
    }

    .request-actions {
        width: 100%;
        justify-content: stretch;
        gap: 0.75rem;
        margin-top: 0.75rem;
    }

    .request-actions .btn {
        flex: 1;
        min-height: 48px;
        font-size: 1.5rem;
    }

    .request-actions .request-group-select {
        flex: 2;
        min-height: 48px;
        font-size: 1rem;
    }

    /* Larger teacher banner on mobile */
    .teacher-banner {
        flex-direction: column;
        text-align: center;
    }

    .teacher-banner .icon {
        font-size: 2rem;
    }

    /* Stats section - 2 columns on small screens */
    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hide admin-only buttons for cleaner teacher view */
    .header .admin-only {
        display: none;
    }
}

/* Extra small screens (320px) */
@media (max-width: 360px) {
    .stats-section {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: var(--size-3);
    }

    .stat-number {
        font-size: var(--font-size-4);
    }
}

/* ============== Blocked Domain Alert Modal ============== */
.modal-blocked-domain {
    max-width: 480px;
}

.modal-header-warning {
    background: linear-gradient(135deg, hsl(var(--red-6-hsl) / 15%) 0%, hsl(var(--yellow-5-hsl) / 10%) 100%);
    border-bottom: 2px solid var(--accent-danger);
}

.modal-header-warning h3 {
    color: var(--accent-danger);
}

.modal-body {
    padding: var(--size-5);
}

.blocked-domain-alert {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.blocked-domain-icon {
    font-size: 3rem;
    line-height: 1;
    flex-shrink: 0;
}

.blocked-domain-info {
    flex: 1;
}

.blocked-domain-message {
    font-size: 1rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.blocked-domain-message strong {
    color: var(--accent-danger);
    font-weight: 600;
}

.blocked-domain-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--accent-warning);
    margin-bottom: 1rem;
}

.blocked-domain-details .detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.blocked-domain-details code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 1rem;
    color: var(--accent-warning);
    font-weight: 600;
}

.blocked-domain-hint {
    font-size: var(--font-size-1);
    color: var(--text-secondary);
    padding: var(--size-2);
    background: hsl(var(--indigo-6-hsl) / 0.1);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--accent-primary);
}

/* Mobile responsive for blocked domain modal */
@media (max-width: 480px) {
    .blocked-domain-alert {
        flex-direction: column;
        text-align: center;
    }

    .blocked-domain-icon {
        font-size: 4rem;
        margin: 0 auto;
    }

    .blocked-domain-details {
        border-left: none;
        border-top: 3px solid var(--accent-warning);
    }

    .blocked-domain-hint {
        border-left: none;
        border-top: 3px solid var(--accent-primary);
    }
}

/* ============== Classrooms Section ============== */
.classrooms-section {
    margin-bottom: var(--size-7);
}

.classrooms-list {
    display: flex;
    flex-direction: column;
    gap: var(--size-2);
}

.classroom-card {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: var(--size-5);
    padding: var(--size-4) var(--size-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.classroom-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.classroom-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.classroom-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.classroom-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.classroom-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.classroom-group select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    min-width: 200px;
}

.classroom-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.classroom-actions {
    display: flex;
    gap: 0.5rem;
}

/* Mobile responsive for classrooms */
@media (max-width: 768px) {
    .classroom-card {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .classroom-group {
        width: 100%;
    }

    .classroom-group select {
        width: 100%;
    }
}

/* ============== Schedule Grid ============== */
.schedule-section {
    margin-bottom: var(--size-7);
}

.schedule-grid-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--size-5);
    overflow-x: auto;
}

.schedule-grid {
    min-width: 600px;
}

.schedule-header {
    display: grid;
    grid-template-columns: 100px repeat(5, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.schedule-time-header,
.schedule-day-header {
    padding: var(--size-2);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-weight: var(--font-weight-6);
    font-size: var(--font-size-1);
    text-align: center;
}

.schedule-time-header {
    color: var(--text-muted);
}

.schedule-day-header {
    color: var(--text-primary);
}

.schedule-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.schedule-row {
    display: grid;
    grid-template-columns: 100px repeat(5, 1fr);
    gap: 4px;
}

.schedule-time {
    padding: 0.75rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.schedule-cell {
    min-height: 60px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.schedule-cell-empty {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    cursor: pointer;
}

.schedule-cell-empty:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
}

.schedule-add-icon {
    font-size: 1.5rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.schedule-cell-empty:hover .schedule-add-icon {
    opacity: 1;
    color: var(--accent-primary);
}

.schedule-cell-occupied {
    padding: 0.5rem;
    text-align: center;
}

.schedule-cell-occupied.is-mine {
    background: linear-gradient(135deg, hsl(var(--indigo-6-hsl) / 0.3) 0%, hsl(var(--violet-6-hsl) / 0.2) 100%);
    border: 1px solid var(--accent-primary);
}

.schedule-cell-occupied.is-other {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
}

.schedule-group-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.schedule-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    background: var(--accent-danger);
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.schedule-cell-occupied:hover .schedule-delete-btn {
    opacity: 1;
}

.schedule-delete-btn:hover {
    background: var(--accent-danger-hover);
}

.schedule-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.schedule-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.schedule-legend-color {
    width: 12px;
    height: 12px;
    background: var(--gradient-primary);
    border-radius: 3px;
}

.schedule-no-groups {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 1rem;
    text-align: center;
}

/* Mobile responsive for schedule grid */
@media (max-width: 768px) {
    .schedule-header {
        grid-template-columns: 70px repeat(5, 1fr);
    }

    .schedule-row {
        grid-template-columns: 70px repeat(5, 1fr);
    }

    .schedule-time {
        font-size: 0.65rem;
        padding: 0.5rem 0.25rem;
    }

    .schedule-day-header {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }

    .schedule-cell {
        min-height: 50px;
    }

    .schedule-group-name {
        font-size: 0.65rem;
    }
}

.success-message {
    padding: 0.75rem;
    background-color: var(--success-bg, #def7ec);
    color: var(--success-text, #03543f);
    border-radius: 4px;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.login-links {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.forgot-password-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
}

.forgot-password-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* ============== Loading Spinner ============== */

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-spin 0.75s linear infinite;
    vertical-align: middle;
}

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

.btn.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn.is-loading .btn-text-hide {
    visibility: hidden;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-left-color: currentColor;
    border-radius: 50%;
    animation: spinner-spin 0.6s linear infinite;
}

/* ============== Machines Table ============== */
.machines-section {
    margin-bottom: var(--size-7);
}

.machines-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.machines-table {
    width: 100%;
    border-collapse: collapse;
}

.machines-table th,
.machines-table td {
    padding: var(--size-3) var(--size-4);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.machines-table th {
    background: var(--bg-tertiary);
    font-weight: var(--font-weight-6);
    font-size: var(--font-size-1);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.machines-table tbody tr:hover {
    background: var(--bg-hover);
}

.machines-table tbody tr:last-child td {
    border-bottom: none;
}

.machines-table .actions-cell {
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: var(--font-size-0);
    font-weight: var(--font-weight-5);
    border-radius: var(--border-radius-sm);
}

.badge-success {
    background: var(--success-bg, #def7ec);
    color: var(--success-text, #03543f);
}

.badge-warning {
    background: var(--warning-bg, #fef3c7);
    color: var(--warning-text, #92400e);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: var(--font-size-0);
}

.token-url-display {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.token-url-display .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.token-url-display .modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: var(--size-6);
    max-width: 600px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.token-url-display .modal-content h3 {
    margin: 0 0 var(--size-2) 0;
}

.token-url-display .modal-content input {
    margin: var(--size-4) 0;
    font-family: monospace;
    font-size: var(--font-size-0);
}

.token-url-display .modal-actions {
    display: flex;
    gap: var(--size-3);
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .machines-table {
        font-size: var(--font-size-0);
    }

    .machines-table th,
    .machines-table td {
        padding: var(--size-2);
    }

    .machines-table th:nth-child(3),
    .machines-table td:nth-child(3),
    .machines-table th:nth-child(5),
    .machines-table td:nth-child(5) {
        display: none;
    }
}