/* Big Gym Performance - Premium Dark Theme */
:root {
    --bg-dark: #0f1115;
    --bg-card: #181b21;
    --bg-input: #232730;

    --primary: #FF2D2D;
    /* Red - SaaS Identity */
    --primary-hover: #D00000;
    --secondary: #ffffff;
    /* White accents */

    --text-main: #ffffff;
    --text-muted: #a0a4b0;

    --glass-bg: rgba(255, 45, 45, 0.05);
    /* Slight red tint */
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.5);

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --font-main: 'Montserrat', sans-serif;
    --font-display: 'Montserrat', sans-serif;

    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.6;
    min-height: 100vh;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: 2.5rem;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #fff, #a0a0a0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Glassmorphism */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 2rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 1rem;
    background-color: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1rem;
    font-family: var(--font-main);
    transition: all 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 45, 45, 0.2);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    color: white;
    font-weight: 700;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: transform 0.2s, background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Grids */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Sidebar Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: #0b0c10;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.5rem;
    color: white;
    text-transform: uppercase;
}

.sidebar-brand span {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--glass-bg);
    color: white;
}

.nav-item.active {
    border-left: 3px solid var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    background-color: var(--bg-dark);
    min-height: 100vh;
}

/* Modal Overlay Styles (FIXED) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.hidden {
    display: none !important;
}

/* Responsive / Mobile */
@media (max-width: 768px) {

    /* CRITICAL: Prevent ANY horizontal overflow */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        position: relative;
    }

    /* Force ALL elements to respect viewport */
    * {
        max-width: 100vw !important;
    }

    body,
    .app-layout {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        top: auto;
        padding: 0;
        z-index: 1000;
        border-right: none;
        border-top: 1px solid var(--glass-border);
        background: rgba(15, 17, 21, 0.98);
        backdrop-filter: blur(10px);
        padding-bottom: env(safe-area-inset-bottom);
        display: flex;
        flex-direction: column;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .sidebar-header,
    .sidebar-footer {
        display: none !important;
    }

    .sidebar-nav {
        flex-direction: row !important;
        justify-content: space-around;
        padding: 0.5rem;
        gap: 0;
        width: 100%;
    }

    .nav-item {
        flex-direction: column !important;
        padding: 0.5rem !important;
        gap: 0.25rem !important;
        font-size: 0.7rem !important;
        text-align: center;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
    }

    .nav-item span {
        font-size: 1.2rem;
    }

    .main-content {
        margin-left: 0 !important;
        margin-bottom: 70px !important;
        padding: 1rem !important;
        width: 100vw !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        position: relative;
        left: 0;
        right: 0;
    }

    /* Force all children to respect parent width */
    .main-content>* {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Critical: Prevent all overflow */
    .glass-card,
    .student-card,
    .workout-card {
        max-width: calc(100vw - 2rem) !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Tables and forms */
    table,
    form,
    .table-responsive {
        max-width: 100% !important;
        overflow-x: auto !important;
    }

    /* Images and media */
    img,
    video,
    iframe {
        max-width: 100% !important;
        height: auto !important;
    }

    /* All text containers */
    p,
    div,
    section,
    article,
    header,
    footer {
        max-width: 100% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Header Stacking / Wrapping */
    .header-action {
        flex-wrap: wrap !important;
        gap: 0.8rem !important;
    }

    .header-action h2 {
        flex: 1 1 100%;
    }

    .header-action .btn-primary,
    .header-action .btn-outline {
        width: 100% !important;
    }

    /* Table Responsiveness */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    .table-responsive table {
        min-width: 500px;
        /* Reduced to avoid extreme overflow */
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .glass-card {
        padding: 1rem !important;
    }

    h1 {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    /* Hide specific sidebar items on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Modal adjustments for mobile */
    .modal-content {
        padding: 1.5rem !important;
        width: 100% !important;
        max-height: 85vh !important;
        margin: auto;
    }

    .modal-content h3 {
        font-size: 1.1rem;
    }

    /* Button adjustments */
    .btn-primary,
    .btn-outline {
        padding: 0.9rem 1.2rem !important;
        font-size: 0.9rem !important;
        width: 100% !important;
    }

    /* Form inputs */
    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
    }

    /* Ensure no horizontal scroll */
    * {
        max-width: 100%;
    }
}

/* Ultra-narrow screens (phones in portrait) */
@media (max-width: 400px) {
    .main-content {
        padding: 0.5rem !important;
    }

    .glass-card,
    .student-card,
    .workout-card {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    .modal-content {
        padding: 1rem !important;
    }

    h1 {
        font-size: 1.3rem !important;
    }

    h2 {
        font-size: 1.1rem !important;
    }

    h3 {
        font-size: 1rem !important;
    }

    .btn-primary,
    .btn-outline {
        padding: 0.75rem !important;
        font-size: 0.85rem !important;
    }

    .form-group {
        margin-bottom: 1rem !important;
    }

    label {
        font-size: 0.8rem !important;
        margin-bottom: 0.3rem !important;
    }

    input,
    select,
    textarea {
        padding: 0.75rem !important;
    }

    .student-name {
        font-size: 1rem !important;
    }

    .student-email {
        font-size: 0.75rem !important;
    }

    .info-label {
        font-size: 0.65rem !important;
    }

    .info-value {
        font-size: 0.85rem !important;
    }

    .nav-item {
        font-size: 0.6rem !important;
        padding: 0.4rem 0.2rem !important;
    }

    .nav-item span {
        font-size: 1rem !important;
    }
}