/* Pressing Pro — global styles · mobile-first */
:root {
  --brand: #1e3a8a;
  --brand-2: #3b82f6;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11','ss01'; -webkit-font-smoothing: antialiased; }

input, select, textarea, button { font-family: inherit; font-size: 16px; }
@media (min-width: 640px) { input, select, textarea, button { font-size: 14px; } }

/* === BADGES === */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: 3px 10px; border-radius: 9999px;
  font-size: .72rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge-depose { background: #e0e7ff; color: #3730a3; }
.badge-lavage { background: #cffafe; color: #155e75; }
.badge-sechage { background: #fef3c7; color: #92400e; }
.badge-repassage { background: #fae8ff; color: #6b21a8; }
.badge-pret { background: #dcfce7; color: #166534; }
.badge-livre { background: #d1fae5; color: #065f46; }
.badge-annule { background: #fee2e2; color: #991b1b; }
.badge-impaye { background: #fee2e2; color: #991b1b; }
.badge-partiel { background: #fef3c7; color: #92400e; }
.badge-paye { background: #dcfce7; color: #166534; }
.badge-actif { background: #dcfce7; color: #166534; }
.badge-suspendu { background: #fef3c7; color: #92400e; }
.badge-termine { background: #e2e8f0; color: #475569; }
.badge-planifie { background: #dbeafe; color: #1e40af; }
.badge-confirme { background: #ccfbf1; color: #115e59; }

/* === BUTTONS — generous touch targets === */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1rem; border-radius: .55rem; font-weight: 600; font-size: .875rem;
  transition: all .15s ease; cursor: pointer; border: 1px solid transparent;
  min-height: 44px; user-select: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: #1e3a8a; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-secondary { background: #fff; color: #1e3a8a; border-color: #cbd5e1; }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-warning { background: #d97706; color: #fff; }
.btn-ghost { background: transparent; color: #475569; }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; min-height: 34px; }
.btn-block { width: 100%; }

/* === FORMS === */
.input, .select, .textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid #cbd5e1; border-radius: .55rem;
  background: #fff; transition: border-color .15s, box-shadow .15s;
  min-height: 44px;
}
.textarea { min-height: 80px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.label { display: block; font-size: .72rem; font-weight: 700; color: #475569; margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .04em; }
.card { background: #fff; border-radius: .75rem; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03); }

/* === TABLES — desktop look + mobile card mode === */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; padding: .75rem 1rem; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .05em; color: #64748b; font-weight: 700; border-bottom: 1px solid #e2e8f0; background: #f8fafc; white-space: nowrap; }
.table td { padding: .9rem 1rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.table tr:hover { background: #f8fafc; }
.table tr.cursor-pointer:active { background: #eef2ff; }

/* On mobile, make tables card-style by default */
@media (max-width: 640px) {
  .table-responsive thead { display: none; }
  .table-responsive tr { display: block; padding: .85rem 1rem; border-bottom: 1px solid #f1f5f9; }
  .table-responsive td { display: flex; justify-content: space-between; align-items: center;
    padding: .25rem 0; border: none; gap: 1rem; }
  .table-responsive td::before { content: attr(data-label); font-weight: 600; color: #64748b;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0; }
  .table-responsive td.no-label::before { content: ''; }
}

/* === TOASTS — bottom on mobile, top-right on desktop === */
#toast-root { position: fixed; z-index: 60; pointer-events: none;
  left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: .5rem; width: calc(100% - 2rem); max-width: 380px; }
@media (min-width: 1024px) {
  #toast-root { left: auto; right: 1rem; bottom: auto; top: 1rem; transform: none; }
}
.toast { padding: .85rem 1rem; border-radius: .55rem; box-shadow: 0 10px 25px rgba(0,0,0,.15); font-size: .875rem;
  animation: slideIn .25s ease-out; background: #fff; border-left: 4px solid; pointer-events: auto;
  font-weight: 500; }
.toast-success { border-color: #059669; }
.toast-error { border-color: #dc2626; }
.toast-info { border-color: #3b82f6; }
.toast-warning { border-color: #d97706; }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === SKELETON === */
.skeleton { background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: .55rem; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === TIMELINE === */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: .5rem; top: 0; bottom: 0; width: 2px; background: #e2e8f0; }
.timeline-step { position: relative; padding-bottom: 1.25rem; }
.timeline-step::before { content: ''; position: absolute; left: -1.65rem; top: .35rem;
  width: 1rem; height: 1rem; border-radius: 9999px; background: #cbd5e1; border: 3px solid #fff; box-shadow: 0 0 0 1px #cbd5e1; }
.timeline-step.done::before { background: #059669; box-shadow: 0 0 0 1px #059669; }
.timeline-step.current::before { background: #3b82f6; box-shadow: 0 0 0 1px #3b82f6; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 1px #3b82f6, 0 0 0 0 rgba(59,130,246,.5); }
  50% { box-shadow: 0 0 0 1px #3b82f6, 0 0 0 8px rgba(59,130,246,0); } }

/* === SIDEBAR === */
.sidebar { width: 256px; background: #0f172a; color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-link { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem;
  border-radius: .55rem; color: #cbd5e1; font-size: .9rem; transition: all .15s; cursor: pointer;
  width: 100%; background: transparent; border: none; text-align: left; min-height: 44px; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: #3b82f6; color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,.4); }
.sidebar-link svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); z-index: 39; }
@media (max-width: 1023px) {
  .sidebar { position: fixed; height: 100vh; height: 100dvh; z-index: 40;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
}

/* === MOBILE BOTTOM NAV === */
.bottom-nav { display: none; }
@media (max-width: 1023px) {
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed;
    bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #e2e8f0;
    padding-bottom: var(--safe-bottom); z-index: 30; box-shadow: 0 -4px 12px rgba(0,0,0,.04); }
  .bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: .5rem .25rem; color: #64748b; font-size: .68rem; gap: 2px; min-height: 56px; cursor: pointer; }
  .bottom-nav-item.active { color: #1e40af; }
  .bottom-nav-item svg { width: 22px; height: 22px; }
  .bottom-nav-item.fab { transform: translateY(-12px); }
  .bottom-nav-item.fab .icon-wrap { background: #1e3a8a; color: #fff; width: 50px; height: 50px;
    border-radius: 9999px; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(30,58,138,.4); }
  .bottom-nav-item.fab svg { width: 26px; height: 26px; }
  .main-content { padding-bottom: calc(80px + var(--safe-bottom)) !important; }
}

/* === KPI CARDS === */
.kpi-card { padding: 1rem; border-radius: .75rem; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border: 1px solid #f1f5f9; transition: all .15s; }
.kpi-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.07); transform: translateY(-1px); }
.kpi-card .label { margin-bottom: .35rem; }
@media (min-width: 640px) { .kpi-card { padding: 1.25rem; } }

/* === MODAL — full-screen on mobile === */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); z-index: 50; }
.modal { position: fixed; inset: 0; z-index: 51; display: grid; place-items: center; padding: 0; pointer-events: none; }
.modal > .card { pointer-events: auto; max-height: 100dvh; overflow-y: auto; width: 100%;
  border-radius: 0; max-width: none; height: 100dvh; }
@media (min-width: 640px) {
  .modal { padding: 1rem; }
  .modal > .card { border-radius: .75rem; max-height: 92vh; height: auto; max-width: 720px; }
}

/* === BANNERS === */
.offline-banner { background: #d97706; color: #fff; padding: .55rem 1rem; text-align: center;
  font-size: .8rem; font-weight: 600; }

/* === TOPBAR === */
.topbar { position: sticky; top: 0; z-index: 20; }

/* === PRINT === */
.print-only { display: none; }
@media print {
  body { background: #fff !important; }
  .no-print, .sidebar, .topbar, .bottom-nav, header, nav, button, #toast-root { display: none !important; }
  .print-only { display: block !important; }
  .card { box-shadow: none !important; border: none !important; }
  .main-content { padding: 0 !important; }
  @page { margin: 1cm; }
}

/* === Thermal receipt — 80mm === */
.thermal-receipt { width: 80mm; max-width: 100%; padding: 4mm; font-family: 'Courier New', monospace;
  font-size: 12px; color: #000; background: #fff; box-sizing: border-box; }
.thermal-receipt h1 { font-size: 16px; font-weight: bold; }
.thermal-receipt hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
.thermal-receipt table { width: 100%; font-size: 11px; }
.thermal-receipt img { max-width: 100%; }
@media print {
  body[data-print-mode="a4"] .thermal-receipt {
    width: 100%; max-width: 18cm; padding: 1.5cm; font-family: system-ui, sans-serif; font-size: 14px;
  }
  body[data-print-mode="a4"] .thermal-receipt h1 { font-size: 22px; }
  body[data-print-mode="a4"] .thermal-receipt table { font-size: 13px; }
}

/* Prevent overflow on long text */
.text-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.text-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.break-words-all { word-break: break-word; overflow-wrap: anywhere; }
.min-w-0-fix { min-width: 0; }
.no-overflow { max-width: 100%; overflow: hidden; }

/* === HELPERS === */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hide on small */
@media (max-width: 640px) { .sm-hidden { display: none; } }
@media (max-width: 1023px) { .lg-hidden { display: none; } }

/* sticky filter bar */
.sticky-filters { position: sticky; top: 0; z-index: 10; background: #f1f5f9; padding-top: .25rem; }
@media (min-width: 1024px) { .sticky-filters { top: 60px; } }

/* Help bubble */
.help-bubble {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 9999px;
  background: #e2e8f0; color: #475569; font-size: 11px; font-weight: bold;
  cursor: help; margin-left: 4px; user-select: none;
}
.help-bubble:hover { background: #3b82f6; color: #fff; }
.kbd {
  font-family: ui-monospace, monospace; font-size: 11px;
  padding: 2px 6px; border: 1px solid #cbd5e1; border-bottom-width: 2px;
  border-radius: 4px; background: #f8fafc;
}

/* Caisse mobile tabs */
.caisse-mobile-tabs { display: none; }
@media (max-width: 1023px) {
  .caisse-mobile-tabs {
    display: flex; gap: 4px; padding: 4px;
    background: #f1f5f9; border-radius: 12px;
    margin-bottom: 12px;
    position: sticky; top: 60px; z-index: 9;
  }
  .caisse-tab {
    flex: 1; padding: 10px; text-align: center; font-weight: 600;
    border-radius: 8px; cursor: pointer; transition: all .15s;
    background: transparent; border: none; font-size: 14px; color: #64748b;
    position: relative;
  }
  .caisse-tab.active { background: #fff; color: #1e3a8a; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
  .caisse-tab .badge-count {
    position: absolute; top: 4px; right: 4px; background: #dc2626; color: #fff;
    font-size: 10px; padding: 1px 6px; border-radius: 9999px; font-weight: bold;
  }
  /* Hide non-active panel on mobile */
  body[data-caisse-tab="items"] .caisse-cart-panel { display: none; }
  body[data-caisse-tab="cart"] .caisse-items-panel { display: none; }
  body[data-caisse-tab="cart"] .caisse-cart-panel { display: block !important; }
}
@media (min-width: 1024px) {
  body[data-caisse-tab] .caisse-items-panel,
  body[data-caisse-tab] .caisse-cart-panel { display: block; }
}
