/* =================================================================
   BASE.CSS — Manduna Pharmacy Management System
   Imports | Variables | Reset | Base | Responsive
   ================================================================= */

/* -----------------------------------------------------------------
   1. IMPORTS
   ----------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Capriola&family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* -----------------------------------------------------------------
   2. CSS VARIABLES
   ----------------------------------------------------------------- */
:root {
    /* — Colors (light mode) — */
    --clr-bg:           #ffffff;
    --clr-surface:      #f5f5f5;
    --clr-border:       #e0e0e0;
    --clr-text:         #111111;
    --clr-text-muted:   #666666;
    --clr-accent:       #000000;
    --clr-accent-hover: #333333;
    --clr-inverse:      #ffffff;

    /* Status */
    --clr-success:      #16a34a;
    --clr-warning:      #ca8a04;
    --clr-error:        #dc2626;
    --clr-info:         #2563eb;

    /* — Typography — */
    --ff-heading:  'Capriola', sans-serif;
    --ff-body:     'Poppins', sans-serif;

    /* Font weights */
    --fw-light:    300;
    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;

    /* Fluid font sizes  (min @ 320px → max @ 1200px) */
    --fs-xs:    clamp(0.8125rem,  0.75rem   + 0.2vw,   0.875rem);   /* ~13–14px */
    --fs-sm:    clamp(0.875rem,   0.8rem    + 0.25vw,   1rem);       /* ~14–16px */
    --fs-base:  clamp(1rem,       0.9rem    + 0.35vw,   1.125rem);   /* ~16–18px */
    --fs-md:    clamp(1.125rem,   1rem      + 0.45vw,   1.25rem);    /* ~18–20px */
    --fs-lg:    clamp(1.25rem,    1.1rem    + 0.55vw,   1.5rem);     /* ~20–24px */
    --fs-xl:    clamp(1.5rem,     1.25rem   + 0.85vw,   1.875rem);   /* ~24–30px */
    --fs-2xl:   clamp(1.875rem,   1.5rem    + 1.25vw,   2.5rem);     /* ~30–40px */
    --fs-3xl:   clamp(2.5rem,     2rem      + 1.75vw,   3.25rem);    /* ~40–52px */

    /* — Spacing (fluid) — */
    --space-xs:   clamp(0.25rem,  0.2rem  + 0.2vw,   0.5rem);
    --space-sm:   clamp(0.5rem,   0.4rem  + 0.35vw,  0.75rem);
    --space-md:   clamp(0.75rem,  0.6rem  + 0.5vw,   1rem);
    --space-lg:   clamp(1rem,     0.8rem  + 0.75vw,  1.5rem);
    --space-xl:   clamp(1.5rem,   1.1rem  + 1.25vw,  2.5rem);
    --space-2xl:  clamp(2rem,     1.5rem  + 1.75vw,  4rem);

    /* — Radius — */
    --radius-sm:  0.25rem;
    --radius-md:  0.5rem;
    --radius-lg:  0.75rem;
    --radius-full: 9999px;

    /* — Shadows — */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md:  0 2px 8px rgba(0, 0, 0, 0.08);

    /* — Transitions — */
    --transition: 200ms ease;

    /* — Z-index scale — */
    --z-dropdown:  100;
    --z-sticky:    200;
    --z-overlay:   300;
    --z-modal:     400;
    --z-toast:     500;
}

/* — Dark mode — */
@media (prefers-color-scheme: dark) {
    :root {
        --clr-bg:           #111111;
        --clr-surface:      #1a1a1a;
        --clr-border:       #2a2a2a;
        --clr-text:         #f0f0f0;
        --clr-text-muted:   #999999;
        --clr-accent:       #ffffff;
        --clr-accent-hover: #cccccc;
        --clr-inverse:      #000000;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Manual dark mode override */
[data-theme="dark"] {
    --clr-bg:           #111111;
    --clr-surface:      #1a1a1a;
    --clr-border:       #2a2a2a;
    --clr-text:         #f0f0f0;
    --clr-text-muted:   #999999;
    --clr-accent:       #ffffff;
    --clr-accent-hover: #cccccc;
    --clr-inverse:      #000000;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Manual light mode override */
[data-theme="light"] {
    --clr-bg:           #ffffff;
    --clr-surface:      #f5f5f5;
    --clr-border:       #e0e0e0;
    --clr-text:         #111111;
    --clr-text-muted:   #666666;
    --clr-accent:       #000000;
    --clr-accent-hover: #333333;
    --clr-inverse:      #ffffff;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* -----------------------------------------------------------------
   3. RESET
   ----------------------------------------------------------------- */

/* Box-sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
    transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease;
}

/* Remove default margins & padding */
*{
    margin: 0;
    padding: 0;
}

/* Document */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 3.75rem;           /* offset for sticky header */
    hanging-punctuation: first last;
}

/* Body */
body {
    min-height: 100dvh;
    font-family: var(--ff-body);
    font-size: var(--fs-base);
    font-weight: var(--fw-regular);
    line-height: 1.6;
    color: var(--clr-text);
    background-color: var(--clr-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--ff-heading);
    font-weight: var(--fw-regular);      /* Capriola only has 400 */
    line-height: 1.2;
    text-wrap: balance;
    color: var(--clr-text);
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl);  }
h4 { font-size: var(--fs-lg);  }
h5 { font-size: var(--fs-md);  }
h6 { font-size: var(--fs-base);}

/* Emphasis — use heading font */
b, strong {
    font-family: var(--ff-heading);
    font-weight: var(--fw-regular);
}

em {
    font-family: var(--ff-heading);
}

/* Paragraph */
p {
    text-wrap: pretty;
}

/* Links */
a {
    color: var(--clr-accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover,
a:focus-visible {
    color: var(--clr-accent-hover);
}

/* Lists */
ul, ol {
    list-style: none;
}

/* Media */
img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Form elements */
input, button, textarea, select {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
}

/* Table */
table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
}

/* Remove animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* -----------------------------------------------------------------
   4. BASE STYLING
   ----------------------------------------------------------------- */

/* Container */
.container {
    width: 100%;
    max-width: 75rem;                    /* 1200px */
    margin-inline: auto;
    padding-inline: var(--space-md);
}

/* Messages */
.messages {
    width: min(100% - (var(--space-md) * 2), 75rem);
    margin: var(--space-md) auto 0;
    display: grid;
    gap: var(--space-sm);
}

.message {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: var(--space-sm);
    padding: var(--space-md);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    background-color: var(--clr-surface);
    box-shadow: var(--shadow-sm);
}

.message_icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.1rem;
}

.message_icon svg {
    width: 100%;
    height: 100%;
}

.message_text {
    margin: 0;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1.5;
    color: var(--clr-text);
}

.message--success {
    border-color: color-mix(in srgb, var(--clr-success) 38%, var(--clr-border));
    background-color: color-mix(in srgb, var(--clr-success) 10%, var(--clr-bg));
}

.message--success .message_icon {
    color: var(--clr-success);
}

.message--error {
    border-color: color-mix(in srgb, var(--clr-error) 38%, var(--clr-border));
    background-color: color-mix(in srgb, var(--clr-error) 10%, var(--clr-bg));
}

.message--error .message_icon {
    color: var(--clr-error);
}

.message--warning {
    border-color: color-mix(in srgb, var(--clr-warning) 42%, var(--clr-border));
    background-color: color-mix(in srgb, var(--clr-warning) 12%, var(--clr-bg));
}

.message--warning .message_icon {
    color: var(--clr-warning);
}

.message--info {
    border-color: color-mix(in srgb, var(--clr-info) 34%, var(--clr-border));
    background-color: color-mix(in srgb, var(--clr-info) 10%, var(--clr-bg));
}

.message--info .message_icon {
    color: var(--clr-info);
}

/* Visually hidden (accessible) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus outline */
:focus-visible {
    outline: 2px solid var(--clr-accent);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background-color: var(--clr-accent);
    color: var(--clr-inverse);
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--clr-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: var(--radius-full);
}

/* -----------------------------------------------------------------
   5. RESPONSIVE
   ----------------------------------------------------------------- */

/* Small phones (≤ 359px) */
@media (max-width: 22.4375em) {
    .container {
        padding-inline: var(--space-sm);
    }
}

/* Phones (360–599px) — default fluid styles apply, no overrides needed */

/* Tablets (600–899px) */
@media (min-width: 37.5em) {
    .container {
        padding-inline: var(--space-lg);
    }
}

/* Small desktops (900–1199px) */
@media (min-width: 56.25em) {
    .container {
        padding-inline: var(--space-xl);
    }
}

/* Large desktops (≥ 1200px) — clamp caps kick in, layout is comfortable */



/* -----------------------------------------------------------------
   Header
   ----------------------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background-color: var(--clr-bg);
    border-bottom: 1px solid var(--clr-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav {
    position: relative;
    display: flex;
    align-items: center;
    height: 3.75rem;                     /* 60px */
    gap: var(--space-lg);
}

/* Brand */
.nav_brand {
    font-family: var(--ff-heading);
    font-size: var(--fs-lg);
    color: var(--clr-text);
    white-space: nowrap;
    flex-shrink: 0;
}

.nav_brand:hover,
.nav_brand:focus-visible {
    color: var(--clr-text);
}

/* Links */
.nav_links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav_links a {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--clr-text-muted);
    transition: color var(--transition);
    white-space: nowrap;
}

.nav_links a:hover,
.nav_links a:focus-visible {
    color: var(--clr-text);
}

/* Theme toggle */
.theme_toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-md);
    color: var(--clr-text);
    cursor: pointer;
    transition: background-color var(--transition);
    flex-shrink: 0;
}

.theme_toggle:hover {
    background-color: var(--clr-surface);
}

/* Show sun in dark mode, moon in light mode */
.theme_icon--dark { opacity: 0; position: absolute; transition: opacity 300ms ease; }
.theme_icon--light { opacity: 1; transition: opacity 300ms ease; }

.theme_toggle {
    position: relative;
}

[data-theme="dark"] .theme_icon--dark { opacity: 1; }
[data-theme="dark"] .theme_icon--light { opacity: 0; }

@media (prefers-color-scheme: dark) {
    .theme_icon--dark { opacity: 1; }
    .theme_icon--light { opacity: 0; }
}

[data-theme="light"] .theme_icon--dark { opacity: 0; }
[data-theme="light"] .theme_icon--light { opacity: 1; }

/* CTA buttons */
.nav_actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-left: auto;
    flex-shrink: 0;
}

.nav_cta {
    display: inline-block;
    padding: 0.5em 1.25em;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--clr-inverse);
    background-color: var(--clr-accent);
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: background-color var(--transition), color var(--transition);
    flex-shrink: 0;
}

.nav_cta:hover,
.nav_cta:focus-visible {
    background-color: var(--clr-accent-hover);
    color: var(--clr-inverse);
}

/* Outline variant */
.nav_cta--outline {
    background-color: transparent;
    color: var(--clr-text);
    border: 1px solid var(--clr-border);
}

.nav_cta--outline:hover,
.nav_cta--outline:focus-visible {
    background-color: var(--clr-surface);
    color: var(--clr-text);
}

/* CTA items hidden in nav_links on desktop */
.nav_links-cta {
    display: none;
}

/* Settings icon (mobile only, next to hamburger) */
.nav_settings-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--clr-text);
    transition: color var(--transition);
}

.nav_settings-mobile:hover,
.nav_settings-mobile:focus-visible {
    color: var(--clr-accent);
}

/* -----------------------------------------------------------------
   Toggle button (mobile only)
   ----------------------------------------------------------------- */
.nav_toggle {
    display: none;
    position: relative;
    width: 2.25rem;
    height: 2.25rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.nav_toggle-line {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 2px;
    background-color: var(--clr-text);
    border-radius: var(--radius-full);
    transition: transform 300ms ease;
    transform-origin: center;
}

.nav_toggle-line:first-child {
    transform: translate(-50%, calc(-50% - 4px));
}

.nav_toggle-line:last-child {
    transform: translate(-50%, calc(-50% + 4px));
}

/* Animated X state */
.nav_toggle.is-active .nav_toggle-line:first-child {
    transform: translate(-50%, -50%) rotate(45deg);
}

.nav_toggle.is-active .nav_toggle-line:last-child {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* -----------------------------------------------------------------
   Mobile (< 600px)
   ----------------------------------------------------------------- */
@media (max-width: 37.4375em) {
    /* Dropdown slides beneath header, full-width */
    .nav_links {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        top: 3.75rem;                  /* matches nav height */
        left: 0;
        right: 0;
        width: 100%;
        background-color: var(--clr-bg);
        border-bottom: 1px solid var(--clr-border);
        padding: 0 var(--space-md);
        gap: 0;
        max-height: 0;
        overflow: hidden;
        z-index: var(--z-dropdown);
        transition: max-height 300ms ease, padding 300ms ease;
    }

    .nav_links.is-open {
        max-height: 28rem;             /* generous max for animation */
        padding: var(--space-sm) var(--space-md) var(--space-lg);
    }

    .nav_links li {
        width: 100%;
    }

    .nav_links a {
        display: block;
        padding: var(--space-sm) 0;
        font-size: var(--fs-base);
    }

    /* Hide desktop actions, show toggle */
    .nav_actions {
        display: none;
    }

    /* Show CTA items inside dropdown */
    .nav_links-cta {
        display: list-item;
        padding-top: var(--space-sm);
    }

    .nav_links-cta .nav_cta {
        display: block;
        text-align: center;
        width: 100%;
        font-size: var(--fs-base);
        color: var(--clr-inverse);
        background-color: var(--clr-accent);
    }

    .nav_links-cta .nav_cta--outline {
        color: var(--clr-text);
        background-color: transparent;
    }

    .nav_links-cta .theme_toggle {
        width: 100%;
        height: auto;
        padding: var(--space-sm) 0;
        justify-content: center;
    }

    .nav_toggle {
        display: block;
        margin-left: auto;
    }

    .nav_settings-mobile {
        display: flex;
        margin-left: auto;
    }

    /* When user icon is present, only IT gets the auto margin;
       reset the hamburger so both sit flush-right together. */
    .nav_settings-mobile ~ .nav_toggle {
        margin-left: 0;
    }

    /* Backdrop overlay — blurs page behind dropdown */
    .nav_overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: 3.75rem;                  /* below header */
        background: rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: calc(var(--z-dropdown) - 1);
    }

    .nav_overlay.is-visible {
        display: block;
    }
}

/* =================================================================
   Buttons (shared)
   ================================================================= */
.btn {
    display: inline-block;
    padding: 0.75em 1.75em;
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-md);
    white-space: nowrap;
    text-align: center;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
    cursor: pointer;
}

.btn--primary {
    color: var(--clr-inverse);
    background-color: var(--clr-accent);
}

.btn--primary:hover,
.btn--primary:focus-visible {
    background-color: var(--clr-accent-hover);
    color: var(--clr-inverse);
}

.btn--outline {
    color: var(--clr-text);
    background-color: transparent;
    border: 1px solid var(--clr-border);
}

.btn--outline:hover,
.btn--outline:focus-visible {
    background-color: var(--clr-surface);
    color: var(--clr-text);
}
