/* ============================================================
   Platinum CRM — Responsive Styles
   Consolidated media queries from theme.css
   Organized by breakpoint
   ============================================================

   Table of Contents
   -----------------
   1.  Mobile           (max-width: 767.98px)
   2.  Small Mobile     (max-width: 575.98px)
   2b. Mobile Header    (max-width: 991.98px)
   3.  Medium           (max-width: 991.98px)
   4.  Tablet           (min-width: 768px) and (max-width: 991.98px)
   5.  Large Desktop    (min-width: 1400px)
   6.  Print
   7.  Accessibility    (forced-colors, prefers-reduced-motion)
   8.  Touch Devices    (hover: none)
   ============================================================ */


/* ============================================================
   1. Mobile  (max-width: 767.98px)
   ============================================================ */
@media (max-width: 767.98px) {

    /* ── Sidebar — hidden by default on mobile ── */
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        z-index: 10001;
    }

    /* Desktop collapsed class is irrelevant on mobile — keep hidden */
    .sidebar.sidebar-collapsed {
        transform: translateX(-100%);
    }

    /* Mobile: user opened the sidebar */
    .sidebar.sidebar-mobile-open {
        transform: translateX(0);
    }

    /* ── Show mobile navbar ── */
    .navbar {
        display: flex !important;
    }

    .header-search {
        min-width: 120px;
        max-width: 180px;
    }

    .navbar-nav.ml-auto {
        margin-left: auto;
    }

    /* ── Auth layout — mobile ── */
    .hero-row {
        flex-direction: column;
    }

    .col-md-8.d-flex.bg-white {
        min-height: 100dvh;
        padding: 1.5rem !important;
        align-items: flex-start;
        padding-top: 3rem !important;
    }

    .login-container,
    .w-100 {
        padding: 0;
    }

    body.hero-present .form-control {
        font-size: 0.9375rem;
        padding: 0.625rem 0.875rem;
    }

    body.hero-present .btn {
        padding: 0.6875rem 1.25rem;
    }

    /* ── Form stepper ── */
    .form-stepper {
        padding: 0.375rem 0.5rem;
        gap: 0;
    }

    .form-stepper-step {
        padding: 0.5rem 0.625rem;
    }

    .form-stepper-label {
        font-size: 0.7rem;
    }

    .form-stepper-connector {
        flex: 0 0 12px;
    }

    /* ── Onboarding progress ── */
    .onboard-step { min-width: 70px; }
    .onboard-step-dot { width: 30px; height: 30px; font-size: 0.65rem; }
    .onboard-step-dot i { font-size: 0.75rem; }
    .onboard-step-label { font-size: 0.65rem; }
    .onboard-step-sub { font-size: 0.6rem; }
    .onboard-connector { min-width: 20px; margin-top: 13.5px; }

    /* ── Content animations — reduce for performance ── */
    .content {
        animation: fadeIn var(--dur-normal) ease both;
    }

    .chart-legend {
        gap: 0.5rem;
    }

    .chart-period-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}


/* ============================================================
   2. Small Mobile  (max-width: 575.98px)
   ============================================================ */
@media (max-width: 575.98px) {

    /* ── Skeleton loaders ── */
    .skeleton-card {
        height: 160px;
    }

    .skeleton-chart {
        height: 180px;
    }

    /* ── Stat widgets ── */
    .stat-widget {
        padding: 1rem;
    }

    .stat-widget-value {
        font-size: 1.375rem;
    }

    .stat-widget-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 1.125rem;
    }

    /* ── Chart containers ── */
    .chart-container-sm { height: 160px; }
    .chart-container-md { height: 220px; }
    .chart-container-lg { height: 280px; }
    .chart-container-xl { height: 340px; }

    /* ── Modals ── */
    .modal-content {
        border-radius: var(--bs-border-radius-lg);
    }

    /* ── Stat grids ── */
    .stat-grid-2,
    .stat-grid-3,
    .stat-grid-4 { grid-template-columns: 1fr; }
}


/* ============================================================
   2b. Mobile Header  (max-width: 991.98px — matches d-lg-none)
   ============================================================ */
@media (max-width: 991.98px) {

    /* Hide desktop content header — mobile header handles everything */
    .content-header {
        display: none;
    }

    /* ── Mobile Header ── */
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.92));
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        padding: 0 0.75rem;
    }

    .mobile-header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 3.25rem;
        gap: 0.375rem;
    }

    /* ── Left: Logo + Back + Title + Breadcrumb ── */
    .mobile-header-start {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .mobile-header-logo {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        text-decoration: none;
    }

    .mobile-header-logo img {
        height: 22px;
        width: auto;
    }

    .mobile-header-sep {
        width: 1px;
        height: 1rem;
        background: var(--bs-gray-300);
        flex-shrink: 0;
        opacity: 0.7;
    }

    .mobile-header-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 8px;
        color: var(--bs-gray-600);
        text-decoration: none;
        flex-shrink: 0;
        transition: background 0.15s ease, color 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-header-back i {
        font-size: 0.875rem;
        font-weight: 700;
    }

    .mobile-header-back:active {
        background: rgba(0, 0, 0, 0.06);
        color: var(--bs-primary);
    }

    .mobile-header-title {
        font-size: 0.8125rem;
        font-weight: 650;
        color: var(--bs-heading-color);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    .mobile-header-breadcrumb {
        font-size: 0.6875rem;
        font-weight: 500;
        color: var(--text-sub);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 0.7;
        display: none;
    }

    /* Show breadcrumb only on wider mobile screens */
    @media (min-width: 420px) {
        .mobile-header-breadcrumb {
            display: inline;
        }
    }

    /* ── Right: Actions ── */
    .mobile-header-actions {
        display: flex;
        align-items: center;
        gap: 0.125rem;
        flex-shrink: 0;
    }

    .mobile-header-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        padding: 0;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: var(--bs-gray-700);
        font-size: 1.125rem;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-header-btn:active {
        background: rgba(0, 0, 0, 0.08);
        transform: scale(0.95);
    }

    .mobile-header-avatar {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: transparent;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.15s ease;
    }

    .mobile-header-avatar:active {
        transform: scale(0.93);
    }

    .mobile-header-avatar i {
        font-size: 1.375rem;
        transition: color 0.15s ease;
    }

    .mobile-header-avatar.avatar-role-platform-admin i { color: var(--bs-warning); }
    .mobile-header-avatar.avatar-role-platform i   { color: var(--bs-primary); }
    .mobile-header-avatar.avatar-role-clinic i     { color: var(--bs-success); }
    .mobile-header-avatar.avatar-role-staff i      { color: var(--bs-indigo, #6610f2); }
    .mobile-header-avatar.avatar-role-patient i    { color: var(--bs-teal, #20c997); }
    .mobile-header-avatar.avatar-role-user i       { color: var(--bs-info); }

    .mobile-header-avatar:hover i,
    .mobile-header-avatar:focus i {
        filter: brightness(1.15);
    }

    /* Mobile account dropdown positioning */
    .mobile-header .account-dropdown-menu {
        position: fixed;
        top: 3.5rem;
        right: 0.75rem;
        left: auto;
        z-index: 1001;
        width: calc(100vw - 1.5rem);
        max-width: 17rem;
        margin-top: 0;
    }

    /* Mobile theme toggle icon sizing */
    .mobile-header .theme-toggle-btn .theme-icon-light,
    .mobile-header .theme-toggle-btn .theme-icon-dark {
        font-size: 0.875rem;
    }

    /* Main content full width when mobile header active */
    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0;
        width: 100%;
    }
}


/* ============================================================
   3. Medium  (max-width: 991.98px)
   ============================================================ */
@media (max-width: 991.98px) {

    /* ── Stat grids ── */
    .stat-grid-3,
    .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
}


/* ============================================================
   4. Tablet  (min-width: 768px) and (max-width: 991.98px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 991.98px) {

    /* ── Sidebar — hidden by default on tablet, slide-in like mobile ── */
    .sidebar {
        transform: translateX(-100%);
        width: 240px;
        z-index: 10001;
    }

    .sidebar.sidebar-collapsed {
        transform: translateX(-100%);
    }

    .sidebar.sidebar-mobile-open {
        transform: translateX(0);
    }

    /* ── Stat widget ── */
    .stat-widget-value {
        font-size: 1.5rem;
    }
}


/* ============================================================
   5. Large Desktop  (min-width: 1400px)
   ============================================================ */
@media (min-width: 1400px) {

    /* ── Stat widgets ── */
    .stat-widget-value {
        font-size: 2rem;
    }

    /* ── Chart containers ── */
    .chart-container-lg { height: 450px; }
    .chart-container-xl { height: 550px; }
}


/* ============================================================
   6. Print
   ============================================================ */
@media print {
    .sidebar,
    .navbar,
    .sidebar-toggle,
    .content-header,
    .mobile-header {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}


/* ============================================================
   7. Accessibility
   ============================================================ */

/* Forced colors (Windows High Contrast Mode) */
@media (forced-colors: active) {
    .form-control {
        border: 2px solid ButtonText;
    }

    .btn-primary {
        forced-color-adjust: none;
    }
}

/* 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;
    }

    .logo-background,
    .skeleton::after,
    .pulse-indicator::before {
        animation: none;
    }

    .card:hover,
    .card-hover-lift:hover,
    .glass-card:hover,
    .hover-lift:hover,
    .hover-scale:hover {
        transform: none;
    }

    .content,
    .fade-in,
    .fade-in-up,
    .fade-in-down,
    .fade-in-left,
    .fade-in-right,
    .scale-in {
        animation: none;
        opacity: 1;
    }
}


/* ============================================================
   8. Touch Devices  (hover: none)
   ============================================================ */
@media (hover: none) {
    .card:hover,
    .card-hover-lift:hover,
    .glass-card:hover,
    .hover-lift:hover,
    .hover-scale:hover {
        transform: none;
        box-shadow: var(--shadow-card);
    }

    .btn:active:not(:disabled) {
        transform: scale(0.98);
    }
}
