/* Mobile-First Enhancements - Comprehensive Mobile Optimization */

/* ================================================
   RESPONSIVE BREAKPOINTS & MOBILE VARIABLES
   ================================================ */
:root {
  --mobile-s: 320px;
  --mobile-m: 375px; 
  --mobile-l: 425px;
  --tablet: 768px;
  --laptop: 1024px;
  --desktop: 1440px;
  --mobile-nav-height: 60px;
  --mobile-padding: 16px;
  --touch-target-min: 44px;
}

/* ================================================
   GLOBAL MOBILE RESETS
   ================================================ */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
  }
  
  html {
    font-size: 16px !important; /* Prevent iOS zoom on form focus */
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }
  
  body {
    overflow-x: hidden;
    font-size: 16px;
    line-height: 1.5;
  }
}

/* ================================================
   MOBILE HAMBURGER MENU (Show on all mobile/tablet)
   ================================================ */
@media (max-width: 991px) {
  .mobile-hamburger {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    font-size: 24px !important;
    color: #8b5cf6 !important;
    padding: 8px !important;
    text-decoration: none !important;
    min-width: 44px !important;
    min-height: 44px !important;
    z-index: 1050 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
  
  .mobile-hamburger i {
    display: block !important;
    font-size: 24px !important;
    color: #8b5cf6 !important;
  }
}

/* ================================================
   MOBILE-FIRST BASE STYLES
   ================================================ */
@media (max-width: 768px) {
  /* Force white backgrounds everywhere */
  body {
    background: #ffffff !important;
    color: #1e293b !important;
  }
  
  /* CRITICAL: Keep footer text light on dark background */
  footer, footer *, .footer, .footer * {
    color: #cbd5e1 !important;
  }
  footer h4, footer h5, footer h6,
  .footer h4, .footer h5, .footer h6 {
    color: #ffffff !important;
  }
  footer a, .footer a {
    color: #cbd5e1 !important;
  }
  footer a:hover, .footer a:hover {
    color: #3b82f6 !important;
  }
  
  /* Navigation optimizations */
  .app-nav {
    padding: 0 8px !important;
    height: 60px !important;
    background: #ffffff !important;
  }
  
  .app-nav .container-fluid {
    height: 60px !important;
    padding: 0 8px !important;
  }
  
  .app-brand {
    font-size: 18px !important;
  }
  
  .app-brand div {
    display: none; /* Hide tagline on mobile */
  }
  
  .app-brand::before {
    display: none !important; /* Hide icon on mobile */
  }
  
  /* Make nav buttons visible and clickable on mobile */
  .app-nav .btn {
    font-size: 13px !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    display: inline-block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  .app-nav .btn-primary {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
  }
  
  .app-nav .btn-outline-primary {
    background: #ffffff !important;
    border-color: #3b82f6 !important;
    color: #3b82f6 !important;
  }
  
  .app-nav .btn i {
    display: none; /* Hide icons in nav buttons on mobile to save space */
  }
  
  /* Collapsible sidebar for mobile */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px !important;
    z-index: 1050;
    background: #ffffff !important;
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .content {
    margin-left: 0 !important;
    padding: 20px 16px !important;
    margin-top: 60px !important;
    background: #ffffff !important;
  }
  
  /* Card optimizations */
  .card {
    border-radius: 12px !important;
    margin-bottom: 16px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
  }
  
  .card-body {
    padding: 16px !important;
  }
  
  /* Button optimizations - ENSURE ALL BUTTONS WORK ON MOBILE */
  .btn, button, .btn-apply, .btn-learn-more, .btn-add-goal, .btn-view-plan, .btn-primary {
    padding: 12px 20px !important;
    font-size: 14px !important;
    border-radius: 8px !important;
    min-height: 44px !important; /* iOS minimum tap target */
    min-width: 44px !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    touch-action: manipulation !important;
    user-select: none !important;
  }
  
  .btn-sm {
    padding: 8px 16px !important;
    font-size: 12px !important;
    min-height: 40px !important;
  }
  
  /* Ensure all clickable elements are accessible */
  a, button, .btn, input, select, textarea, [onclick], [role="button"] {
    cursor: pointer !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    touch-action: manipulation !important;
  }
  
  /* Form optimizations */
  .form-control {
    padding: 12px 16px !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
    border-radius: 8px !important;
  }
  
  .form-select {
    padding: 12px 16px !important;
    font-size: 16px !important;
  }
  
  /* Table responsiveness */
  .table-responsive {
    font-size: 14px;
  }
  
  .table th, .table td {
    padding: 8px 12px !important;
    font-size: 13px !important;
  }
}

/* ================================================
   ENHANCED IMPORT ANALYSIS MOBILE
   ================================================ */
@media (max-width: 768px) {
  /* Stats cards stack vertically */
  .import-analysis .row.g-3 .col-md-3 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    margin-bottom: 12px;
  }
  
  /* Bureau breakdown cards */
  .bureau-circle {
    width: 60px !important;
    height: 60px !important;
  }
  
  .bureau-count {
    width: 40px !important;
    height: 40px !important;
    font-size: 14px !important;
  }
  
  /* Account categories grid */
  .account-categories .col-md-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  /* Account table horizontal scroll */
  .account-analysis-table {
    min-width: 600px;
  }
  
  /* Sidebar moves to bottom on mobile */
  .import-analysis .col-lg-3 {
    order: 2 !important;
    margin-top: 20px;
  }
  
  .import-analysis .col-lg-9 {
    order: 1 !important;
  }
  
  /* AI recommendations compact */
  .recommendation-item {
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 12px;
    border-left: 3px solid var(--brand);
  }
}

/* ================================================
   WHITE LABEL BILLING MOBILE
   ================================================ */
@media (max-width: 768px) {
  /* Revenue cards 2x2 grid */
  .billing-stats .col-md-3 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  
  /* Client table optimizations */
  .client-table .table {
    font-size: 13px !important;
  }
  
  .client-table .btn-group {
    flex-direction: column !important;
  }
  
  .client-table .btn-group .btn {
    margin-bottom: 4px !important;
    border-radius: 6px !important;
  }
  
  /* Revenue chart container */
  .revenue-chart-container {
    height: 200px !important;
    margin: 16px 0;
  }
  
  /* Billing plans stack */
  .billing-plans .col-md-4 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin-bottom: 16px;
  }
  
  /* Quick actions vertical */
  .quick-actions .d-grid {
    gap: 8px !important;
  }
  
  .quick-actions .btn {
    padding: 12px !important;
    font-size: 13px !important;
  }
}

/* ================================================
   CLIENT ONBOARDING MOBILE
   ================================================ */
@media (max-width: 768px) {
  /* Flow items stack */
  .flow-item .row {
    flex-direction: column !important;
  }
  
  .flow-item .col-md-6, 
  .flow-item .col-md-3 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin-bottom: 12px;
  }
  
  /* Flow preview compact */
  .flow-preview {
    max-height: 200px !important;
  }
  
  .flow-step {
    padding: 8px !important;
    margin: 4px 0 !important;
  }
  
  .step-icon {
    font-size: 1.2em !important;
  }
  
  /* Email template cards */
  .email-templates .col-md-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  /* Performance insights compact */
  .insight-item {
    padding: 6px 0 !important;
  }
  
  .insight-item .d-flex {
    font-size: 12px !important;
  }
  
  /* Trigger events list */
  .form-check {
    margin-bottom: 8px !important;
  }
  
  .form-check-label {
    font-size: 13px !important;
  }
}

/* ================================================
   DASHBOARD MOBILE OPTIMIZATIONS  
   ================================================ */
@media (max-width: 768px) {
  /* Credit score cards */
  .score-card {
    margin-bottom: 16px !important;
  }
  
  .score-display {
    font-size: 2.5rem !important;
  }
  
  /* Progress bars */
  .progress {
    height: 8px !important;
    border-radius: 4px !important;
  }
  
  /* Account list items */
  .tradeline-item {
    padding: 12px !important;
    margin-bottom: 8px !important;
    border-radius: 8px !important;
  }
  
  /* Action buttons */
  .action-buttons .btn {
    width: 100% !important;
    margin-bottom: 8px !important;
  }
  
  /* Stats overview */
  .stats-grid .col-md-3 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
}

/* ================================================
   MODAL & OVERLAY MOBILE
   ================================================ */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    height: 100% !important;
  }
  
  .modal-content {
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
  }
  
  .modal-header {
    padding: 16px !important;
    border-bottom: 1px solid #dee2e6;
  }
  
  .modal-body {
    padding: 16px !important;
    overflow-y: auto;
  }
  
  .modal-footer {
    padding: 16px !important;
    border-top: 1px solid #dee2e6;
  }
  
  /* Flow builder modal special handling */
  .modal-fullscreen .modal-dialog {
    width: 100% !important;
    height: 100% !important;
  }
  
  .flow-canvas {
    min-height: 300px !important;
    padding: 16px !important;
  }
  
  .template-item {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }
}

/* ================================================
   TOUCH OPTIMIZATIONS
   ================================================ */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn, .nav-link, .dropdown-item {
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
  }
  
  /* Table row touch targets */
  .table tbody tr {
    min-height: 48px !important;
  }
  
  .table tbody td {
    vertical-align: middle !important;
  }
  
  /* Form controls */
  .form-control, .form-select {
    min-height: 44px !important;
  }
  
  /* Checkbox and radio larger targets */
  .form-check-input {
    width: 20px !important;
    height: 20px !important;
  }
  
  .form-check-label {
    padding-left: 8px !important;
  }
}

/* ================================================
   SPECIFIC MOBILE IMPROVEMENTS  
   ================================================ */

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1040;
}

.sidebar-overlay.show {
  display: block;
}

/* Mobile search optimizations */
@media (max-width: 768px) {
  .search-input {
    font-size: 16px !important;
    padding: 12px 16px !important;
  }
  
  .search-results {
    max-height: 300px !important;
    overflow-y: auto;
  }
}

/* Mobile navigation improvements */
@media (max-width: 768px) {
  .navbar .btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
    margin: 0 4px !important;
  }
  
  .navbar .d-flex {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
}

/* Mobile form improvements */
@media (max-width: 768px) {
  .form-floating .form-control {
    padding-top: 20px !important;
    padding-bottom: 12px !important;
  }
  
  .form-floating label {
    font-size: 14px !important;
  }
  
  .input-group .btn {
    padding: 12px 16px !important;
  }
}

/* Mobile badge and tag improvements */
@media (max-width: 768px) {
  .badge {
    font-size: 10px !important;
    padding: 4px 8px !important;
  }
  
  .status-badge {
    display: inline-block !important;
    margin: 2px !important;
  }
}

/* ================================================
   PROGRESSIVE WEB APP STYLES
   ================================================ */
@media (display-mode: standalone) {
  .app-nav {
    padding-top: env(safe-area-inset-top) !important;
  }
  
  .content {
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
}

/* ================================================
   MOBILE LIGHT THEME (Override dark mode for consistency)
   ================================================ */
@media (max-width: 768px) {
  /* Only override cards WITHOUT inline styles or bg classes */
  .card:not([style*="background"]):not([class*="bg-"]) {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #1e293b !important;
  }
  
  /* Card body backgrounds - preserve parent card styles */
  .card-body:not([style*="background"]):not([class*="bg-"]) {
    background: transparent !important;
    color: #1e293b !important;
  }
  
  /* Ensure text-white class works on colored cards */
  .card.text-white,
  .card.text-white * {
    color: #ffffff !important;
  }
  
  /* Card headers WITH DARK backgrounds get white text (only genuinely dark colors) */
  .card-header.bg-primary,
  .card-header.bg-secondary,
  .card-header.bg-success,
  .card-header.bg-danger,
  .card-header.bg-dark {
    color: #ffffff !important;
  }
  
  /* All children of dark card headers inherit white text */
  .card-header.bg-primary *,
  .card-header.bg-secondary *,
  .card-header.bg-success *,
  .card-header.bg-danger *,
  .card-header.bg-dark * {
    color: inherit !important;
  }
  
  /* Card headers with LIGHT backgrounds get dark text (preserve original background) */
  .card-header.bg-light,
  .card-header.bg-warning,
  .card-header.bg-info {
    color: #1e293b !important;
  }
  
  /* Card headers with NO background get dark text and light background */
  
  /* ================================================
     FUNDING & GOALS SECTION - MOBILE FIXES
     ================================================ */
  .ci-tabs button {
    min-height: 48px !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    background: #f3f4f6 !important;
    color: #1f2937 !important;
    border: 2px solid transparent !important;
  }
  
  .ci-tabs button.active {
    background: #ffffff !important;
    color: #6366f1 !important;
    border-bottom-color: #6366f1 !important;
  }
  
  .offer-card {
    margin-bottom: 16px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
  }
  
  .offer-header {
    padding: 16px !important;
    background: #6366f1 !important;
    color: #ffffff !important;
  }
  
  .offer-header * {
    color: #ffffff !important;
  }
  
  .offer-footer button {
    min-height: 48px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
  }
  
  .btn-apply {
    background: #6366f1 !important;
    color: #ffffff !important;
    border: none !important;
  }
  
  .btn-learn-more {
    background: #ffffff !important;
    color: #374151 !important;
    border: 2px solid #e5e7eb !important;
  }
  
  /* Goal cards mobile */
  .goal-item {
    padding: 16px !important;
    margin-bottom: 12px !important;
    background: #ffffff !important;
    border: 2px solid #e5e7eb !important;
  }
  
  .btn-add-goal, .btn-view-plan {
    min-height: 44px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
  }
  
  /* Ensure marketplace grid is responsive */
  .ci-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  .marketplace-header {
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  .ci-tabs {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* ================================================
     IMPROVED SCROLLING & OVERFLOW HANDLING
     ================================================ */
  .table-responsive {
    -webkit-overflow-scrolling: touch !important;
    overflow-x: auto !important;
  }
  
  /* Prevent horizontal scroll issues */
  .container, .container-fluid {
    overflow-x: hidden !important;
    max-width: 100% !important;
  }
  
  .row {
    margin-left: -8px !important;
    margin-right: -8px !important;
  }
  
  .row > * {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  
  /* ================================================
     IMPROVED FORM ELEMENTS FOR MOBILE
     ================================================ */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  input[type="date"],
  textarea,
  select {
    font-size: 16px !important; /* Prevents zoom on iOS */
    padding: 12px 16px !important;
    border-radius: 8px !important;
    width: 100% !important;
  }
  
  /* Better checkbox and radio buttons */
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
  }
  
  /* Form labels */
  label {
    font-size: 14px !important;
    margin-bottom: 8px !important;
    display: block !important;
  }
  
  /* ================================================
     IMPROVED NAVIGATION FOR MOBILE
     ================================================ */
  .navbar {
    padding: 8px 16px !important;
  }
  
  .navbar-brand img {
    max-height: 36px !important;
  }
  
  /* Hide desktop-only elements */
  .d-none.d-sm-inline-block {
    display: none !important;
  }
  
  /* ================================================
     IMPROVED CARD LAYOUT
     ================================================ */
  .card {
    margin-bottom: 16px !important;
    border-radius: 12px !important;
  }
  
  .card-header {
    padding: 12px 16px !important;
  }
  
  .card-body {
    padding: 16px !important;
  }
  
  .card-footer {
    padding: 12px 16px !important;
  }
  
  /* ================================================
     GRID SYSTEM IMPROVEMENTS
     ================================================ */
  .col-md-6, .col-md-4, .col-md-3, .col-lg-6, .col-lg-4, .col-lg-3 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  /* Half-width on mobile for stats */
  .stats-grid .col-md-3,
  .stats-grid .col-md-4 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  
  /* ================================================
     TYPOGRAPHY IMPROVEMENTS
     ================================================ */
  h1 { font-size: 24px !important; }
  h2 { font-size: 22px !important; }
  h3 { font-size: 20px !important; }
  h4 { font-size: 18px !important; }
  h5 { font-size: 16px !important; }
  h6 { font-size: 14px !important; }
  
  /* ================================================
     UTILITY SPACING FOR MOBILE
     ================================================ */
  .mt-5, .my-5 { margin-top: 24px !important; }
  .mb-5, .my-5 { margin-bottom: 24px !important; }
  .pt-5, .py-5 { padding-top: 24px !important; }
  .pb-5, .py-5 { padding-bottom: 24px !important; }
  
  /* ================================================
     FOOTER IMPROVEMENTS
     ================================================ */
  footer {
    padding: 16px !important;
    font-size: 12px !important;
    margin-left: 0 !important;
  }
  
  footer .row {
    text-align: center !important;
  }
  
  footer .col-md-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin-bottom: 12px !important;
  }
  
  /* ================================================
     LOADING STATES & SPINNERS
     ================================================ */
  .spinner-border {
    width: 2rem !important;
    height: 2rem !important;
  }
  
  /* ================================================
     COLOR CONTRAST FIXES FOR MOBILE
     ================================================ */
  /* Ensure all text is readable */
  body, p, span, div, label {
    color: #1f2937 !important;
  }
  
  /* Headings */
  h1, h2, h3, h4, h5, h6, .insight-title, .section-title {
    color: #111827 !important;
    font-weight: 700 !important;
  }
  
  /* Links */
  a:not(.btn) {
    color: #6366f1 !important;
    text-decoration: underline !important;
  }
  
  a:not(.btn):visited {
    color: #4f46e5 !important;
  }
  
  /* Badge contrast */
  .badge, .status-badge, .approval-badge {
    border: 1px solid rgba(0,0,0,0.1) !important;
    font-weight: 600 !important;
  }
  
  /* Override any light gray text */
  .text-muted, .text-secondary {
    color: #6b7280 !important;
  }
  
  /* Card headers with NO background get dark text and light background */
  .card-header:not([class*="bg-"]) {
    color: #1e293b !important;
    background: #f8f9fa !important;
  }
  
  /* All children of light card headers inherit dark text */
  .card-header.bg-light *,
  .card-header.bg-warning *,
  .card-header.bg-info *,
  .card-header:not([class*="bg-"]) * {
    color: inherit !important;
  }
  
  .sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,.9) 0%, rgba(248,250,252,.9) 100%) !important;
  }
  
  .form-control {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #1e293b !important;
  }
  
  .table {
    color: #1e293b !important;
    background: #ffffff !important;
  }
  
  .table thead th {
    border-color: #e2e8f0 !important;
    background: #f8f9fa !important;
  }
  
  /* Ensure main text is dark on mobile (but NEVER inside card-header) */
  body {
    color: #1e293b !important;
  }
  
  /* Card body text - dark color */
  .card-body p:not(.badge):not([class*="text-"]):not([class*="bg-"]),
  .card-body h1:not(.badge):not([class*="text-"]):not([class*="bg-"]), 
  .card-body h2:not(.badge):not([class*="text-"]):not([class*="bg-"]), 
  .card-body h3:not(.badge):not([class*="text-"]):not([class*="bg-"]), 
  .card-body h4:not(.badge):not([class*="text-"]):not([class*="bg-"]), 
  .card-body h5:not(.badge):not([class*="text-"]):not([class*="bg-"]), 
  .card-body h6:not(.badge):not([class*="text-"]):not([class*="bg-"]) {
    color: #1e293b !important;
  }
  
  /* Buttons remain clickable and visible */
  .btn {
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  .btn-primary {
    color: #ffffff !important;
    background: #3b82f6 !important;
  }
  
  .btn-outline-primary, .btn-outline-secondary {
    color: #3b82f6 !important;
    background: #ffffff !important;
    border-color: #3b82f6 !important;
  }
  
  /* Help widget mobile sizing */
  #help-widget {
    bottom: 16px !important;
    right: 16px !important;
  }
  
  #help-btn {
    width: 50px !important;
    height: 50px !important;
    font-size: 20px !important;
  }
  
  #help-chat {
    width: 100% !important;
    max-width: calc(100vw - 32px) !important;
    height: 70vh !important;
    max-height: 500px !important;
    right: 0 !important;
  }
}

/* ================================================
   ANIMATION OPTIMIZATIONS FOR MOBILE
   ================================================ */
@media (max-width: 768px) {
  /* Reduce motion for performance */
  .card, .btn, .sidebar {
    transition: transform 0.2s ease !important;
  }
  
  /* Faster animations */
  .fade {
    transition: opacity 0.15s linear !important;
  }
  
  .collapse {
    transition: height 0.15s ease !important;
  }
}

/* ================================================
   ACCESSIBILITY IMPROVEMENTS
   ================================================ */
@media (max-width: 768px) {
  /* Focus indicators */
  .btn:focus, .form-control:focus {
    box-shadow: 0 0 0 3px rgba(120, 103, 232, 0.25) !important;
    outline: none !important;
  }
  
  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .btn {
      border-width: 2px !important;
    }
    
    .card {
      border-width: 2px !important;
    }
  }
  
  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* ================================================
   LANDSCAPE ORIENTATION OPTIMIZATIONS
   ================================================ */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-dialog {
    max-height: 90vh !important;
  }
  
  .modal-body {
    max-height: 60vh !important;
    overflow-y: auto !important;
  }
}

/* ================================================
   EXTRA SMALL DEVICES (< 375px)
   ================================================ */
@media (max-width: 374px) {
  .btn {
    font-size: 13px !important;
    padding: 10px 16px !important;
  }
  
  .card-body {
    padding: 12px !important;
  }
  
  h1 { font-size: 20px !important; }
  h2 { font-size: 18px !important; }
  h3 { font-size: 16px !important; }
}

/* ================================================
   PRINT STYLES
   ================================================ */
@media print {
  .sidebar,
  .app-nav,
  .mobile-hamburger,
  .btn,
  footer,
  .modal,
  .mobile-overlay {
    display: none !important;
  }
  
  .content {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding: 0 !important;
  }
  
  .card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
  }
}

/* ================================================
   HIGH DPI / RETINA DISPLAYS
   ================================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .app-brand img,
  .navbar-brand img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* ================================================
   SAFE AREA INSETS FOR NOTCHED DEVICES
   ================================================ */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .app-nav {
      padding-left: max(16px, env(safe-area-inset-left)) !important;
      padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
    
    .content {
      padding-left: max(16px, env(safe-area-inset-left)) !important;
      padding-right: max(16px, env(safe-area-inset-right)) !important;
      padding-bottom: max(80px, env(safe-area-inset-bottom)) !important;
    }
    
    .sidebar {
      padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }
  }
}

/* ================================================
   SPECIFIC PAGE IMPROVEMENTS
   ================================================ */
@media (max-width: 768px) {
  /* Credit goals/funding page improvements */
  .score-circle {
    width: 160px !important;
    height: 160px !important;
  }
  
  .score-circle-inner {
    width: 136px !important;
    height: 136px !important;
  }
  
  /* Letter generation improvements */
  .letter-preview-content {
    padding: 12px !important;
    font-size: 14px !important;
  }
  
  /* Dashboard improvements */
  .dashboard-stats {
    grid-template-columns: 1fr !important;
  }
  
  /* Client list improvements */
  .client-card {
    margin-bottom: 12px !important;
  }
}

/* MOBILE FIX v1759893418 - Enhanced and Complete */
