/* Copyright (c) 2025 William Chesher | MIT License */
/* microverse admin - based on Hielo template by TEMPLATED (CC BY 3.0) */

@import url('https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700');

/* ============================================
   Color Schemes
   Using Tapestry palette families
   ============================================ */

:root {
    /* Default: Purple */
    --accent: #8a4fff;
    --accent-hover: #7a3fee;
    --accent-light: #a87fff;
    --accent-bg: rgba(138, 79, 255, 0.1);
}

/* Ocean - cool blues */
body.scheme-ocean,
html.scheme-ocean {
    --accent: #1976d2;
    --accent-hover: #1565c0;
    --accent-light: #42a5f5;
    --accent-bg: rgba(25, 118, 210, 0.1);
}

/* Forest - natural greens */
body.scheme-forest,
html.scheme-forest {
    --accent: #388e3c;
    --accent-hover: #2e7d32;
    --accent-light: #66bb6a;
    --accent-bg: rgba(56, 142, 60, 0.1);
}

/* Amber - warm gold */
body.scheme-amber,
html.scheme-amber {
    --accent: #d69a3d;
    --accent-hover: #c48a2d;
    --accent-light: #ddbb4c;
    --accent-bg: rgba(214, 154, 61, 0.1);
}

/* Coral - warm pink/orange */
body.scheme-coral,
html.scheme-coral {
    --accent: #e58347;
    --accent-hover: #d57337;
    --accent-light: #f5a677;
    --accent-bg: rgba(229, 131, 71, 0.1);
}

/* Teal - cyan/jade */
body.scheme-teal,
html.scheme-teal {
    --accent: #009696;
    --accent-hover: #007878;
    --accent-light: #2ebdd7;
    --accent-bg: rgba(0, 150, 150, 0.1);
}

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

/* Base */
html, body {
    min-height: 100vh;
}

body {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.75;
    color: #444;
    background: #f5f5f5;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5em;
}

h1 { font-size: 2.5em; }
h2 { font-size: 1.75em; }
h3 { font-size: 1.25em; }

p {
    margin-bottom: 1em;
}

/* Header - Dark header on light theme for contrast */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5em;
    background: #1a1a2e;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2em;
    z-index: 1000;
}

/* Accent strip under header */
#header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
}

#header .logo {
    font-size: 1.25em;
    font-weight: 600;
    color: var(--accent);
}

#header .logo span {
    font-weight: 300;
    color: #888;
    font-size: 0.8em;
}

#header nav {
    display: flex;
    gap: 1.5em;
}

#header nav a {
    color: #aaa;
    font-weight: 400;
}

#header nav a:hover,
#header nav a.active {
    color: var(--accent);
}

/* Navigation dropdown */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    cursor: pointer;
    color: #aaa;
    font-weight: 400;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active {
    color: var(--accent);
}

.nav-dropdown-toggle::after {
    content: ' \25BC';
    font-size: 0.7em;
    margin-left: 0.3em;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #1f2940;
    border: 1px solid #2a3a55;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 180px;
    z-index: 1000;
    padding: 0.5em 0;
    padding-top: 1em;
}

/* Invisible bridge to maintain hover across gap */
.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -0.5em;
    left: 0;
    right: 0;
    height: 0.5em;
}

.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.5em 1em;
    color: #ddd;
    text-decoration: none;
    white-space: nowrap;
}

.nav-dropdown-menu a:hover {
    background: #2a3a55;
    color: var(--accent);
}

#header .user-info {
    display: flex;
    align-items: center;
    gap: 1em;
}

#header .user-info span {
    color: #aaa;
}

#header .user-info .logout {
    color: #888;
    font-size: 0.9em;
}

#header .user-info .logout:hover {
    color: var(--accent);
}

#header .profile-link {
    color: #aaa;
}

#header .profile-link:hover {
    color: var(--accent);
}

/* Main content */
main {
    padding: 5em 2em 2em 2em;
    max-width: 1400px;
    margin: 0 auto;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 1.5em;
    margin-bottom: 1.5em;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
    padding-bottom: 1em;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    margin: 0;
    font-size: 1.25em;
}

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

.stat-card {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
    border-radius: 8px;
    padding: 1.5em;
    text-align: center;
}

.stat-card.alt {
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
}

.stat-card.success {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
}

.stat-card .number {
    font-size: 2.5em;
    font-weight: 600;
    display: block;
}

.stat-card .label {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.75em 1em;
    border-bottom: 1px solid #eee;
}

th {
    font-weight: 500;
    color: #666;
    font-size: 0.85em;
    text-transform: uppercase;
}

tr:hover {
    background: #fafafa;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25em 0.75em;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 500;
}

.badge.online {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge.offline {
    background: #ffebee;
    color: #c62828;
}

.badge.admin {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge.teacher {
    background: #e3f2fd;
    color: #1565c0;
}

.badge.student {
    background: #fff3e0;
    color: #ef6c00;
}

/* Buttons */
.button, button, input[type="submit"] {
    display: inline-block;
    padding: 0.75em 1.5em;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.button:hover, button:hover, input[type="submit"]:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.button.alt {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.button.alt:hover {
    background: var(--accent);
    color: #fff;
}

.button.small {
    padding: 0.4em 0.8em;
    font-size: 0.8em;
}

.button.danger {
    background: #e53935;
}

.button.danger:hover {
    background: #c62828;
}

/* Forms */
.form-group {
    margin-bottom: 1.25em;
}

.form-group label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75em 1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: #fff;
    padding: 3em;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.25em;
}

.login-box .subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 2em;
}

.login-box .error {
    background: #ffebee;
    color: #c62828;
    padding: 0.75em 1em;
    border-radius: 4px;
    margin-bottom: 1em;
    font-size: 0.9em;
    display: none;
}

.login-box .error.show {
    display: block;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    padding: 2em;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 1em;
}

.modal-actions {
    display: flex;
    gap: 1em;
    justify-content: flex-end;
    margin-top: 1.5em;
}

/* Alerts */
.alert {
    padding: 1em;
    border-radius: 4px;
    margin-bottom: 1em;
}

.alert.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.alert.error {
    background: #ffebee;
    color: #c62828;
}

/* Actions */
.actions {
    display: flex;
    gap: 0.5em;
}

/* Token display */
.token-display {
    background: #f5f5f5;
    padding: 1em;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    word-break: break-all;
    margin: 0;
    flex: 1;
}

.token-display-row {
    display: flex;
    gap: 0.5em;
    align-items: stretch;
}

.token-display-row .button {
    flex-shrink: 0;
    align-self: center;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2em;
    color: #888;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3em;
    color: #888;
}

/* ============================================
   Layout Modes
   ============================================ */

/* Fullscreen layout - for full-screen apps like editor */
body.layout-fullscreen {
    overflow: hidden;
}

body.layout-fullscreen main {
    padding: 0;
    max-width: none;
}

body.layout-fullscreen .app-content {
    position: fixed;
    top: 3.5em;  /* Below shell header */
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* When fullscreen app has its own header below shell */
body.layout-fullscreen .app-header {
    height: 3em;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1em;
}

body.layout-fullscreen .app-main {
    position: absolute;
    top: 3em;  /* Below app header */
    left: 0;
    right: 0;
    bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
    #header {
        padding: 0 1em;
    }

    #header nav {
        display: none;
    }

    main {
        padding: 4.5em 1em 1em 1em;
    }

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

    .modal {
        margin: 1em;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Dark Theme
   Applied via body.dark-theme class
   Light header contrasts with dark content
   ============================================ */

body.dark-theme,
html.dark-theme body {
    background: #1a1a2e;
    color: #e0e0e0;
}

/* Dark theme: Light header for contrast */
body.dark-theme #header,
html.dark-theme #header {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body.dark-theme #header .logo,
html.dark-theme #header .logo {
    color: var(--accent);
}

body.dark-theme #header .logo span,
html.dark-theme #header .logo span {
    color: #888;
}

body.dark-theme #header nav a,
html.dark-theme #header nav a {
    color: #666;
}

body.dark-theme #header nav a:hover,
body.dark-theme #header nav a.active,
html.dark-theme #header nav a:hover,
html.dark-theme #header nav a.active {
    color: var(--accent);
}

body.dark-theme .nav-dropdown-toggle,
html.dark-theme .nav-dropdown-toggle {
    color: #666;
}

body.dark-theme .nav-dropdown-toggle:hover,
body.dark-theme .nav-dropdown-toggle.active,
html.dark-theme .nav-dropdown-toggle:hover,
html.dark-theme .nav-dropdown-toggle.active {
    color: var(--accent);
}

body.dark-theme .nav-dropdown-menu,
html.dark-theme .nav-dropdown-menu {
    background: #fff;
    border-color: #e0e0e0;
}

body.dark-theme .nav-dropdown-menu a,
html.dark-theme .nav-dropdown-menu a {
    color: #333;
}

body.dark-theme .nav-dropdown-menu a:hover,
html.dark-theme .nav-dropdown-menu a:hover {
    background: #f5f5f5;
    color: var(--accent);
}

body.dark-theme #header .user-info span,
html.dark-theme #header .user-info span {
    color: #666;
}

body.dark-theme #header .user-info .logout,
html.dark-theme #header .user-info .logout {
    color: #999;
}

body.dark-theme #header .user-info .logout:hover,
html.dark-theme #header .user-info .logout:hover {
    color: var(--accent);
}

body.dark-theme .profile-link {
    color: #666;
}

body.dark-theme .profile-link:hover {
    color: var(--accent);
}

/* Dark theme: Content area */
body.dark-theme main h1,
body.dark-theme main h2,
body.dark-theme main h3 {
    color: #eee;
}

body.dark-theme .card,
body.dark-theme .profile-card,
body.dark-theme .dashboard-card {
    background: #1f2940;
    border-color: #2a3a55;
}

body.dark-theme .card-header {
    border-color: #2a3a55;
}

body.dark-theme table {
    background: #1f2940;
}

body.dark-theme table th {
    background: #16213e;
    color: #ccc;
}

body.dark-theme table td {
    border-color: #2a3a55;
    color: #ddd;
}

body.dark-theme table tr:hover td {
    background: #2a3a55;
}

body.dark-theme .stat-card {
    background: #1f2940;
    border-color: #2a3a55;
}

body.dark-theme .stat-card .label {
    color: #aaa;
}

body.dark-theme .button {
    background: var(--accent);
}

body.dark-theme .button.alt {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}

body.dark-theme input[type="text"],
body.dark-theme input[type="password"],
body.dark-theme input[type="email"],
body.dark-theme select,
body.dark-theme textarea {
    background: #16213e;
    border-color: #2a3a55;
    color: #ddd;
}

body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
    border-color: var(--accent);
}

body.dark-theme .toggle-group {
    border-color: #2a3a55;
}

body.dark-theme .toggle-group button {
    background: #1f2940;
    color: #aaa;
}

body.dark-theme .toggle-group button:hover:not(.active) {
    background: #2a3a55;
}

body.dark-theme .form-group label {
    color: #bbb;
}

body.dark-theme .info-row .label {
    color: #888;
}

body.dark-theme .info-row .value {
    color: #ddd;
}

body.dark-theme .preference-label {
    color: #ddd;
}

body.dark-theme .preference-label .desc {
    color: #888;
}

body.dark-theme .preference-row {
    border-color: #2a3a55;
}

body.dark-theme .alert.success {
    background: #1f3a2e;
    color: #6dbe6d;
    border-color: #2a5a3a;
}

body.dark-theme .alert.error {
    background: #3a1f2e;
    color: #d67070;
    border-color: #5a2a3a;
}

body.dark-theme .theme-selector {
    background: #16213e;
}

body.dark-theme .theme-selector label {
    color: #ddd;
}

body.dark-theme .theme-toggle {
    border-color: #2a3a55;
}

body.dark-theme .theme-toggle button {
    background: #1f2940;
    color: #aaa;
}

body.dark-theme .theme-toggle button:hover:not(.active) {
    background: #2a3a55;
}
