/* ================================================
   GLOBAL STYLES - Physics LMS
   ================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    color: var(--neutral-100);
    background: var(--primary-900);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: var(--fw-bold);
    line-height: 1.3;
    color: var(--white);
}

h1 {
    font-size: var(--fs-4xl);
}

h2 {
    font-size: var(--fs-3xl);
}

h3 {
    font-size: var(--fs-2xl);
}

h4 {
    font-size: var(--fs-xl);
}

h5 {
    font-size: var(--fs-lg);
}

a {
    color: var(--accent-400);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--cyan-400);
}

img {
    max-width: 100%;
    display: block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--neutral-800);
}

::-webkit-scrollbar-thumb {
    background: var(--neutral-600);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-500);
}

/* Selection */
::selection {
    background: var(--accent-500);
    color: var(--white);
}

/* ================================================
   LOADING SCREEN
   ================================================ */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--primary-900);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-container {
    text-align: center;
}

.loader-orb {
    width: 60px;
    height: 60px;
    margin: 0 auto var(--space-6);
    border-radius: 50%;
    background: var(--gradient-primary);
    animation: orbPulse 1.5s ease-in-out infinite;
    box-shadow: var(--shadow-glow);
}

.loader-title {
    font-family: var(--font-heading);
    font-size: var(--fs-3xl);
    font-weight: var(--fw-extrabold);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loader-sub {
    color: var(--neutral-400);
    font-size: var(--fs-sm);
    margin-top: var(--space-2);
}

/* ================================================
   LAYOUT
   ================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    transition: margin-left var(--transition-base);
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
}

.page-wrapper {
    padding: var(--space-8);
    max-width: 1400px;
    animation: fadeInUp 0.4s ease;
}

/* ================================================
   UTILITY CLASSES
   ================================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--neutral-400);
}

.text-success {
    color: var(--success-500);
}

.text-error {
    color: var(--error-500);
}

.text-warning {
    color: var(--warning-500);
}

.text-accent {
    color: var(--accent-400);
}

.text-cyan {
    color: var(--cyan-500);
}

.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: var(--space-1);
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.gap-8 {
    gap: var(--space-8);
}

.mt-2 {
    margin-top: var(--space-2);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mt-6 {
    margin-top: var(--space-6);
}

.mt-8 {
    margin-top: var(--space-8);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

.p-4 {
    padding: var(--space-4);
}

.p-6 {
    padding: var(--space-6);
}

.hidden {
    display: none !important;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
}

/* ================================================
   TOAST NOTIFICATIONS
   ================================================ */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-md);
    background: var(--neutral-800);
    border: 1px solid var(--glass-border);
    color: var(--white);
    font-size: var(--fs-sm);
    min-width: 300px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    animation: slideInRight 0.4s var(--transition-spring);
    backdrop-filter: blur(20px);
}

.toast.toast-success {
    border-left: 4px solid var(--success-500);
}

.toast.toast-error {
    border-left: 4px solid var(--error-500);
}

.toast.toast-warning {
    border-left: 4px solid var(--warning-500);
}

.toast.toast-info {
    border-left: 4px solid var(--info-500);
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--neutral-400);
    cursor: pointer;
    font-size: 1.1rem;
    padding: var(--space-1);
}

/* ================================================
   RESPONSIVE
   ================================================ */

/* Viewport meta - ensure proper scaling */

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--topbar-height);
    }

    .page-wrapper {
        padding: var(--space-3);
    }

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    h1 {
        font-size: var(--fs-xl);
    }

    h2 {
        font-size: var(--fs-lg);
    }

    h3 {
        font-size: var(--fs-md);
    }

    /* ---- PAGE HEADER ---- */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    .page-header h1 {
        font-size: var(--fs-xl);
    }

    .page-header-subtitle {
        font-size: var(--fs-xs);
    }

    /* ---- FILTER BAR ---- */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .filter-bar .form-group {
        width: 100% !important;
        min-width: 0 !important;
    }

    .filter-bar .btn {
        width: 100%;
    }

    /* ---- TOPBAR ---- */
    .topbar {
        padding: 0 var(--space-2);
        gap: var(--space-1);
        left: 0;
    }

    .topbar-left {
        flex-shrink: 1;
        min-width: 0;
        gap: var(--space-2);
    }

    .topbar-title {
        font-size: var(--fs-sm);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-right {
        gap: var(--space-2);
        flex-shrink: 0;
    }

    .batch-selector {
        padding: 4px 8px;
        font-size: var(--fs-xs);
    }

    .batch-selector span:first-child {
        display: none;
    }

    .batch-selector .batch-icon {
        display: none;
    }

    /* ---- CARDS ---- */
    .card {
        padding: var(--space-4);
    }

    .stat-card {
        padding: var(--space-4);
        gap: var(--space-3);
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: var(--fs-xl);
    }

    /* ---- MODALS ---- */
    .modal-overlay {
        padding: var(--space-2);
        align-items: flex-start;
        padding-top: var(--space-4);
    }

    .modal {
        max-width: 100% !important;
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }

    .modal-header {
        padding: var(--space-4);
    }

    .modal-header h3 {
        font-size: var(--fs-md);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100% - 40px);
    }

    .modal-body {
        padding: var(--space-4);
    }

    .modal-footer {
        padding: var(--space-3) var(--space-4);
        flex-wrap: wrap;
    }

    /* ---- TABLES ---- */
    .table-container {
        border-radius: var(--radius-md);
        -webkit-overflow-scrolling: touch;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
        font-size: var(--fs-xs);
    }

    /* ---- VIDEO CARDS ---- */
    .video-card-thumb {
        height: 160px;
    }

    .video-card-info {
        padding: var(--space-3);
    }

    .video-card-title {
        font-size: var(--fs-sm);
    }

    .video-card-desc {
        font-size: var(--fs-xs);
    }

    /* ---- SWING BAR (Leaderboard Podium) ---- */
    .swing-bar-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 1rem !important;
    }

    .swing-bar-item {
        width: 100% !important;
        max-width: 280px !important;
    }

    .swing-bar-bar {
        height: auto !important;
        min-height: 40px !important;
        padding: 0.5rem !important;
    }

    .swing-bar-avatar {
        width: 50px !important;
        height: 50px !important;
    }

    .swing-bar-name {
        font-size: var(--fs-sm) !important;
    }

    /* ---- TOAST ---- */
    .toast-container {
        right: var(--space-3);
        left: var(--space-3);
        top: var(--space-3);
    }

    .toast {
        min-width: unset;
        max-width: 100%;
        font-size: var(--fs-xs);
    }

    /* ---- QA THREAD ---- */
    .qa-message {
        max-width: 95% !important;
    }

    /* ---- EMPTY STATE ---- */
    .empty-state {
        padding: var(--space-8) var(--space-4);
    }

    .empty-state-icon {
        font-size: 2.5rem;
    }

    .empty-state-title {
        font-size: var(--fs-md);
    }

    /* ---- REGISTRATION / AUTH FORM ---- */
    .auth-container {
        padding: var(--space-4) !important;
    }

    .auth-card {
        padding: var(--space-4) !important;
    }

    /* ---- MISC ---- */
    .confirm-dialog .modal {
        margin: var(--space-4);
    }

    /* Table action buttons */
    .data-table .btn {
        padding: 4px 8px;
        font-size: 0.65rem;
    }
}

/* Extra small screens (phones < 480px) */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .page-wrapper {
        padding: var(--space-2);
    }

    h1 {
        font-size: var(--fs-lg);
    }

    .topbar-title {
        font-size: var(--fs-xs);
    }

    .batch-selector {
        display: none;
    }

    .stat-card {
        padding: var(--space-3);
    }

    .card {
        padding: var(--space-3);
    }

    .modal-overlay {
        padding: 0;
        padding-top: 0;
    }

    .modal {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }

    .swing-bar-item {
        max-width: 100% !important;
    }

    /* Form elements full width */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }
}