/**
 * PharmAssist Mobile-First Responsive Framework
 * Location: styles/responsive.css
 *
 * Mobile-first CSS framework providing:
 * - Standardized breakpoint custom properties
 * - Flexible grid system
 * - Responsive utility classes
 * - Touch-friendly defaults
 * - Mobile navigation patterns
 *
 * Load after styles/common.css and styles/themes.css so that
 * the CSS custom properties defined there are available.
 *
 * Usage:
 * <link rel="stylesheet" href="styles/responsive.css">
 */

/* ============================================
   BREAKPOINT CUSTOM PROPERTIES
   ============================================ */
:root {
    /* Mobile-first breakpoints (min-width) */
    --breakpoint-sm:  576px;   /* Small devices  – landscape phones  */
    --breakpoint-md:  768px;   /* Medium devices – tablets           */
    --breakpoint-lg:  992px;   /* Large devices  – desktops          */
    --breakpoint-xl:  1200px;  /* Extra-large    – wide desktops     */
    --breakpoint-xxl: 1400px;  /* XX-large       – very wide screens */
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 576px) {
    .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (min-width: 992px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

/* Full-width container variant */
.container-fluid {
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   MOBILE-FIRST GRID SYSTEM
   ============================================ */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -8px;
    margin-right: -8px;
}

.row > * {
    padding-left: 8px;
    padding-right: 8px;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}

/* Auto-width columns */
.col {
    flex: 1 0 0%;
}

.col-auto {
    width: auto;
    flex: 0 0 auto;
}

/* Fixed-width column sizes (mobile-first: always apply) */
.col-1  { flex: 0 0 auto; width: 8.3333%; }
.col-2  { flex: 0 0 auto; width: 16.6667%; }
.col-3  { flex: 0 0 auto; width: 25%; }
.col-4  { flex: 0 0 auto; width: 33.3333%; }
.col-5  { flex: 0 0 auto; width: 41.6667%; }
.col-6  { flex: 0 0 auto; width: 50%; }
.col-7  { flex: 0 0 auto; width: 58.3333%; }
.col-8  { flex: 0 0 auto; width: 66.6667%; }
.col-9  { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.3333%; }
.col-11 { flex: 0 0 auto; width: 91.6667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

/* SM breakpoint columns (≥ 576px) */
@media (min-width: 576px) {
    .col-sm      { flex: 1 0 0%; }
    .col-sm-auto { width: auto; flex: 0 0 auto; }
    .col-sm-1    { flex: 0 0 auto; width: 8.3333%; }
    .col-sm-2    { flex: 0 0 auto; width: 16.6667%; }
    .col-sm-3    { flex: 0 0 auto; width: 25%; }
    .col-sm-4    { flex: 0 0 auto; width: 33.3333%; }
    .col-sm-5    { flex: 0 0 auto; width: 41.6667%; }
    .col-sm-6    { flex: 0 0 auto; width: 50%; }
    .col-sm-7    { flex: 0 0 auto; width: 58.3333%; }
    .col-sm-8    { flex: 0 0 auto; width: 66.6667%; }
    .col-sm-9    { flex: 0 0 auto; width: 75%; }
    .col-sm-10   { flex: 0 0 auto; width: 83.3333%; }
    .col-sm-11   { flex: 0 0 auto; width: 91.6667%; }
    .col-sm-12   { flex: 0 0 auto; width: 100%; }
}

/* MD breakpoint columns (≥ 768px) */
@media (min-width: 768px) {
    .col-md      { flex: 1 0 0%; }
    .col-md-auto { width: auto; flex: 0 0 auto; }
    .col-md-1    { flex: 0 0 auto; width: 8.3333%; }
    .col-md-2    { flex: 0 0 auto; width: 16.6667%; }
    .col-md-3    { flex: 0 0 auto; width: 25%; }
    .col-md-4    { flex: 0 0 auto; width: 33.3333%; }
    .col-md-5    { flex: 0 0 auto; width: 41.6667%; }
    .col-md-6    { flex: 0 0 auto; width: 50%; }
    .col-md-7    { flex: 0 0 auto; width: 58.3333%; }
    .col-md-8    { flex: 0 0 auto; width: 66.6667%; }
    .col-md-9    { flex: 0 0 auto; width: 75%; }
    .col-md-10   { flex: 0 0 auto; width: 83.3333%; }
    .col-md-11   { flex: 0 0 auto; width: 91.6667%; }
    .col-md-12   { flex: 0 0 auto; width: 100%; }
}

/* LG breakpoint columns (≥ 992px) */
@media (min-width: 992px) {
    .col-lg      { flex: 1 0 0%; }
    .col-lg-auto { width: auto; flex: 0 0 auto; }
    .col-lg-1    { flex: 0 0 auto; width: 8.3333%; }
    .col-lg-2    { flex: 0 0 auto; width: 16.6667%; }
    .col-lg-3    { flex: 0 0 auto; width: 25%; }
    .col-lg-4    { flex: 0 0 auto; width: 33.3333%; }
    .col-lg-5    { flex: 0 0 auto; width: 41.6667%; }
    .col-lg-6    { flex: 0 0 auto; width: 50%; }
    .col-lg-7    { flex: 0 0 auto; width: 58.3333%; }
    .col-lg-8    { flex: 0 0 auto; width: 66.6667%; }
    .col-lg-9    { flex: 0 0 auto; width: 75%; }
    .col-lg-10   { flex: 0 0 auto; width: 83.3333%; }
    .col-lg-11   { flex: 0 0 auto; width: 91.6667%; }
    .col-lg-12   { flex: 0 0 auto; width: 100%; }
}

/* XL breakpoint columns (≥ 1200px) */
@media (min-width: 1200px) {
    .col-xl      { flex: 1 0 0%; }
    .col-xl-auto { width: auto; flex: 0 0 auto; }
    .col-xl-1    { flex: 0 0 auto; width: 8.3333%; }
    .col-xl-2    { flex: 0 0 auto; width: 16.6667%; }
    .col-xl-3    { flex: 0 0 auto; width: 25%; }
    .col-xl-4    { flex: 0 0 auto; width: 33.3333%; }
    .col-xl-5    { flex: 0 0 auto; width: 41.6667%; }
    .col-xl-6    { flex: 0 0 auto; width: 50%; }
    .col-xl-7    { flex: 0 0 auto; width: 58.3333%; }
    .col-xl-8    { flex: 0 0 auto; width: 66.6667%; }
    .col-xl-9    { flex: 0 0 auto; width: 75%; }
    .col-xl-10   { flex: 0 0 auto; width: 83.3333%; }
    .col-xl-11   { flex: 0 0 auto; width: 91.6667%; }
    .col-xl-12   { flex: 0 0 auto; width: 100%; }
}

/* ============================================
   TOUCH-FRIENDLY DEFAULTS
   ============================================ */

/* Minimum touch target size utility class */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Enforce tap targets on mobile for common interactive elements */
@media (max-width: 767px) {
    .btn,
    button:not([class*="icon-only"]),
    .nav-item a,
    .nav-link,
    .card-clickable {
        min-height: 44px;
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

/* ============================================
   RESPONSIVE TABLES
   ============================================ */

/* Wrap tables so they scroll horizontally on small screens */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

@media (max-width: 767px) {
    .table-responsive-sm {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
}

@media (max-width: 575px) {
    .table-responsive-xs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
}

/* ============================================
   DISPLAY UTILITIES
   ============================================ */

/* Base display helpers */
.d-none    { display: none !important; }
.d-block   { display: block !important; }
.d-inline  { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex    { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid    { display: grid !important; }

/* SM breakpoint display (≥ 576px) */
@media (min-width: 576px) {
    .d-sm-none         { display: none !important; }
    .d-sm-block        { display: block !important; }
    .d-sm-inline       { display: inline !important; }
    .d-sm-inline-block { display: inline-block !important; }
    .d-sm-flex         { display: flex !important; }
    .d-sm-inline-flex  { display: inline-flex !important; }
    .d-sm-grid         { display: grid !important; }
}

/* MD breakpoint display (≥ 768px) */
@media (min-width: 768px) {
    .d-md-none         { display: none !important; }
    .d-md-block        { display: block !important; }
    .d-md-inline       { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-flex         { display: flex !important; }
    .d-md-inline-flex  { display: inline-flex !important; }
    .d-md-grid         { display: grid !important; }
}

/* LG breakpoint display (≥ 992px) */
@media (min-width: 992px) {
    .d-lg-none         { display: none !important; }
    .d-lg-block        { display: block !important; }
    .d-lg-inline       { display: inline !important; }
    .d-lg-inline-block { display: inline-block !important; }
    .d-lg-flex         { display: flex !important; }
    .d-lg-inline-flex  { display: inline-flex !important; }
    .d-lg-grid         { display: grid !important; }
}

/* XL breakpoint display (≥ 1200px) */
@media (min-width: 1200px) {
    .d-xl-none         { display: none !important; }
    .d-xl-block        { display: block !important; }
    .d-xl-inline       { display: inline !important; }
    .d-xl-inline-block { display: inline-block !important; }
    .d-xl-flex         { display: flex !important; }
    .d-xl-inline-flex  { display: inline-flex !important; }
    .d-xl-grid         { display: grid !important; }
}

/* Shorthand: visible only below a breakpoint */
.d-mobile-only { display: block !important; }
@media (min-width: 768px) {
    .d-mobile-only { display: none !important; }
}

/* Shorthand: visible only at/above md */
.d-desktop-only { display: none !important; }
@media (min-width: 768px) {
    .d-desktop-only { display: block !important; }
}

/* ============================================
   FLEX UTILITIES
   ============================================ */

.flex-row         { flex-direction: row !important; }
.flex-column      { flex-direction: column !important; }
.flex-row-reverse { flex-direction: row-reverse !important; }
.flex-col-reverse { flex-direction: column-reverse !important; }
.flex-wrap        { flex-wrap: wrap !important; }
.flex-nowrap      { flex-wrap: nowrap !important; }
.flex-grow-1      { flex-grow: 1 !important; }
.flex-shrink-0    { flex-shrink: 0 !important; }

.justify-start    { justify-content: flex-start !important; }
.justify-end      { justify-content: flex-end !important; }
.justify-center   { justify-content: center !important; }
.justify-between  { justify-content: space-between !important; }
.justify-around   { justify-content: space-around !important; }
.justify-evenly   { justify-content: space-evenly !important; }

.align-start      { align-items: flex-start !important; }
.align-end        { align-items: flex-end !important; }
.align-center     { align-items: center !important; }
.align-baseline   { align-items: baseline !important; }
.align-stretch    { align-items: stretch !important; }

/* ============================================
   RESPONSIVE SPACING
   ============================================ */

/* Padding */
.p-0  { padding: 0 !important; }
.p-1  { padding: 4px !important; }
.p-2  { padding: 8px !important; }
.p-3  { padding: 16px !important; }
.p-4  { padding: 24px !important; }
.p-5  { padding: 32px !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 4px !important; }
.pt-2 { padding-top: 8px !important; }
.pt-3 { padding-top: 16px !important; }
.pt-4 { padding-top: 24px !important; }
.pt-5 { padding-top: 32px !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 4px !important; }
.pb-2 { padding-bottom: 8px !important; }
.pb-3 { padding-bottom: 16px !important; }
.pb-4 { padding-bottom: 24px !important; }
.pb-5 { padding-bottom: 32px !important; }

.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: 4px !important; }
.pl-2 { padding-left: 8px !important; }
.pl-3 { padding-left: 16px !important; }
.pl-4 { padding-left: 24px !important; }
.pl-5 { padding-left: 32px !important; }

.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: 4px !important; }
.pr-2 { padding-right: 8px !important; }
.pr-3 { padding-right: 16px !important; }
.pr-4 { padding-right: 24px !important; }
.pr-5 { padding-right: 32px !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: 4px !important; padding-right: 4px !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 16px !important; padding-right: 16px !important; }
.px-4 { padding-left: 24px !important; padding-right: 24px !important; }
.px-5 { padding-left: 32px !important; padding-right: 32px !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 4px !important; padding-bottom: 4px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-4 { padding-top: 24px !important; padding-bottom: 24px !important; }
.py-5 { padding-top: 32px !important; padding-bottom: 32px !important; }

/* Margin */
.m-0   { margin: 0 !important; }
.m-1   { margin: 4px !important; }
.m-2   { margin: 8px !important; }
.m-3   { margin: 16px !important; }
.m-4   { margin: 24px !important; }
.m-5   { margin: 32px !important; }
.m-auto { margin: auto !important; }

.mt-0  { margin-top: 0 !important; }
.mt-1  { margin-top: 4px !important; }
.mt-2  { margin-top: 8px !important; }
.mt-3  { margin-top: 16px !important; }
.mt-4  { margin-top: 24px !important; }
.mt-5  { margin-top: 32px !important; }

.mb-0  { margin-bottom: 0 !important; }
.mb-1  { margin-bottom: 4px !important; }
.mb-2  { margin-bottom: 8px !important; }
.mb-3  { margin-bottom: 16px !important; }
.mb-4  { margin-bottom: 24px !important; }
.mb-5  { margin-bottom: 32px !important; }

.ml-0  { margin-left: 0 !important; }
.ml-1  { margin-left: 4px !important; }
.ml-2  { margin-left: 8px !important; }
.ml-3  { margin-left: 16px !important; }
.ml-4  { margin-left: 24px !important; }
.ml-5  { margin-left: 32px !important; }
.ml-auto { margin-left: auto !important; }

.mr-0  { margin-right: 0 !important; }
.mr-1  { margin-right: 4px !important; }
.mr-2  { margin-right: 8px !important; }
.mr-3  { margin-right: 16px !important; }
.mr-4  { margin-right: 24px !important; }
.mr-5  { margin-right: 32px !important; }
.mr-auto { margin-right: auto !important; }

.mx-0    { margin-left: 0 !important; margin-right: 0 !important; }
.mx-1    { margin-left: 4px !important; margin-right: 4px !important; }
.mx-2    { margin-left: 8px !important; margin-right: 8px !important; }
.mx-3    { margin-left: 16px !important; margin-right: 16px !important; }
.mx-4    { margin-left: 24px !important; margin-right: 24px !important; }
.mx-5    { margin-left: 32px !important; margin-right: 32px !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

.my-0    { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-1    { margin-top: 4px !important; margin-bottom: 4px !important; }
.my-2    { margin-top: 8px !important; margin-bottom: 8px !important; }
.my-3    { margin-top: 16px !important; margin-bottom: 16px !important; }
.my-4    { margin-top: 24px !important; margin-bottom: 24px !important; }
.my-5    { margin-top: 32px !important; margin-bottom: 32px !important; }

/* Gap utilities */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }
.gap-4 { gap: 24px !important; }
.gap-5 { gap: 32px !important; }

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

.text-left    { text-align: left !important; }
.text-center  { text-align: center !important; }
.text-right   { text-align: right !important; }

@media (min-width: 768px) {
    .text-md-left   { text-align: left !important; }
    .text-md-center { text-align: center !important; }
    .text-md-right  { text-align: right !important; }
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-break {
    word-break: break-word;
    overflow-wrap: break-word;
}

.text-nowrap {
    white-space: nowrap !important;
}

/* Responsive font sizes (scale up on larger screens) */
.fs-sm { font-size: 0.875rem; }
.fs-base { font-size: 1rem; }
.fs-lg { font-size: 1.125rem; }
.fs-xl { font-size: 1.25rem; }
.fs-2xl { font-size: 1.5rem; }
.fs-3xl { font-size: 1.875rem; }

/* ============================================
   MOBILE NAVIGATION PATTERN
   ============================================ */

/* Toggle button — visible by default (mobile), hidden on wider screens */
.mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    color: var(--text-primary, #ffffff);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.mobile-nav-toggle:hover {
    background: var(--bg-tertiary, #1a1a1a);
    border-color: var(--accent-primary, #00d4ff);
}

/* Hamburger icon lines */
.hamburger-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 20px;
}

.hamburger-lines span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary, #ffffff);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Animated X state */
.mobile-nav-toggle[aria-expanded="true"] .hamburger-lines span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.mobile-nav-toggle[aria-expanded="true"] .hamburger-lines span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.mobile-nav-toggle[aria-expanded="true"] .hamburger-lines span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Hide toggle on desktop */
@media (min-width: 768px) {
    .mobile-nav-toggle {
        display: none;
    }
}

/* Nav menu — full-width overlay on mobile */
@media (max-width: 767px) {
    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-secondary, #111111);
        border-top: 1px solid var(--border-color, #2a2a2a);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 999;
        padding: 16px;
    }

    .nav-menu.active {
        transform: translateX(0);
    }

    .nav-menu .nav-item {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid var(--border-color, #2a2a2a);
    }

    .nav-menu .nav-item:last-child {
        border-bottom: none;
    }
}

/* Ensure nav menu is visible and flex on desktop */
@media (min-width: 768px) {
    .nav-menu {
        display: flex !important;
        position: static;
        transform: none;
        background: transparent;
        border-top: none;
        padding: 0;
        overflow: visible;
    }
}

/* ============================================
   RESPONSIVE IMAGES & MEDIA
   ============================================ */

.img-fluid {
    max-width: 100%;
    height: auto;
}

.img-thumbnail {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color, #2a2a2a);
    border-radius: 6px;
    padding: 4px;
}

/* ============================================
   RESPONSIVE EMBEDS (video, iframe)
   ============================================ */

.embed-responsive {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.embed-responsive::before {
    display: block;
    content: '';
}

.embed-responsive-16by9::before {
    padding-top: 56.25%;
}

.embed-responsive-4by3::before {
    padding-top: 75%;
}

.embed-responsive > iframe,
.embed-responsive > video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ============================================
   WIDTH / HEIGHT UTILITIES
   ============================================ */

.w-25   { width: 25% !important; }
.w-50   { width: 50% !important; }
.w-75   { width: 75% !important; }
.w-100  { width: 100% !important; }
.w-auto { width: auto !important; }

.h-25   { height: 25% !important; }
.h-50   { height: 50% !important; }
.h-75   { height: 75% !important; }
.h-100  { height: 100% !important; }
.h-auto { height: auto !important; }

.min-vw-100 { min-width: 100vw !important; }
.min-vh-100 { min-height: 100vh !important; }
.vw-100 { width: 100vw !important; }
.vh-100 { height: 100vh !important; }

/* ============================================
   OVERFLOW UTILITIES
   ============================================ */

.overflow-auto   { overflow: auto !important; }
.overflow-hidden { overflow: hidden !important; }
.overflow-visible { overflow: visible !important; }
.overflow-scroll { overflow: scroll !important; }
.overflow-x-auto { overflow-x: auto !important; }
.overflow-y-auto { overflow-y: auto !important; }

/* ============================================
   POSITION UTILITIES
   ============================================ */

.position-static   { position: static !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed    { position: fixed !important; }
.position-sticky   { position: sticky !important; }

/* ============================================
   BORDER RADIUS UTILITIES
   ============================================ */

.rounded-0  { border-radius: 0 !important; }
.rounded-1  { border-radius: 4px !important; }
.rounded-2  { border-radius: 8px !important; }
.rounded-3  { border-radius: 12px !important; }
.rounded-4  { border-radius: 16px !important; }
.rounded-pill { border-radius: 9999px !important; }
.rounded-circle { border-radius: 50% !important; }

/* ============================================
   SHADOW UTILITIES
   ============================================ */

.shadow-none { box-shadow: none !important; }
.shadow-sm   { box-shadow: var(--shadow-card, 0 2px 4px rgba(0,0,0,0.1)) !important; }
.shadow      { box-shadow: var(--shadow-elevated, 0 4px 12px rgba(0,0,0,0.15)) !important; }
.shadow-glow { box-shadow: var(--shadow-glow, 0 0 40px rgba(0,212,255,0.15)) !important; }

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .nav-menu {
        transition: none;
    }

    .mobile-nav-toggle .hamburger-lines span {
        transition: none;
    }
}
