/* ========================================
   SHARED STYLES
   Common CSS for the Platform
   ======================================== */

/* Custom Font - PowerGrotesk */
@font-face {
    font-family: 'PowerGrotesk';
    src: url('/static/fonts/PowerGrotesk-Regular.woff2') format('woff2'),
         url('/static/fonts/PowerGrotesk-Regular.woff') format('woff'),
         url('/static/fonts/PowerGrotesk-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* CSS Variables - Design Tokens */
:root {
    /* Colors */
    --bg: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-elevated: #F9FAFB;
    --bg-elevated-2: #F3F4F6;
    --bg-elevated-3: #E5E7EB;
    --fg: #18181b;
    --fg-muted: #52525b;
    --fg-subtle: #71717a;
    --accent: #e42313;
    --border: #E4E4E7;
    --border-hover: #D4D4D8;
    --border-focus: #A1A1AA;
    --accent-white: #18181b;
    --accent-white-faded: rgba(0, 0, 0, 0.3);
    --accent-red: #e42313;
    --accent-green: #27C93F;
    --accent-yellow: #FFBD2E;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-teal: #14b8a6;
    --accent-orange: #f97316;
    --accent-cyan: #06b6d4;

    /* Instructor Studio Design Tokens (from instructor.css) */
    --studio-primary: #3b82f6;
    --studio-primary-hover: #2563eb;
    --studio-primary-subtle: rgba(59, 130, 246, 0.12);
    --studio-primary-text: #ffffff;
    --studio-accent: #14b8a6;
    --studio-success: #4ade80;
    --studio-success-subtle: rgba(34, 197, 94, 0.12);
    --studio-warning: #facc15;
    --studio-warning-subtle: rgba(234, 179, 8, 0.12);
    --studio-danger: #f87171;
    --studio-danger-subtle: rgba(239, 68, 68, 0.12);
    --studio-info: #60a5fa;
    --studio-info-subtle: rgba(59, 130, 246, 0.12);
    --studio-bg-primary: #09090b;
    --studio-bg-secondary: #0f0f11;
    --studio-card-bg: rgba(255, 255, 255, 0.028);
    --studio-card-bg-hover: rgba(255, 255, 255, 0.045);
    --studio-card-border-color: rgba(255, 255, 255, 0.10);
    --studio-card-border: 1px solid var(--studio-card-border-color);
    --studio-card-border-hover: rgba(255, 255, 255, 0.15);
    --studio-card-radius: 0.75rem;
    --studio-card-padding: 1rem;
    --studio-focus-ring: 0 0 0 2px var(--studio-primary-subtle);

    /* Typography */
    --font-primary: 'PowerGrotesk', 'Satoshi', system-ui, sans-serif;
    --font-heading: 'PowerGrotesk', 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Consolas', monospace;

    /* Spacing Scale (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Layout */
    --container-width: 1100px;
    --container-padding: var(--space-6);

    /* Border Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Focus Ring */
    --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255, 255, 255, 0.4);
    --focus-ring-inset: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    background-color: var(--bg);
}

body {
    font-family: var(--font-primary);
    color: var(--fg);
    background-color: var(--bg);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

p {
    font-weight: 500;
}

::selection {
    background: var(--accent-white);
    color: var(--bg);
}

a {
    text-decoration: none;
    color: inherit;
}

/* Grid Background - More organic, less perfect */
.grid-bg {
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px),
        radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(59, 130, 246, 0.02) 0%, transparent 50%);
    background-size: 58px 58px, 58px 58px, 800px 800px, 600px 600px;
    background-position: 0 0, 0 0, 0 0, 0 0;
    position: relative;
}

/* Subtle noise texture overlay */
.grid-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.015'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* Background Glow - More varied and organic */
.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 15% 25%, rgba(139, 92, 246, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 85% 75%, rgba(59, 130, 246, 0.03) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(100, 100, 100, 0.02) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
    opacity: 0.8;
}

/* ========================================
   FOCUS STATES (Accessibility)
   ======================================== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Button focus states */
button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Link focus states */
a:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-xs);
}

/* ========================================
   INSTRUCTOR STUDIO TABS
   Fix for active tab hover state
   ======================================== */

/* When a tab button has .active class, keep text white on hover */
#tab-monitor.active:hover,
#tab-classes.active:hover,
#tab-materials.active:hover,
#tab-labs.active:hover {
    color: white !important;
    background-color: #0d2e36 !important;
}

/* ========================================
   UTILITY CLASSES - Custom Utilities
   ======================================== */

/* Glass Card - More organic, less perfect */
.glass-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    position: relative;
    overflow: hidden;
}

/* Subtle texture overlay on cards */
.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255, 255, 255, 0.03) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

.glass-card:hover::before {
    opacity: 1;
}

.glass-panel {
    background: rgba(15, 15, 15, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
}

/* Loading Spinner */
.loading-spinner {
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.loading-spinner-dark {
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top: 2px solid #000;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.loading-spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 1.5px;
}

.loading-spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Logo flip animation - 3D flip effect */
.logo-flip {
    animation: logoFlip 3s ease-in-out infinite;
    transform-style: preserve-3d;
}

@keyframes logoFlip {
    0%, 100% {
        transform: rotateY(0deg);
    }
    50% {
        transform: rotateY(180deg);
    }
}

/* Alternative: gentle pulse with subtle rotation */
.logo-pulse-rotate {
    animation: logoPulseRotate 2s ease-in-out infinite;
}

@keyframes logoPulseRotate {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.05) rotate(5deg);
        opacity: 0.8;
    }
}

/* ==========================================================================
   CONSOLIDATED PATTERNS - Extracted from page-specific files
   Consolidation performed 2025-12-22 to reduce duplication across:
   - classes.css, admin.css, labs-page.css, instructor.css (merged 2025-01-XX)
   - app-shell.css, settings.css
   - lab-view.css, material-view.css
   ========================================================================== */

/* ==========================================================================
   PAGE HEADER ENHANCED - Base Styles
   Page-specific color variations remain in their respective files
   ========================================================================== */

.page-header-enhanced {
    padding: 24px 32px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.page-header-enhanced .header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.classes-page .page-header-enhanced .header-content {
    align-items: flex-start;
}

.page-header-enhanced .header-info {
    flex: 1;
}

.page-header-enhanced .header-title {
    font-size: 1.65rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0;
    letter-spacing: -0.01em;
    line-height: 1.35;
}

.page-header-enhanced .header-title .header-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.page-header-enhanced .header-title:has(.header-title-icon) {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.page-header-enhanced .header-title-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.page-header-enhanced .header-subtitle {
    font-size: 0.9rem;
    color: var(--fg-muted);
    font-weight: 400;
    line-height: 1.55;
}

.page-header-enhanced .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Responsive - Page Header Enhanced */
@media (max-width: 768px) {
    .page-header-enhanced {
        padding: 20px;
    }

    .page-header-enhanced .header-title {
        font-size: 1.5rem;
    }

    .page-header-enhanced .header-content {
        flex-direction: column;
        gap: 12px;
    }
}

/* Large screens - Page Header Enhanced */
@media (min-width: 1600px) {
    .page-header-enhanced {
        padding: 32px 48px 28px;
    }

    .page-header-enhanced .header-title {
        font-size: 2rem;
    }

    .page-header-enhanced .header-title-icon {
        width: 42px;
        height: 42px;
    }
}

@media (min-width: 1920px) {
    .page-header-enhanced {
        padding: 40px 64px 32px;
    }

    .page-header-enhanced .header-title {
        font-size: 2.25rem;
    }

    .page-header-enhanced .header-subtitle {
        font-size: 1rem;
    }
}

/* Instructor/Admin Page Header Override - Gradient background */
.instructor-page .page-header-enhanced,
.admin-page .page-header-enhanced {
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.04) 0%, transparent 100%);
    padding-bottom: 32px;
}

.instructor-page .page-header-enhanced .header-content,
.admin-page .page-header-enhanced .header-content {
    max-width: 1400px;
}

/* ==========================================================================
   MODAL SYSTEM - Shared Modal Styles
   Consolidated from app-shell.css, labs-page.css, classes.css, settings.css
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
}

.modal-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 201;
}

.modal-content {
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.modal-body {
    padding: 24px 28px;
}

.modal-footer {
    padding: 16px 28px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Modal Close Button */
.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

/* Responsive Modal */
@media (max-width: 640px) {
    .modal-container {
        padding: 16px;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* Modal Utility Classes - Warning boxes, danger buttons, text styles */
.btn-card-danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.btn-card-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* Modal Warning Box - Can use Tailwind: bg-red-500/10 border border-red-500/20 rounded-lg p-4 mb-4 */
.modal-warning-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.modal-warning-text {
    color: #f87171;
    font-size: 0.9rem;
    margin: 0;
}

.modal-text-muted {
    color: var(--fg-muted);
    margin-bottom: 8px;
}

.modal-text-subtle {
    color: var(--fg-subtle);
    font-size: 0.85rem;
    margin: 0;
}

.text-emphasis {
    color: var(--fg);
    font-weight: 500;
}

.fw-600 {
    font-weight: 600;
}

.spinner-light {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
}

.loading-container-padded {
    padding: 40px;
}

/* ==========================================================================
   CUSTOM SCROLLBAR - Dark Theme Scrollbar Styles
   Consolidated from lab-view.css and material-view.css
   ========================================================================== */

/* Dark scrollbar for all elements */
.dark-scrollbar,
.dark-scrollbar * {
    scrollbar-width: thin;
    scrollbar-color: #333 #0a0a0a;
}

.dark-scrollbar::-webkit-scrollbar,
.dark-scrollbar *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dark-scrollbar::-webkit-scrollbar-track,
.dark-scrollbar *::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.dark-scrollbar::-webkit-scrollbar-thumb,
.dark-scrollbar *::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
    border: 2px solid #0a0a0a;
}

.dark-scrollbar::-webkit-scrollbar-thumb:hover,
.dark-scrollbar *::-webkit-scrollbar-thumb:hover {
    background: #444;
}

.dark-scrollbar::-webkit-scrollbar-corner,
.dark-scrollbar *::-webkit-scrollbar-corner {
    background: #0a0a0a;
}

/* Subtle scrollbar variant (for sidebars/panels) */
.subtle-scrollbar,
.subtle-scrollbar * {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.subtle-scrollbar::-webkit-scrollbar,
.subtle-scrollbar *::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.subtle-scrollbar::-webkit-scrollbar-track,
.subtle-scrollbar *::-webkit-scrollbar-track {
    background: transparent;
}

.subtle-scrollbar::-webkit-scrollbar-thumb,
.subtle-scrollbar *::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.subtle-scrollbar::-webkit-scrollbar-thumb:hover,
.subtle-scrollbar *::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.subtle-scrollbar::-webkit-scrollbar-corner,
.subtle-scrollbar *::-webkit-scrollbar-corner {
    background: transparent;
}

/* Light scrollbar for light theme pages */
.light-scrollbar,
.light-scrollbar * {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.light-scrollbar::-webkit-scrollbar,
.light-scrollbar *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.light-scrollbar::-webkit-scrollbar-track,
.light-scrollbar *::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.light-scrollbar::-webkit-scrollbar-thumb,
.light-scrollbar *::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
    border: 2px solid #f3f4f6;
}

.light-scrollbar::-webkit-scrollbar-thumb:hover,
.light-scrollbar *::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.light-scrollbar::-webkit-scrollbar-corner,
.light-scrollbar *::-webkit-scrollbar-corner {
    background: #f3f4f6;
}

/* Hidden scrollbar (content still scrollable) */
.hidden-scrollbar {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.hidden-scrollbar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* ==========================================================================
   INSTRUCTOR STUDIO - Tab Content & Animations
   Consolidated from instructor.css (merged 2025-01-XX)
   ========================================================================== */

/* Tab Content Visibility */
.studio-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.studio-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Studio Modal Content - Prevent unwanted hover backgrounds */
.studio-sidebar-content,
.studio-sidebar-content:hover,
.studio-tab-content,
.studio-tab-content:hover,
.studio-modal-layout,
.studio-modal-layout:hover {
    background-color: #ffffff !important;
}

/* ==========================================================================
   EMPTY STATE STYLES - Consolidated
   ========================================================================== */

.empty-state-container {
    text-align: center;
    padding: 64px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 32px;
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 8px;
    font-family: var(--font-heading);
}

.empty-desc {
    font-size: 1rem;
    color: var(--fg-muted);
    max-width: 480px;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Card Button Utility - Used in empty states and cards */
.btn-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-card-primary {
    background: var(--studio-primary);
    color: #fff;
}

.btn-card-primary:hover {
    background: var(--studio-primary-hover);
}
