/* ═══════════════════════════════════════════════════════
   GARAGEOS — Mobile Client Optimizations
   Écran cible : ~6 pouces (smartphones)
   Focus : Devis, Factures, Abonnements, Paiement CB
═══════════════════════════════════════════════════════ */

/* ── Cards mobiles pour remplacer les tableaux ────────── */
@media (max-width: 768px) {
  
  /* Card item pour factures/devis/abonnements */
  .mobile-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
  }
  
  .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
  }
  
  .mobile-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
  }
  
  .mobile-card-subtitle {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
  }
  
  .mobile-card-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-align: right;
  }
  
  .mobile-card-amount-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 2px;
  }
  
  .mobile-card-body {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }
  
  .mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
  }
  
  .mobile-card-row-label {
    color: var(--muted);
    flex: 0 0 auto;
  }
  
  .mobile-card-row-value {
    color: var(--text);
    font-weight: 500;
    text-align: right;
    flex: 1 1 auto;
  }
  
  .mobile-card-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
  }
  
  .mobile-card-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 12px;
    padding: 10px 14px;
    min-height: 44px; /* Touch-friendly */
  }
  
  /* Badge status amélioré */
  .badge-mobile {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  
  .badge-mobile.payee,
  .badge-mobile.paye {
    background: var(--green-dim);
    color: var(--green);
  }
  
  .badge-mobile.impayee {
    background: var(--red-dim);
    color: var(--red);
  }
  
  .badge-mobile.en_attente,
  .badge-mobile.brouillon {
    background: var(--orange-dim);
    color: var(--orange);
  }
  
  .badge-mobile.envoye,
  .badge-mobile.accepte {
    background: var(--blue-dim);
    color: var(--blue);
  }
  
  /* Empty state mobile */
  .mobile-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--bg2);
    border-radius: 12px;
    border: 1px solid var(--border);
  }
  
  .mobile-empty-icon {
    font-size: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
  }
  
  .mobile-empty-text {
    color: var(--muted);
    font-size: 13px;
  }
  
  /* Section header mobile */
  .mobile-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
  }
  
  .mobile-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
  }
  
  .mobile-section-count {
    background: var(--accent-dim);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
  }
  
  /* Sticky payment button (bas d'écran) */
  .mobile-sticky-pay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 1rem;
    box-shadow: 0 -4px 12px rgba(15,23,42,.08);
    z-index: 100;
  }
  
  .mobile-sticky-pay .btn {
    width: 100%;
    min-height: 52px;
    font-size: 15px;
    font-weight: 600;
    justify-content: center;
  }
  
  /* Padding bottom pour éviter overlap avec sticky button */
  .has-sticky-pay {
    padding-bottom: 100px !important;
  }
  
  /* Dashboard client mobile */
  .mobile-dashboard-cards {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  
  .mobile-dashboard-card {
    background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
    border-radius: 12px;
    padding: 1.25rem;
    color: white;
    position: relative;
    overflow: hidden;
  }
  
  .mobile-dashboard-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
  }
  
  .mobile-dashboard-card-icon {
    font-size: 32px;
    margin-bottom: 0.5rem;
  }
  
  .mobile-dashboard-card-label {
    font-size: 11px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
  }
  
  .mobile-dashboard-card-value {
    font-size: 28px;
    font-weight: 700;
    position: relative;
    z-index: 1;
  }
  
  /* Paiement Stripe mobile */
  .mobile-payment-summary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
    border-radius: 12px;
    padding: 1.5rem;
    color: white;
    margin-bottom: 1rem;
    text-align: center;
  }
  
  .mobile-payment-summary-label {
    font-size: 11px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
  }
  
  .mobile-payment-summary-amount {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 0.25rem;
  }
  
  .mobile-payment-summary-desc {
    font-size: 12px;
    opacity: 0.9;
  }
  
  /* Tabs mobile */
  .mobile-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }
  
  .mobile-tab {
    flex: 0 0 auto;
    padding: 10px 16px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
  }
  
  .mobile-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  
  /* Cacher les tableaux desktop sur mobile */
  .hide-on-mobile {
    display: none !important;
  }
  
  /* Afficher les cards mobile uniquement sur mobile */
  .show-on-mobile {
    display: block !important;
  }
}

/* Desktop : cacher les éléments mobile-only */
@media (min-width: 769px) {
  .show-on-mobile {
    display: none !important;
  }
  
  .mobile-sticky-pay {
    display: none !important;
  }
}

/* PWA optimizations */
@media (max-width: 768px) {
  /* Safe area pour iPhone avec encoche */
  .page-body {
    padding-top: max(0.875rem, env(safe-area-inset-top));
    padding-bottom: max(0.875rem, env(safe-area-inset-bottom));
    padding-left: max(0.875rem, env(safe-area-inset-left));
    padding-right: max(0.875rem, env(safe-area-inset-right));
  }
  
  .mobile-sticky-pay {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  
  /* Éviter le zoom iOS sur focus input */
  input, select, textarea {
    font-size: 16px !important;
  }
  
  /* Smooth scroll */
  html {
    scroll-behavior: smooth;
  }
  
  /* Pull-to-refresh style */
  body {
    overscroll-behavior-y: contain;
  }
}
