/* ============================================
   MEDIVA — Global Design System
   FILE: mediva/public/assets/css/main.css
   Colors: Wine #C0392B | Gold #D4AF37 | White
   ============================================ */

/* ============================================
   1. GOOGLE FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600;700&family=Montserrat:wght@400;500;600;700;800&display=swap');

/* ============================================
   2. CSS VARIABLES
   ============================================ */
:root {
    /* Brand Colors */
    --wine:          #C0392B;
    --wine-dark:     #922B21;
    --wine-deeper:   #7B241C;
    --wine-light:    #E74C3C;
    --wine-pale:     #FADBD8;
    --wine-ultra:    #FEF9F9;

    /* Gold */
    --gold:          #D4AF37;
    --gold-dark:     #B8960C;
    --gold-light:    #F4D03F;
    --gold-pale:     #FEF9E7;

    /* Neutrals */
    --white:         #FFFFFF;
    --off-white:     #FAFAFA;
    --grey-50:       #F8F9FA;
    --grey-100:      #F1F3F5;
    --grey-200:      #E9ECEF;
    --grey-300:      #DEE2E6;
    --grey-400:      #CED4DA;
    --grey-500:      #ADB5BD;
    --grey-600:      #6C757D;
    --grey-700:      #495057;
    --grey-800:      #343A40;
    --grey-900:      #212529;
    --black:         #0A0A0A;

    /* Semantic */
    --success:       #27AE60;
    --success-light: #D5F5E3;
    --warning:       #F39C12;
    --warning-light: #FDEBD0;
    --danger:        #C0392B;
    --danger-light:  #FADBD8;
    --info:          #2980B9;
    --info-light:    #D6EAF8;

    /* Typography */
    --font-heading:  'Cormorant Garamond', Georgia, serif;
    --font-body:     'Inter', system-ui, sans-serif;
    --font-accent:   'Montserrat', sans-serif;

    /* Font Sizes */
    --text-xs:    0.75rem;
    --text-sm:    0.875rem;
    --text-base:  1rem;
    --text-md:    1.125rem;
    --text-lg:    1.25rem;
    --text-xl:    1.5rem;
    --text-2xl:   1.875rem;
    --text-3xl:   2.25rem;
    --text-4xl:   3rem;
    --text-5xl:   3.75rem;
    --text-6xl:   4.5rem;

    /* Spacing */
    --space-1:   0.25rem;
    --space-2:   0.5rem;
    --space-3:   0.75rem;
    --space-4:   1rem;
    --space-5:   1.25rem;
    --space-6:   1.5rem;
    --space-8:   2rem;
    --space-10:  2.5rem;
    --space-12:  3rem;
    --space-16:  4rem;
    --space-20:  5rem;
    --space-24:  6rem;

    /* Border Radius */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-2xl:  24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg:   0 10px 40px rgba(0,0,0,0.10);
    --shadow-xl:   0 20px 60px rgba(0,0,0,0.12);
    --shadow-wine: 0 8px 32px rgba(192,57,43,0.30);
    --shadow-gold: 0 8px 32px rgba(212,175,55,0.25);

    /* Transitions */
    --transition-fast:  150ms ease;
    --transition-base:  250ms ease;
    --transition-slow:  400ms ease;

    /* Layout */
    --navbar-height:   72px;
    --sidebar-width:   260px;
    --container-xl:    1280px;

    /* Z-index */
    --z-dropdown:  100;
    --z-sticky:    200;
    --z-overlay:   300;
    --z-modal:     400;
    --z-toast:     500;
}

/* ============================================
   3. RESET
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--grey-800);
    background: var(--white);
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--wine);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--wine-dark); }

ul, ol { list-style: none; }

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input, textarea, select {
    font-family: inherit;
}

/* ============================================
   4. TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    color: var(--grey-900);
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl);  }
h6 { font-size: var(--text-lg);  }

p {
    line-height: 1.7;
    color: var(--grey-700);
}

.text-label {
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

.text-wine    { color: var(--wine); }
.text-gold    { color: var(--gold); }
.text-white   { color: var(--white); }
.text-muted   { color: var(--grey-500); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

/* Gold shimmer text effect */
.text-gold-shimmer {
    background: linear-gradient(
        90deg,
        var(--gold-dark),
        var(--gold-light),
        var(--gold-dark)
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: goldShimmer 3s linear infinite;
}

/* ============================================
   5. LAYOUT
   ============================================ */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin-inline: auto;
    padding-inline: var(--space-6);
}

.section      { padding-block: var(--space-24); }
.section-sm   { padding-block: var(--space-16); }

/* ============================================
   6. NAVBAR
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--grey-100);
    z-index: var(--z-sticky);
    transition: all var(--transition-base);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--container-xl);
    margin-inline: auto;
    padding-inline: var(--space-6);
}

/* Logo */
.navbar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.navbar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--wine), var(--wine-dark));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-wine);
    flex-shrink: 0;
}

.navbar-logo-icon svg {
    width: 22px;
    height: 22px;
    fill: var(--white);
}

.navbar-logo-text {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--grey-900);
    letter-spacing: -0.02em;
}

.navbar-logo-text span {
    color: var(--wine);
}

/* Nav Links */
.navbar-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-link {
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--grey-600);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
    color: var(--wine);
    background: var(--wine-ultra);
}

/* Navbar Actions */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Mobile Menu Toggle */
.navbar-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.navbar-toggle:hover {
    background: var(--grey-100);
}

.navbar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--grey-800);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.navbar-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.navbar-toggle.open span:nth-child(2) {
    opacity: 0;
}

.navbar-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Nav */
.navbar-mobile {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--grey-200);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    flex-direction: column;
    gap: var(--space-2);
}

.navbar-mobile.open {
    display: flex;
}

.navbar-mobile .nav-link {
    font-size: var(--text-sm);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    text-align: left;
}

/* ============================================
   7. BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    outline: none;
}

/* Ripple effect */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.15);
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: inherit;
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }

/* Primary */
.btn-primary {
    background: var(--wine);
    color: var(--white);
    border-color: var(--wine);
    box-shadow: var(--shadow-wine);
}

.btn-primary:hover {
    background: var(--wine-dark);
    border-color: var(--wine-dark);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(192,57,43,0.40);
}

/* Gold */
.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--white);
    border-color: transparent;
    box-shadow: var(--shadow-gold);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(212,175,55,0.40);
    color: var(--white);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--wine);
    border-color: var(--wine);
}

.btn-outline:hover {
    background: var(--wine);
    color: var(--white);
    transform: translateY(-2px);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--white);
    border-color: rgba(255,255,255,0.5);
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border-color: var(--white);
}

/* White */
.btn-white {
    background: var(--white);
    color: var(--wine);
    border-color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-white:hover {
    background: var(--off-white);
    transform: translateY(-2px);
    color: var(--wine);
}

/* Sizes */
.btn-sm  { font-size: 0.65rem; padding: var(--space-2) var(--space-4); }
.btn-lg  { font-size: var(--text-sm); padding: var(--space-4) var(--space-8); }
.btn-xl  { font-size: var(--text-base); padding: var(--space-5) var(--space-10); }
.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn-sm-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   8. CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    border: 1px solid var(--grey-100);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--grey-200);
}

.card-premium {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    border: 1px solid rgba(212,175,55,0.3);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.card-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--wine),
        var(--gold),
        var(--wine)
    );
}

.card-wine {
    background: linear-gradient(135deg, var(--wine) 0%, var(--wine-deeper) 100%);
    color: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    position: relative;
    overflow: hidden;
}

.card-wine::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.card-dark {
    background: var(--grey-900);
    color: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
}

/* ============================================
   9. HERO SECTION
   ============================================ */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--white);
    padding-top: var(--navbar-height);
    position: relative;
    overflow: hidden;
}

/* Hero background decorations */
.hero::before {
    content: '';
    position: absolute;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(192,57,43,0.06) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -100px;
    left: -100px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(212,175,55,0.06) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 680px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--wine-ultra);
    border: 1px solid var(--wine-pale);
    color: var(--wine);
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-6);
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--wine);
    border-radius: 50%;
    animation: pulse 2s ease infinite;
}

.hero-title {
    font-size: var(--text-6xl);
    font-weight: 700;
    line-height: 1.05;
    color: var(--grey-900);
    margin-bottom: var(--space-6);
    letter-spacing: -0.03em;
}

.hero-title .highlight {
    color: var(--wine);
    position: relative;
}

.hero-title .highlight::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--wine), var(--gold));
    border-radius: var(--radius-full);
}

.hero-subtitle {
    font-size: var(--text-lg);
    color: var(--grey-600);
    line-height: 1.7;
    margin-bottom: var(--space-10);
    max-width: 560px;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-12);
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    flex-wrap: wrap;
}

.hero-stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.hero-stat-number {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--grey-900);
    line-height: 1;
}

.hero-stat-label {
    font-size: var(--text-xs);
    color: var(--grey-500);
    font-family: var(--font-accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.hero-stat-divider {
    width: 1px;
    height: 40px;
    background: var(--grey-200);
}

/* Hero Image Side */
.hero-visual {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.hero-card-float {
    position: absolute;
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--grey-100);
    animation: float 4s ease-in-out infinite;
}

.hero-card-float:nth-child(2) {
    animation-delay: -2s;
}

/* ============================================
   10. FEATURES SECTION
   ============================================ */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.feature-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    border: 1px solid var(--grey-100);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    background: linear-gradient(180deg, var(--wine-ultra), transparent);
    transition: height var(--transition-slow);
}

.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: var(--wine-pale);
}

.feature-card:hover::before {
    height: 100px;
}

.feature-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--wine-ultra), var(--wine-pale));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-5);
    transition: all var(--transition-base);
}

.feature-card:hover .feature-icon {
    background: linear-gradient(135deg, var(--wine), var(--wine-dark));
}

.feature-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--wine);
    transition: stroke var(--transition-base);
}

.feature-card:hover .feature-icon svg {
    stroke: var(--white);
}

.feature-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--grey-900);
    margin-bottom: var(--space-3);
}

.feature-desc {
    font-size: var(--text-sm);
    color: var(--grey-600);
    line-height: 1.7;
}

/* ============================================
   11. SECTION HEADERS
   ============================================ */
.section-header {
    text-align: center;
    max-width: 640px;
    margin-inline: auto;
    margin-bottom: var(--space-16);
}

.section-label {
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wine);
    margin-bottom: var(--space-3);
    display: block;
}

.section-title {
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--grey-900);
    margin-bottom: var(--space-4);
    line-height: 1.15;
}

.section-desc {
    font-size: var(--text-md);
    color: var(--grey-600);
    line-height: 1.7;
}

.gold-line {
    width: 48px;
    height: 3px;
    background: linear-gradient(90deg, var(--wine), var(--gold));
    border-radius: var(--radius-full);
    margin: var(--space-4) auto;
}

/* ============================================
   12. STATS BANNER
   ============================================ */
.stats-banner {
    background: linear-gradient(135deg, var(--wine) 0%, var(--wine-deeper) 100%);
    padding: var(--space-16) 0;
    position: relative;
    overflow: hidden;
}

.stats-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-8);
    position: relative;
    z-index: 1;
}

.stat-item {
    text-align: center;
    color: var(--white);
}

.stat-number {
    font-family: var(--font-heading);
    font-size: var(--text-5xl);
    font-weight: 700;
    color: var(--white);
    line-height: 1;
    margin-bottom: var(--space-2);
}

.stat-number span {
    color: var(--gold);
}

.stat-label {
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.7);
}

/* ============================================
   13. FORMS
   ============================================ */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--grey-700);
    margin-bottom: var(--space-2);
}

.form-label span.required {
    color: var(--wine);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--grey-900);
    background: var(--white);
    border: 1.5px solid var(--grey-200);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--wine);
    box-shadow: 0 0 0 4px rgba(192,57,43,0.08);
    background: var(--white);
}

.form-input::placeholder {
    color: var(--grey-400);
    font-size: var(--text-sm);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(192,57,43,0.08);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--grey-500);
    margin-top: var(--space-2);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C757D' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

/* Input with icon */
.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-400);
    pointer-events: none;
    width: 18px;
    height: 18px;
}

.input-wrapper .form-input {
    padding-left: calc(var(--space-4) + 26px);
}

.input-icon-right {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-400);
    cursor: pointer;
    width: 18px;
    height: 18px;
    transition: color var(--transition-fast);
}

.input-icon-right:hover {
    color: var(--grey-600);
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--wine);
    cursor: pointer;
    flex-shrink: 0;
}

.form-check-label {
    font-size: var(--text-sm);
    color: var(--grey-700);
    cursor: pointer;
}

/* ============================================
   14. BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-accent);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px var(--space-3);
    border-radius: var(--radius-full);
}

.badge-wine    { background: var(--wine-pale);    color: var(--wine-dark);  }
.badge-gold    { background: var(--gold-pale);    color: var(--gold-dark);  }
.badge-success { background: var(--success-light); color: var(--success);   }
.badge-info    { background: var(--info-light);   color: var(--info);       }
.badge-warning { background: var(--warning-light); color: var(--warning);   }
.badge-danger  { background: var(--danger-light); color: var(--danger);     }
.badge-grey    { background: var(--grey-100);     color: var(--grey-600);   }

/* ============================================
   15. ALERTS
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    border: 1px solid transparent;
    margin-bottom: var(--space-4);
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: var(--success-light);
    color: #1a7a43;
    border-color: #a3d9b8;
}

.alert-danger,
.alert-error {
    background: var(--danger-light);
    color: var(--wine-darker, var(--wine-dark));
    border-color: var(--wine-pale);
}

.alert-warning {
    background: var(--warning-light);
    color: #a06300;
    border-color: #fad7a0;
}

.alert-info {
    background: var(--info-light);
    color: #1a6090;
    border-color: #aed6f1;
}

/* ============================================
   16. TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border-left: 4px solid var(--wine);
    min-width: 300px;
    max-width: 420px;
    pointer-events: all;
    animation: slideInRight 0.3s ease;
}

.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-error   { border-left-color: var(--danger);  }
.toast-info    { border-left-color: var(--info);     }

.toast-message {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--grey-800);
    line-height: 1.4;
}

.toast-close {
    color: var(--grey-400);
    cursor: pointer;
    font-size: var(--text-lg);
    line-height: 1;
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.toast-close:hover { color: var(--grey-600); }

/* ============================================
   17. MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--grey-900);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--grey-500);
    transition: all var(--transition-fast);
    background: var(--grey-100);
    border: none;
}

.modal-close:hover {
    background: var(--grey-200);
    color: var(--grey-700);
}

/* ============================================
   18. FOOTER
   ============================================ */
.footer {
    background: var(--grey-900);
    color: var(--grey-400);
    padding: var(--space-20) 0 var(--space-8);
    position: relative;
    overflow: hidden;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--wine), var(--gold), var(--wine));
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: var(--space-12);
    margin-bottom: var(--space-16);
}

.footer-brand {}

.footer-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.footer-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--wine), var(--wine-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-logo-text {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--white);
}

.footer-desc {
    font-size: var(--text-sm);
    color: var(--grey-500);
    line-height: 1.7;
    max-width: 300px;
    margin-bottom: var(--space-6);
}

.footer-social {
    display: flex;
    gap: var(--space-3);
}

.footer-social-link {
    width: 38px;
    height: 38px;
    background: var(--grey-800);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--grey-400);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.footer-social-link:hover {
    background: var(--wine);
    color: var(--white);
    transform: translateY(-2px);
}

.footer-social-link svg {
    width: 16px;
    height: 16px;
}

.footer-col-title {
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--white);
    margin-bottom: var(--space-5);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.footer-link {
    font-size: var(--text-sm);
    color: var(--grey-500);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--wine-light);
}

.footer-bottom {
    border-top: 1px solid var(--grey-800);
    padding-top: var(--space-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.footer-copyright {
    font-size: var(--text-xs);
    color: var(--grey-600);
}

.footer-copyright a {
    color: var(--wine-light);
    text-decoration: none;
}

.footer-bottom-links {
    display: flex;
    gap: var(--space-6);
}

.footer-bottom-link {
    font-size: var(--text-xs);
    color: var(--grey-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-bottom-link:hover {
    color: var(--grey-400);
}

/* ============================================
   19. PAGINATION
   ============================================ */
.pagination-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    margin-top: var(--space-8);
}

.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.page-item {}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding-inline: var(--space-3);
    border-radius: var(--radius-lg);
    font-family: var(--font-accent);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--grey-600);
    background: var(--white);
    border: 1.5px solid var(--grey-200);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.page-link:hover {
    border-color: var(--wine);
    color: var(--wine);
    background: var(--wine-ultra);
}

.page-item.active .page-link {
    background: var(--wine);
    border-color: var(--wine);
    color: var(--white);
}

.page-item.disabled .page-link {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-info {
    font-size: var(--text-sm);
    color: var(--grey-500);
}

/* ============================================
   20. ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-12px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.7; transform: scale(1.1); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

@keyframes goldShimmer {
    0%   { background-position: -200% center; }
    100% { background-position:  200% center; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.animate-fade-in       { animation: fadeIn 0.6s ease forwards; }
.animate-fade-in-left  { animation: fadeInLeft 0.6s ease forwards; }
.animate-fade-in-right { animation: fadeInRight 0.6s ease forwards; }
.animate-float         { animation: float 4s ease-in-out infinite; }
.animate-scale-in      { animation: scaleIn 0.4s ease forwards; }

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }

/* Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--grey-100) 25%,
        var(--grey-200) 50%,
        var(--grey-100) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--wine-pale);
    border-top-color: var(--wine);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ============================================
   21. SCROLLBAR
   ============================================ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--grey-100); }
::-webkit-scrollbar-thumb {
    background: var(--wine);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--wine-dark); }

/* ============================================
   22. SELECTION
   ============================================ */
::selection {
    background: var(--wine-pale);
    color: var(--wine-dark);
}

/* ============================================
   23. UTILITY CLASSES
   ============================================ */
.hidden     { display: none !important; }
.block      { display: block; }
.flex       { display: flex; }
.grid       { display: grid; }
.relative   { position: relative; }
.absolute   { position: absolute; }

.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-center    { justify-content: center; }
.justify-between   { justify-content: space-between; }
.justify-end       { justify-content: flex-end; }

.flex-col  { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1    { flex: 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); }

.w-full    { width: 100%; }
.h-full    { height: 100%; }
.min-h-screen { min-height: 100vh; }

.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }
.mt-auto { margin-top: auto; }
.mx-auto { margin-inline: auto; }

.p-4   { padding: var(--space-4); }
.p-6   { padding: var(--space-6); }
.p-8   { padding: var(--space-8); }
.py-4  { padding-block: var(--space-4); }
.px-4  { padding-inline: var(--space-4); }
.px-6  { padding-inline: var(--space-6); }

.rounded-full { border-radius: var(--radius-full); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }

.overflow-hidden { overflow: hidden; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bg-wine      { background: var(--wine); }
.bg-gold      { background: var(--gold); }
.bg-white     { background: var(--white); }
.bg-grey      { background: var(--grey-50); }
.bg-dark      { background: var(--grey-900); }
.bg-wine-pale { background: var(--wine-pale); }

.border       { border: 1px solid var(--grey-200); }
.border-wine  { border: 1px solid var(--wine); }
.border-gold  { border: 1px solid var(--gold); }

.shadow-sm   { box-shadow: var(--shadow-sm); }
.shadow-md   { box-shadow: var(--shadow-md); }
.shadow-lg   { box-shadow: var(--shadow-lg); }
.shadow-wine { box-shadow: var(--shadow-wine); }

.opacity-50  { opacity: 0.5; }
.opacity-70  { opacity: 0.7; }

.cursor-pointer { cursor: pointer; }
.select-none    { user-select: none; }

.font-heading { font-family: var(--font-heading); }
.font-accent  { font-family: var(--font-accent); }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-lg      { font-size: var(--text-lg); }
.text-xl      { font-size: var(--text-xl); }
.text-2xl     { font-size: var(--text-2xl); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

.divider {
    height: 1px;
    background: var(--grey-200);
    border: none;
    margin-block: var(--space-6);
}

.divider-wine {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--wine), transparent);
    border: none;
}

/* ============================================
   24. RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    h1 { font-size: var(--text-4xl); }
    h2 { font-size: var(--text-3xl); }

    .container { padding-inline: var(--space-5); }

    .features-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid    { grid-template-columns: repeat(2, 1fr); }
    .footer-grid   { grid-template-columns: 1fr 1fr; gap: var(--space-8); }

    .navbar-nav    { display: none; }
    .navbar-toggle { display: flex; }

    .hero-title    { font-size: var(--text-4xl); }
}

/* Mobile */
@media (max-width: 768px) {
    :root { --navbar-height: 64px; }

    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl);  }

    .container  { padding-inline: var(--space-4); }
    .section    { padding-block: var(--space-16); }
    .section-sm { padding-block: var(--space-10); }

    .features-grid { grid-template-columns: 1fr; }
    .stats-grid    { grid-template-columns: repeat(2, 1fr); }
    .footer-grid   { grid-template-columns: 1fr; }

    .hero {
        flex-direction: column;
        text-align: center;
        padding-block: calc(var(--navbar-height) + var(--space-12)) var(--space-12);
    }

    .hero-title    { font-size: var(--text-3xl); }
    .hero-subtitle { font-size: var(--text-base); }
    .hero-actions  { justify-content: center; }
    .hero-stats    { justify-content: center; }
    .hero-visual   { display: none; }

    .section-title { font-size: var(--text-2xl); }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }

    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-4);
    }

    .toast { min-width: unset; width: 100%; }

    .modal { padding: var(--space-6); }
}

/* Small Mobile */
@media (max-width: 480px) {
    h1 { font-size: var(--text-2xl); }
    .container { padding-inline: var(--space-3); }
    .btn-xl    { font-size: var(--text-sm); padding: var(--space-4) var(--space-6); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-actions { flex-direction: column; width: 100%; }
    .hero-actions .btn { width: 100%; justify-content: center; }
}


/* ============================================
   MEDIVA — MOBILE OPTIMIZATION
   Add this at the BOTTOM of main.css
   ============================================ */

/* ============================================
   GLOBAL MOBILE FIXES
   ============================================ */

/* Prevent anything from overflowing */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

*, *::before, *::after {
    box-sizing: border-box;
    max-width: 100%;
}

img, video, iframe, table, canvas {
    max-width: 100%;
    height: auto;
}

/* Fix pre/code overflow */
pre, code, .inline-code {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Fix long words/URLs breaking layout */
p, h1, h2, h3, h4, h5, h6,
a, span, li, td, th, label,
.form-input, .form-textarea,
.form-select, button {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* ============================================
   TABLET (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {

    .container {
        padding-inline: 16px;
        max-width: 100%;
    }

    /* Fix any hardcoded grid to stack */
    [style*="grid-template-columns: 2fr"],
    [style*="grid-template-columns: 1.5fr"],
    [style*="grid-template-columns:2fr"],
    [style*="grid-template-columns:1.5fr"],
    [style*="grid-template-columns: 1fr 300px"],
    [style*="grid-template-columns:1fr 300px"],
    [style*="grid-template-columns: 1fr 280px"],
    [style*="grid-template-columns:1fr 280px"],
    [style*="grid-template-columns: 1fr 320px"],
    [style*="grid-template-columns:1fr 320px"],
    [style*="grid-template-columns: 280px 1fr"],
    [style*="grid-template-columns:280px 1fr"],
    [style*="grid-template-columns: 240px 1fr"],
    [style*="grid-template-columns:240px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Fix sidebar on dashboard */
    .dashboard-layout {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .dashboard-main {
        margin-left: 0 !important;
    }

    .sidebar-toggle-btn {
        display: flex !important;
    }

    /* Admin layout */
    .admin-layout {
        grid-template-columns: 1fr !important;
    }

    .admin-sidebar {
        display: none;
    }

    .admin-main {
        margin-left: 0 !important;
    }

    /* Navbar */
    .navbar-nav {
        display: none !important;
    }

    .navbar-toggle {
        display: flex !important;
    }

    /* Hero section */
    .hero .container,
    .hero > .container {
        grid-template-columns: 1fr !important;
    }

    .hero-visual {
        display: none !important;
    }

    /* Tables */
    .admin-table,
    .exam-table,
    .history-table {
        font-size: 12px;
    }
}

/* ============================================
   MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    :root {
        --navbar-height: 60px;
    }

    body {
        font-size: 14px;
    }

    .container {
        padding-inline: 12px !important;
    }

    /* Typography scale down */
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }

    /* Section padding reduce */
    .section {
        padding-block: 3rem !important;
    }

    .section-sm {
        padding-block: 2rem !important;
    }

    .section-header {
        margin-bottom: 2rem !important;
    }

    .section-title {
        font-size: 1.5rem !important;
    }

    /* ========================================
       ALL GRIDS — Stack on mobile
       ======================================== */
    [style*="grid-template-columns"],
    .features-grid,
    .stats-grid,
    .admin-stats,
    .quick-actions,
    .progress-stats-row,
    .template-grid,
    .review-options,
    .history-grid,
    .chat-layout,
    .exam-layout {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Fix 2-column grids */
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns:repeat(2"],
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* Fix 3-column grids */
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns:repeat(3"],
    .grid-3 {
        grid-template-columns: 1fr !important;
    }

    /* Fix 4-column grids */
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns:repeat(4"],
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Fix inline-style grids from PHP views */
    div[style*="grid-template-columns: repeat(4"],
    div[style*="grid-template-columns:repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    div[style*="grid-template-columns: repeat(3"],
    div[style*="grid-template-columns:repeat(3"] {
        grid-template-columns: 1fr !important;
    }

    /* ========================================
       NAVBAR
       ======================================== */
    .navbar {
        height: 60px;
    }

    .navbar-inner {
        padding-inline: 12px;
    }

    .navbar-actions .btn {
        font-size: 0.6rem;
        padding: 6px 12px;
    }

    /* ========================================
       BUTTONS
       ======================================== */
    .btn {
        font-size: 0.65rem;
        padding: 8px 16px;
    }

    .btn-xl,
    .btn-lg {
        font-size: 0.75rem !important;
        padding: 10px 20px !important;
    }

    /* Stack side-by-side buttons */
    .hero-actions,
    [style*="display:flex"][style*="gap"] {
        flex-wrap: wrap !important;
    }

    .hero-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* ========================================
       HERO
       ======================================== */
    .hero {
        min-height: auto !important;
        padding: 60px 0 40px !important;
    }

    .hero-title {
        font-size: 2rem !important;
        line-height: 1.15 !important;
    }

    .hero-subtitle {
        font-size: 0.9rem !important;
    }

    .hero-stats {
        flex-direction: row;
        gap: 16px !important;
    }

    .hero-stat-number {
        font-size: 1.25rem !important;
    }

    .hero-stat-divider {
        display: none;
    }

    /* ========================================
       CARDS
       ======================================== */
    .card,
    .card-premium,
    .card-wine {
        padding: 16px !important;
    }

    .feature-card {
        padding: 20px !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    /* ========================================
       FORMS
       ======================================== */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 10px 14px;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .admin-form-grid {
        grid-template-columns: 1fr !important;
    }

    /* ========================================
       AUTH PAGE
       ======================================== */
    .auth-page {
        grid-template-columns: 1fr !important;
    }

    .auth-left {
        display: none !important;
    }

    .auth-right {
        padding: 24px 16px !important;
        min-height: 100vh;
    }

    .auth-form-title {
        font-size: 1.5rem !important;
    }

    /* ========================================
       DASHBOARD
       ======================================== */
    .dashboard-content {
        padding: 12px !important;
    }

    .dashboard-topbar {
        padding: 10px 12px !important;
    }

    .topbar-search {
        display: none !important;
    }

    .greeting-card {
        padding: 20px !important;
        flex-direction: column !important;
    }

    .greeting-name {
        font-size: 1.5rem !important;
    }

    .greeting-right {
        display: none !important;
    }

    .page-title {
        font-size: 1.5rem !important;
    }

    .page-header-inner {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    /* Stats row — 2 columns on mobile */
    .stats-grid,
    .progress-stats-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .stat-card-value,
    .progress-stat-value {
        font-size: 1.5rem !important;
    }

    /* Quick actions — 2 columns */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ========================================
       EXAM / CBT
       ======================================== */
    .exam-layout {
        grid-template-columns: 1fr !important;
    }

    .exam-sidebar {
        position: static !important;
        order: -1;
        margin-bottom: 16px;
    }

    .exam-topbar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .question-card {
        padding: 16px !important;
    }

    .question-text {
        font-size: 1rem !important;
    }

    .option-item {
        padding: 12px !important;
    }

    .option-letter {
        width: 30px;
        height: 30px;
        font-size: 0.7rem;
    }

    .question-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    .q-grid-btn {
        width: 32px;
        height: 32px;
        font-size: 0.6rem;
    }

    .result-hero {
        padding: 32px 16px !important;
    }

    .result-score-circle {
        width: 120px;
        height: 120px;
    }

    .result-score-number {
        font-size: 2.5rem !important;
    }

    .result-stats-row {
        gap: 16px !important;
    }

    .review-options {
        grid-template-columns: 1fr !important;
    }

    /* ========================================
       AI CHAT
       ======================================== */
    .chat-layout {
        grid-template-columns: 1fr !important;
    }

    .chat-sidebar {
        display: none !important;
    }

    .chat-main {
        height: calc(100vh - 120px) !important;
        min-height: 400px !important;
    }

    .chat-messages {
        padding: 12px !important;
    }

    .message-bubble {
        max-width: 90% !important;
    }

    .chat-suggestions {
        flex-direction: column !important;
    }

    .suggestion-pill {
        width: 100% !important;
    }

    .chat-input-area {
        padding: 10px 12px !important;
    }

    .chat-welcome-title {
        font-size: 1.25rem !important;
    }

    /* ========================================
       COMMUNITY
       ======================================== */
    .history-grid {
        grid-template-columns: 1fr !important;
    }

    /* ========================================
       TABLES — Horizontal scroll
       ======================================== */
    .admin-table,
    .exam-table,
    .history-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* ========================================
       FOOTER
       ======================================== */
    .footer {
        padding: 40px 0 24px !important;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }

    .footer-bottom {
        flex-direction: column !important;
        text-align: center;
    }

    .footer-bottom-links {
        justify-content: center;
    }

    .footer-social {
        justify-content: flex-start;
    }

    /* ========================================
       STATS BANNER
       ======================================== */
    .stats-banner {
        padding: 40px 0 !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }

    .stat-number {
        font-size: 2rem !important;
    }

    /* ========================================
       MODALS
       ======================================== */
    .modal {
        margin: 12px;
        padding: 20px !important;
        max-height: 85vh;
    }

    /* ========================================
       TOAST NOTIFICATIONS
       ======================================== */
    .toast-container {
        left: 8px !important;
        right: 8px !important;
        bottom: 8px !important;
    }

    .toast {
        min-width: unset !important;
        width: 100% !important;
    }

    /* ========================================
       STICKY ELEMENTS
       ======================================== */
    [style*="position:sticky"],
    [style*="position: sticky"] {
        position: static !important;
    }

    /* ========================================
       ADMIN PANEL
       ======================================== */
    .admin-content {
        padding: 12px !important;
    }

    .admin-topbar {
        padding: 10px 12px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }

    .admin-topbar-title {
        font-size: 1rem !important;
    }

    .health-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .admin-stat-value {
        font-size: 1.5rem !important;
    }

    .admin-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }

    /* ========================================
       PROFILE
       ======================================== */
    .profile-cover {
        height: 120px !important;
    }

    .profile-avatar {
        width: 70px !important;
        height: 70px !important;
    }

    .profile-name {
        font-size: 1.25rem !important;
    }

    .profile-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ========================================
       LAB GUIDE
       ======================================== */
    .topic-pills {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
    }

    .topic-pill {
        flex-shrink: 0;
    }

    /* ========================================
       CLINICAL CASES
       ======================================== */
    div[style*="grid-template-columns: 1fr 320px"],
    div[style*="grid-template-columns:1fr 320px"],
    div[style*="grid-template-columns: 1fr 300px"],
    div[style*="grid-template-columns:1fr 300px"] {
        grid-template-columns: 1fr !important;
    }

    /* ========================================
       PAGINATION
       ======================================== */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-link {
        min-width: 36px;
        height: 36px;
        font-size: 0.65rem;
    }

    /* ========================================
       UTILITY OVERRIDES
       ======================================== */
    /* Fix inline padding/margin */
    [style*="padding:var(--space-8)"],
    [style*="padding: var(--space-8)"] {
        padding: 16px !important;
    }

    [style*="padding:var(--space-10)"],
    [style*="padding: var(--space-10)"] {
        padding: 20px !important;
    }

    [style*="padding:var(--space-12)"],
    [style*="padding: var(--space-12)"] {
        padding: 24px !important;
    }

    [style*="padding:var(--space-16)"],
    [style*="padding: var(--space-16)"] {
        padding: 32px !important;
    }

    /* Fix inline gap */
    [style*="gap:var(--space-6)"],
    [style*="gap: var(--space-6)"] {
        gap: 12px !important;
    }

    [style*="gap:var(--space-8)"],
    [style*="gap: var(--space-8)"] {
        gap: 16px !important;
    }
}

/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {

    body {
        font-size: 13px;
    }

    .container {
        padding-inline: 8px !important;
    }

    h1 { font-size: 1.4rem !important; }
    h2 { font-size: 1.2rem !important; }

    /* All 4-column grids → 1 column */
    div[style*="grid-template-columns: repeat(4"],
    div[style*="grid-template-columns:repeat(4"] {
        grid-template-columns: 1fr !important;
    }

    .stats-grid,
    .progress-stats-row {
        grid-template-columns: 1fr !important;
    }

    .quick-actions {
        grid-template-columns: 1fr !important;
    }

    /* Buttons full width */
    .btn-xl,
    .btn-lg {
        width: 100%;
        justify-content: center;
    }

    /* CTA Banner */
    [style*="padding:var(--space-16) var(--space-12)"],
    [style*="padding: var(--space-16) var(--space-12)"] {
        padding: 32px 16px !important;
    }

    /* Hide optional elements */
    .hero-stats {
        display: none !important;
    }

    .footer-bottom-links {
        flex-direction: column;
        gap: 8px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .navbar,
    .sidebar,
    .footer,
    .toast-container,
    .dashboard-topbar,
    .sidebar-overlay,
    .navbar-mobile,
    button,
    .btn {
        display: none !important;
    }

    body {
        font-size: 11pt;
        color: #000;
        background: #fff;
    }

    .dashboard-main {
        margin: 0 !important;
    }

    .dashboard-content {
        padding: 0 !important;
    }
}


/* ============================================
   CHAT — MOBILE OPTIMIZATION
   ============================================ */
@media (max-width: 1024px) {

    .chat-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
        min-height: auto !important;
    }

    .chat-sidebar {
        display: none !important;
    }

    .chat-main {
        height: calc(100vh - 140px) !important;
        min-height: 450px !important;
        border-radius: 12px !important;
    }
}

@media (max-width: 768px) {

    .chat-main {
        height: calc(100vh - 120px) !important;
        min-height: 400px !important;
    }

    .chat-header {
        padding: 10px 14px !important;
    }

    .chat-ai-avatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 1rem !important;
    }

    .chat-ai-name {
        font-size: 0.85rem !important;
    }

    .chat-messages {
        padding: 12px !important;
        gap: 12px !important;
    }

    .message-bubble {
        max-width: 88% !important;
        padding: 12px 14px !important;
        font-size: 0.85rem !important;
    }

    .message-bubble p {
        font-size: 0.85rem !important;
    }

    .message-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.75rem !important;
    }

    .chat-input-area {
        padding: 10px 12px !important;
    }

    .chat-input-wrapper {
        padding: 8px 12px !important;
    }

    .chat-textarea {
        font-size: 14px !important;
    }

    .chat-send-btn {
        width: 36px !important;
        height: 36px !important;
    }

    .chat-input-footer {
        display: none !important;
    }

    .chat-welcome {
        padding: 20px !important;
    }

    .chat-welcome-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }

    .chat-welcome-title {
        font-size: 1.1rem !important;
    }

    .chat-welcome-desc {
        font-size: 0.8rem !important;
    }

    .chat-suggestions {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .suggestion-pill {
        width: 100% !important;
        font-size: 0.75rem !important;
        padding: 10px 14px !important;
        text-align: left !important;
    }

    .topic-pills {
        padding: 8px 12px !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        gap: 6px !important;
    }

    .topic-pill {
        flex-shrink: 0 !important;
        font-size: 0.6rem !important;
        padding: 4px 10px !important;
    }

    /* AI stats at bottom */
    div[style*="grid-template-columns: repeat(3"] {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .typing-bubble {
        padding: 10px 14px !important;
    }

    /* Rate limit indicator */
    .rate-indicator {
        display: none !important;
    }

    /* Cached badge */
    .cached-badge {
        font-size: 0.5rem !important;
    }
}

@media (max-width: 480px) {

    .chat-main {
        height: calc(100vh - 100px) !important;
        border-radius: 8px !important;
    }

    .chat-header-left {
        gap: 8px !important;
    }

    .chat-header .btn {
        display: none !important;
    }

    .message-bubble {
        max-width: 92% !important;
    }
}



/* ============================================
   MOBILE SPACING FIX
   ============================================ */
@media (max-width: 768px) {

    /* Reduce all large paddings */
    [style*="padding:var(--space-8)"] {
        padding: 16px !important;
    }

    [style*="padding:var(--space-10)"] {
        padding: 20px !important;
    }

    [style*="padding:var(--space-12)"] {
        padding: 24px !important;
    }

    [style*="padding: var(--space-8)"] {
        padding: 16px !important;
    }

    [style*="padding: var(--space-10)"] {
        padding: 20px !important;
    }

    /* Fix gradient banners */
    [style*="background:linear-gradient"] {
        padding: 20px 16px !important;
        border-radius: 12px !important;
    }

    /* Fix all inline grids */
    div[style*="display:grid"],
    div[style*="display: grid"] {
        gap: 10px !important;
    }

    /* Fix inline flex */
    div[style*="display:flex"][style*="gap:var(--space-6)"],
    div[style*="display:flex"][style*="gap: var(--space-6)"],
    div[style*="display:flex"][style*="gap:var(--space-8)"],
    div[style*="display:flex"][style*="gap: var(--space-8)"] {
        gap: 10px !important;
    }

    /* Better card spacing */
    div[style*="border-radius:var(--radius-2xl)"] {
        border-radius: 12px !important;
    }

    div[style*="border-radius:var(--radius-xl)"] {
        border-radius: 10px !important;
    }

    /* Fix inline margin-bottom */
    [style*="margin-bottom:var(--space-8)"],
    [style*="margin-bottom: var(--space-8)"] {
        margin-bottom: 16px !important;
    }

    [style*="margin-bottom:var(--space-6)"],
    [style*="margin-bottom: var(--space-6)"] {
        margin-bottom: 12px !important;
    }

    [style*="margin-bottom:var(--space-10)"],
    [style*="margin-bottom: var(--space-10)"] {
        margin-bottom: 20px !important;
    }

    /* Fix position:relative cards not wrapping */
    [style*="position:relative"],
    [style*="position: relative"] {
        max-width: 100% !important;
    }

    /* Badge wrapping */
    .badge {
        font-size: 0.55rem !important;
        padding: 2px 6px !important;
    }

    /* Alert fix */
    .alert {
        flex-direction: row !important;
        padding: 10px 12px !important;
        font-size: 0.8rem !important;
    }

    /* Fix sidebar stuff that might show */
    [style*="position:sticky"] {
        position: static !important;
    }
}

/* Force chat page no padding */
.dashboard-content:has(.mediva-chat-app) {
    padding: 0 !important;
    overflow: hidden !important;
    height: calc(100vh - 73px) !important;
}

@media (max-width: 768px) {
    .dashboard-content:has(.mediva-chat-app) {
        height: calc(100vh - 64px) !important;
    }
}