/* ==========================================================================
   Teacher2Discord — Design System
   ========================================================================== */

/* ===== Design tokens ===== */
:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #131825;
    --bg-tertiary: #1a2035;
    --bg-hover: #212942;
    --border: #252d42;
    --border-glow: #364063;
    --text-primary: #e8ecf4;
    --text-secondary: #8b93a8;
    --text-muted: #505872;
    --accent: #5865F2;
    --accent-hover: #4752C4;
    --accent-glow: rgba(88, 101, 242, 0.2);
    --accent-subtle: rgba(88, 101, 242, 0.08);
    --success: #57F287;
    --success-bg: rgba(87, 242, 135, 0.08);
    --success-border: rgba(87, 242, 135, 0.2);
    --warning: #FEE75C;
    --warning-bg: rgba(254, 231, 92, 0.08);
    --warning-border: rgba(254, 231, 92, 0.2);
    --danger: #ED4245;
    --danger-hover: #d63031;
    --danger-bg: rgba(237, 66, 69, 0.08);
    --danger-border: rgba(237, 66, 69, 0.2);
    --info-bg: rgba(88, 101, 242, 0.08);
    --info-border: rgba(88, 101, 242, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 0.9375rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #7983f5; }


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

/* ===== Header ===== */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(16px) saturate(1.8);
    -webkit-backdrop-filter: blur(16px) saturate(1.8);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; opacity: 0.9; }
.brand span { color: var(--accent); }
.nav-logo {
    height: 28px;
    width: auto;
    margin-right: 0.5rem;
    border-radius: 4px;
}
header nav { display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; }

/* ===== Main content ===== */
main {
    flex: 1;
    padding: 2rem 1.5rem 3rem;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    animation: pageIn 0.35s ease-out;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}


/* ==========================================================================
   Typography
   ========================================================================== */

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}
h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}


/* ==========================================================================
   Components
   ========================================================================== */

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
    border-color: var(--border-glow);
}
.card-left-align {
    text-align: left;
}

/* ===== Forms ===== */
label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}
input[type="text"], input[type="email"], input[type="url"],
textarea, select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font);
    margin-bottom: 0.75rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}
textarea { resize: vertical; min-height: 100px; }

input[type="file"] {
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}
input[type="file"]::file-selector-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    font-family: var(--font);
    font-size: 0.82rem;
    cursor: pointer;
    margin-right: 0.75rem;
    transition: background var(--transition);
}
input[type="file"]::file-selector-button:hover {
    background: var(--bg-hover);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1.1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}
.btn:active { transform: translateY(0); }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-full { width: 100%; }

.btn-danger { background: var(--danger); }
.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 0 20px rgba(237, 66, 69, 0.2);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-ghost:hover {
    border-color: var(--border-glow);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}
.btn-outline:hover {
    background: var(--accent-subtle);
    box-shadow: none;
}

/* ===== Alerts ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
    border: 1px solid transparent;
}
.alert-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: #a0aaff;
}
.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success);
}
.alert-error {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}
.alert-warning {
    background: rgba(250, 176, 5, 0.1);
    border-color: rgba(250, 176, 5, 0.35);
    color: #f5c451;
}
.alert .close-btn {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity var(--transition);
    padding: 0.25rem;
}
.alert .close-btn:hover { opacity: 1; }

/* ===== Breadcrumbs ===== */
.breadcrumb {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.2rem;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-muted); margin: 0 0.2rem; font-size: 0.7rem; }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.5rem;
    letter-spacing: 0.02em;
}
.badge-default {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}
.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

/* ===== Item rows ===== */
.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(37, 45, 66, 0.5);
}
.item-row:last-child { border-bottom: none; }
.item-row .label { font-size: 0.9rem; }

/* ===== Channel cards ===== */
.channel-card {
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
}
.channel-card:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
    text-decoration: none;
    transform: translateX(4px);
    box-shadow: -4px 0 0 var(--accent);
}
.channel-card .channel-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.channel-card .channel-arrow {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all var(--transition);
}
.channel-card:hover .channel-arrow {
    color: var(--accent);
    transform: translateX(3px);
}

/* ===== Copy box ===== */
.copy-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
    font-family: 'SFMono-Regular', 'Cascadia Code', 'Consolas', monospace;
    line-height: 1.5;
}


/* ==========================================================================
   Page layouts
   ========================================================================== */

/* ===== Section divider ===== */
.section { margin-top: 2rem; }

/* ===== Grid layouts ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state-compact {
    padding: 2rem;
}
.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}
.empty-state p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* ===== Centered page layout ===== */
.page-center {
    max-width: 420px;
    margin: 3rem auto;
    text-align: center;
}
.page-center .page-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.page-center p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    line-height: 1.6;
}
.page-center p strong {
    color: var(--text-primary);
}

/* ===== Page header with actions ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h1 { margin-bottom: 0; }

/* ===== Inline form (for delete buttons, etc.) ===== */
.inline-form { display: inline; }

/* ===== Copy row ===== */
.copy-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.copy-row .copy-box { flex: 1; }

/* ===== Send form layout ===== */
.send-form { margin-bottom: 1.5rem; }
.send-form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.send-form-actions input[type="file"] {
    flex: 1;
    min-width: 0;
}

/* ===== Subfolder card ===== */
.subfolder-card {
    margin-bottom: 0.5rem;
    padding: 0.75rem 1.25rem;
}
.subfolder-card .item-row {
    border: none;
    padding: 0;
}

/* ===== Hint text ===== */
.hint-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}


/* ==========================================================================
   Message history
   ========================================================================== */

/* ===== Message history header ===== */
.message-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.message-history-header h2 { margin-bottom: 0; }
.message-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== Load more button ===== */
.load-more-wrap {
    padding: 0.75rem;
    text-align: center;
    border-top: 1px solid rgba(37, 45, 66, 0.3);
    margin-top: 0.25rem;
}

.message-history {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
}
.message-history::-webkit-scrollbar { width: 6px; }
.message-history::-webkit-scrollbar-track { background: transparent; }
.message-history::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.message-item {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.message-item:hover { background: var(--bg-tertiary); }
.message-item + .message-item { border-top: 1px solid rgba(37, 45, 66, 0.3); }
.message-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.message-meta strong { color: var(--text-secondary); }
.message-body {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.5;
}
.message-attachment {
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 0.35rem;
}

/* ===== Attachment previews ===== */
.message-attachment-preview {
    margin-top: 0.5rem;
}

/* --- Image frame --- */
.attachment-image-frame {
    max-width: 360px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.attachment-image-frame:hover {
    border-color: var(--border-glow);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.attachment-image-frame img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    cursor: pointer;
    transition: opacity var(--transition);
}
.attachment-image-frame img:hover {
    opacity: 0.92;
}

/* --- Video frame --- */
.attachment-video-frame {
    max-width: 420px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
}
.attachment-video-frame video {
    display: block;
    width: 100%;
    max-height: 300px;
}

/* --- Generic file card --- */
.attachment-file-card {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}
.attachment-file-card:hover {
    border-color: var(--border-glow);
}
.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    text-transform: uppercase;
}
.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.file-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 250px;
}
.file-download {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
}
.file-download:hover {
    text-decoration: underline;
}

/* --- Attachment label and links (below preview) --- */
.attachment-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}
.attachment-footer {
    margin-top: 0.35rem;
    display: inline-flex;
    align-items: center;
}
.attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.76rem;
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
.attachment-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}
.attachment-open-icon {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* ===== Lightbox ===== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.lightbox-overlay.active { opacity: 1; }
.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    animation: popIn 0.25s ease-out;
}
.lightbox-content img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.lightbox-caption {
    color: var(--text-secondary);
    font-size: 0.84rem;
    margin-top: 0.85rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    flex-wrap: wrap;
}
.lightbox-open-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition);
}
.lightbox-open-link:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}
.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.75rem;
    cursor: pointer;
    transition: color var(--transition);
    line-height: 1;
}
.lightbox-close:hover { color: #fff; }


/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease-out;
}
.modal-overlay.active { display: flex; }
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-md);
    animation: popIn 0.2s ease-out;
}
.modal-card .modal-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.modal-card h3 {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}
.modal-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.modal-actions .btn { min-width: 100px; }


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

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}


/* ==========================================================================
   Utilities
   ========================================================================== */

.center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 2rem; }
.mt-0 { margin-top: 0.25rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.flex-row { display: flex; gap: 0.5rem; align-items: center; }

/* ===== Error list ===== */
.errorlist {
    color: var(--danger);
    font-size: 0.8rem;
    list-style: none;
    margin-bottom: 0.5rem;
}


/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
    main { padding: 1.25rem 1rem 2rem; }
    h1 { font-size: 1.25rem; }
    .grid-2 { grid-template-columns: 1fr; }
    .page-center { margin: 1.5rem auto; }
    .attachment-image-frame { max-width: 100%; }
    .attachment-video-frame { max-width: 100%; }
    .file-name { max-width: 160px; }
}

/* ==========================================================================
   Navigation & Logo Utilities
   ========================================================================== */
.nav-logo {
    height: 28px;
    width: auto;
    margin-right: 0.5rem;
    border-radius: 4px;
}

.login-header-logo {
    height: 32px;
    width: auto;
    vertical-align: middle;
    margin-right: 0.2rem;
    margin-top: -6px;
}

.text-left {
    text-align: left !important;
}

