/* ═══════════════════════════════════════════════════════════
   10 Minute School Affiliate Hub — Global Stylesheet
   Design: Glassmorphism + gradient, 2024 premium dark theme
   Font: Inter (Google Fonts)
   ═══════════════════════════════════════════════════════════ */

/* ─── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep: #0f172a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-start: #6366f1;
    --accent-end: #3b82f6;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --radius-sm: 0.5rem;
    --radius-md: 0.85rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.08);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

a {
    color: var(--accent-start);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-end);
}

/* ─── ANIMATED BACKGROUND BLOBS ────────────────────────── */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: blobFloat 18s ease-in-out infinite;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #6366f1, transparent 70%);
    top: -10%;
    left: -5%;
    animation-delay: 0s;
}

.blob-2 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #3b82f6, transparent 70%);
    top: 40%;
    right: -10%;
    animation-delay: -6s;
    animation-duration: 22s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #8b5cf6, transparent 70%);
    bottom: -5%;
    left: 30%;
    animation-delay: -12s;
    animation-duration: 20s;
}

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(60px, -40px) scale(1.08); }
    50%      { transform: translate(-30px, 50px) scale(0.95); }
    75%      { transform: translate(40px, 20px) scale(1.05); }
}

/* ─── GLASS CARD ───────────────────────────────────────── */
.glass-card {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-glow);
}

/* ─── HERO SECTION ─────────────────────────────────────── */
.hero {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 5rem 0 3rem;
}

.hero-badge {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 50px;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(59,130,246,0.15));
    border: 1px solid rgba(99,102,241,0.25);
    color: #a5b4fc;
    margin-bottom: 1.5rem;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 2.5rem;
    line-height: 1.7;
}

/* ─── SEARCH ───────────────────────────────────────────── */
.search-wrapper {
    max-width: 640px;
    margin: 0 auto;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition);
}

.search-box input {
    width: 100%;
    padding: 1.1rem 3rem 1.1rem 3.5rem;
    font-size: 1.05rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.search-box input:focus {
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255,255,255,0.06);
}

.search-box input:focus ~ .search-icon,
.search-box input:focus + .search-icon {
    color: var(--accent-start);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    position: absolute;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    transition: color var(--transition), background var(--transition);
    opacity: 0;
    pointer-events: none;
}

.search-clear.visible {
    opacity: 1;
    pointer-events: auto;
}

.search-clear:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
}

.search-meta {
    margin-top: 0.85rem;
    text-align: center;
}

.result-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── COURSE GRID ──────────────────────────────────────── */
.course-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    padding-bottom: 6rem;
}

.course-card {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.course-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-glass-hover);
    background: var(--bg-card-hover);
    box-shadow: 0 12px 40px rgba(0,0,0,0.25), var(--shadow-glow);
}

.card-name {
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-link-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: rgba(255,255,255,0.03);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.04);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

/* ─── BUTTONS ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.btn-ghost {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    border-color: var(--border-glass-hover);
}

.btn-copy {
    flex: 1;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}
.btn-copy:hover {
    background: rgba(99,102,241,0.12);
    color: #a5b4fc;
    border-color: rgba(99,102,241,0.3);
}
.btn-copy.copied {
    background: var(--success-bg) !important;
    color: var(--success) !important;
    border-color: rgba(34,197,94,0.3) !important;
}

.btn-edit {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    padding: 0.65rem;
    min-width: 42px;
}
.btn-edit:hover {
    background: rgba(251,191,36,0.12);
    color: var(--warning);
    border-color: rgba(251,191,36,0.3);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover {
    background: rgba(239,68,68,0.2);
    box-shadow: 0 2px 12px rgba(239,68,68,0.15);
}

.btn-danger-ghost {
    color: #f87171;
}
.btn-danger-ghost:hover {
    background: var(--danger-bg);
    border-color: rgba(239,68,68,0.2);
}

.btn-full {
    width: 100%;
}

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

/* ─── FLOATING ACTION BUTTON ──────────────────────────── */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.3);
    transition: transform var(--transition), box-shadow var(--transition);
}
.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 8px 32px rgba(99,102,241,0.45);
}

/* ─── MODALS ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 1.5rem;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    width: 100%;
    max-width: 520px;
    padding: 2rem;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
}
.modal-close:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.12);
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

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

/* ─── FORMS ────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus {
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}
.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}
.form-row .btn {
    height: 44px;
    flex-shrink: 0;
}

/* ─── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 4rem 2rem;
}
.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}
.empty-state h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.empty-state p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ─── TOAST ────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 2000;
    padding: 0.85rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    max-width: 90vw;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
}
.toast.toast-success {
    border-color: rgba(34,197,94,0.3);
    color: #4ade80;
}
.toast.toast-error {
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

/* ─── FOOTER ───────────────────────────────────────────── */
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem 0 3rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.site-footer a {
    color: var(--text-secondary);
}
.site-footer a:hover {
    color: var(--accent-start);
}

/* ─── ALERTS ───────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}
.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239,68,68,0.2);
    color: #f87171;
}

/* ─── LOGIN PAGE ───────────────────────────────────────── */
.login-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-card .form-group {
    text-align: left;
}

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.back-link:hover {
    color: var(--text-primary);
}

/* ─── ADMIN PAGE ───────────────────────────────────────── */
.admin-header {
    position: relative;
    z-index: 1;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 2rem;
}

.admin-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 50px;
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.25);
    color: #a5b4fc;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 0.5rem;
    vertical-align: middle;
}

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

.admin-main {
    position: relative;
    z-index: 1;
    padding-bottom: 4rem;
}

.admin-add-section {
    padding: 2rem;
    margin-bottom: 1.5rem;
}
.admin-add-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

/* ─── ADMIN TABLE ──────────────────────────────────────── */
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem 0;
}
.table-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.course-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    background: rgba(255,255,255,0.05);
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
}

.table-wrapper {
    overflow-x: auto;
    padding: 1rem 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table thead th {
    text-align: left;
    padding: 0.85rem 1.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-glass);
}

.admin-table tbody tr {
    transition: background var(--transition);
}
.admin-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.admin-table tbody td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}

.td-id {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    width: 50px;
}

.td-name {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 250px;
}

.td-link {
    max-width: 280px;
}

.link-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    word-break: break-all;
}

.td-date {
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.td-actions {
    white-space: nowrap;
}

.loading-row, .empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem !important;
    font-size: 0.95rem;
}

/* ─── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 900px) {
    .course-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-row {
        flex-direction: column;
    }
    .form-row .btn {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .hero {
        padding: 3.5rem 0 2rem;
    }
    .hero-title {
        font-size: 1.85rem;
    }
    .hero-subtitle {
        font-size: 0.95rem;
    }
    .course-grid {
        grid-template-columns: 1fr;
    }
    .modal-card {
        padding: 1.5rem;
    }
    .admin-header-inner {
        flex-direction: column;
        align-items: flex-start;
    }
    .admin-add-section {
        padding: 1.5rem;
    }
    .table-header {
        padding: 1.25rem 1.25rem 0;
    }
    .admin-table thead th,
    .admin-table tbody td {
        padding: 0.7rem 0.75rem;
    }
    .fab {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 54px;
        height: 54px;
    }
}

/* ─── CARD ENTRANCE ANIMATION ──────────────────────────── */
@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.course-card {
    animation: cardFadeIn 0.4s ease both;
}

.course-card:nth-child(1)  { animation-delay: 0.03s; }
.course-card:nth-child(2)  { animation-delay: 0.06s; }
.course-card:nth-child(3)  { animation-delay: 0.09s; }
.course-card:nth-child(4)  { animation-delay: 0.12s; }
.course-card:nth-child(5)  { animation-delay: 0.15s; }
.course-card:nth-child(6)  { animation-delay: 0.18s; }
.course-card:nth-child(7)  { animation-delay: 0.21s; }
.course-card:nth-child(8)  { animation-delay: 0.24s; }
.course-card:nth-child(9)  { animation-delay: 0.27s; }
.course-card:nth-child(10) { animation-delay: 0.30s; }
.course-card:nth-child(11) { animation-delay: 0.33s; }
.course-card:nth-child(12) { animation-delay: 0.36s; }

/* ─── SCROLLBAR ────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.18);
}
