/* =============================================
   CASHITO OMS — Complete Stylesheet
   Brand: Orange #F5A623 + Charcoal #1A1A2E
   ============================================= */

:root {
  --brand-orange: #F5A623;
  --brand-orange-dark: #E09415;
  --brand-charcoal: #1A1A2E;
  --brand-charcoal-light: #2D2D44;
  --color-primary: #F5A623;
  --color-primary-hover: #E09415;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-info: #3B82F6;
  --color-purple: #8B5CF6;
  --color-gray: #6B7280;
  --color-bg: #F3F4F6;
  --color-surface: #FFFFFF;
  --color-border: #E5E7EB;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-divider: #E5E7EB;
  --color-surface-offset: #F9FAFB;
  --sidebar-width: 240px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 180ms cubic-bezier(0.16,1,0.3,1);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px;
  --text-xs: clamp(0.7rem,0.65rem + 0.25vw,0.8rem);
  --text-sm: clamp(0.8rem,0.75rem + 0.25vw,0.875rem);
  --text-base: clamp(0.875rem,0.8rem + 0.25vw,1rem);
  --text-lg: clamp(1rem,0.9rem + 0.5vw,1.125rem);
  --text-xl: clamp(1.125rem,1rem + 0.75vw,1.375rem);
  --text-2xl: clamp(1.25rem,1.1rem + 1vw,1.75rem);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font-body); font-size: var(--text-base); color: var(--color-text); background: var(--color-bg); line-height: 1.6; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
input, select, textarea, button { color: inherit; }

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--brand-charcoal);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
  gap: var(--space-4);
}
.topbar-left { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.page-title { font-size: var(--text-xl); font-weight: 700; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-content { padding: var(--space-6); flex: 1; }

/* ============ SIDEBAR ============ */
.sidebar-logo {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 140px;
  height: auto;
  object-fit: contain;
}
.sidebar-logo-fallback {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--brand-orange);
  letter-spacing: -0.5px;
}
.sidebar-nav { flex: 1; padding: var(--space-4) 0; }
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: var(--space-4) var(--space-4) var(--space-2);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: rgba(255,255,255,0.7);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.06); text-decoration: none; }
.nav-item.active { color: var(--brand-orange); background: rgba(245,166,35,0.1); border-left-color: var(--brand-orange); }
.nav-item i { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.sidebar-avatar {
  width: 36px; height: 36px;
  background: var(--brand-orange);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--text-sm); color: var(--brand-charcoal);
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: var(--text-sm); font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: var(--text-xs); color: rgba(255,255,255,0.45); text-transform: capitalize; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600; border: 2px solid transparent;
  transition: all var(--transition); white-space: nowrap; line-height: 1.4;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-orange); color: var(--brand-charcoal); border-color: var(--brand-orange); }
.btn-primary:hover { background: var(--brand-orange-dark); border-color: var(--brand-orange-dark); }
.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }
.btn-warning { background: var(--color-warning); color: #fff; border-color: var(--color-warning); }
.btn-warning:hover { background: #D97706; border-color: #D97706; }
.btn-info { background: var(--color-info); color: #fff; border-color: var(--color-info); }
.btn-info:hover { background: #2563EB; border-color: #2563EB; }
.btn-outline { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-bg); border-color: var(--color-text-muted); }
.btn-ghost { background: transparent; color: var(--color-text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }
.w-100 { width: 100%; }

/* ============ CARDS ============ */
.card { background: var(--color-surface); border-radius: var(--radius-lg); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); gap: var(--space-3); flex-wrap: wrap; }
.card-title { font-size: var(--text-base); font-weight: 700; color: var(--color-text); display: flex; align-items: center; gap: var(--space-2); }
.card-body { padding: var(--space-5); }

/* ============ STAT CARDS ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--space-2);
  position: relative; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-orange::before { background: var(--brand-orange); }
.stat-green::before { background: var(--color-success); }
.stat-yellow::before { background: var(--color-warning); }
.stat-blue::before { background: var(--color-info); }
.stat-red::before { background: var(--color-danger); }
.stat-gray::before { background: var(--color-gray); }
.stat-purple::before { background: var(--color-purple); }
.stat-card-icon { font-size: 1.25rem; }
.stat-orange .stat-card-icon { color: var(--brand-orange); }
.stat-green .stat-card-icon { color: var(--color-success); }
.stat-yellow .stat-card-icon { color: var(--color-warning); }
.stat-blue .stat-card-icon { color: var(--color-info); }
.stat-red .stat-card-icon { color: var(--color-danger); }
.stat-gray .stat-card-icon { color: var(--color-gray); }
.stat-purple .stat-card-icon { color: var(--color-purple); }
.stat-card-value { font-size: var(--text-2xl); font-weight: 800; color: var(--color-text); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-card-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; }

/* ============ FORMS ============ */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.form-label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); display: flex; align-items: center; gap: var(--space-1); }
.form-control {
  padding: var(--space-2) var(--space-3); border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md); font-size: var(--text-sm); background: var(--color-surface);
  color: var(--color-text); transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%; line-height: 1.5;
}
.form-control:focus { outline: none; border-color: var(--brand-orange); box-shadow: 0 0 0 3px rgba(245,166,35,0.15); }
.form-control::placeholder { color: var(--color-text-muted); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-check-input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--brand-orange); }
.form-text { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; border-left: none; }
.required-star { color: var(--color-danger); margin-left: 2px; }

/* ============ TABLES ============ */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th { background: #F9FAFB; color: var(--color-text-muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px; padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-divider); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FAFAFA; }
.check-col { width: 40px; }
.actions { display: flex; gap: var(--space-1); flex-wrap: nowrap; }

/* ============ BADGES ============ */
.badge { display: inline-flex; align-items: center; padding: 2px var(--space-2); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.badge-new { background: #EFF6FF; color: #1D4ED8; }
.badge-called { background: #FFFBEB; color: #92400E; }
.badge-not_answered { background: #F3F4F6; color: #374151; }
.badge-price_negotiation { background: #F5F3FF; color: #6D28D9; }
.badge-booked { background: #EDE9FE; color: #5B21B6; }
.badge-picked_paid { background: #ECFDF5; color: #065F46; }
.badge-cancelled { background: #FEF2F2; color: #991B1B; }
.retry-badge { background: #FFF3CD; color: #856404; font-size: var(--text-xs); padding: 2px var(--space-2); border-radius: var(--radius-full); font-weight: 600; }

/* ============ ALERTS ============ */
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); display: flex; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-4); }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ============ MODALS ============ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: var(--space-4); backdrop-filter: blur(2px); }
.modal-overlay.active { display: flex; }
.modal { background: var(--color-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; animation: modalIn 0.2s ease; overflow: hidden; }
.modal-lg { max-width: 760px; }
@keyframes modalIn { from { opacity:0; transform:translateY(-12px) scale(0.97); } to { opacity:1; transform:none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--color-border); flex-shrink: 0; gap: var(--space-3); }
.modal-title { font-size: var(--text-lg); font-weight: 700; color: var(--color-text); display: flex; align-items: center; gap: var(--space-2); }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); background: none; border: none; transition: all var(--transition); flex-shrink: 0; }
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body { padding: var(--space-6); overflow-y: auto; flex: 1; }
.modal-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); display: flex; gap: var(--space-3); justify-content: flex-end; flex-shrink: 0; }

/* ============ TOASTS ============ */
.toast-container { position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 9999; display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; display: flex; align-items: center; gap: var(--space-2); box-shadow: var(--shadow-lg); pointer-events: auto; animation: toastIn 0.3s ease; max-width: 360px; }
@keyframes toastIn { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:none; } }
.toast-success { background: #065F46; color: #fff; }
.toast-error { background: #991B1B; color: #fff; }
.toast-warning { background: #92400E; color: #fff; }
.toast-info { background: #1E40AF; color: #fff; }

/* ============ LOGIN PAGE ============ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--brand-charcoal) 0%, var(--brand-charcoal-light) 50%, #1a1a2e 100%);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  width: 100%; max-width: 440px;
  overflow: hidden;
}
.login-header {
  background: var(--brand-charcoal);
  padding: var(--space-8) var(--space-8) var(--space-6);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
}
.login-logo { display: flex; align-items: center; justify-content: center; }
.login-logo img { width: 180px; height: auto; }
.login-logo-fallback {
  font-size: var(--text-2xl); font-weight: 800; color: var(--brand-orange); letter-spacing: -1px;
}
.login-subtitle { font-size: var(--text-xs); color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }
.login-body { padding: var(--space-6) var(--space-8) var(--space-8); }
.login-title { font-size: var(--text-xl); font-weight: 800; color: var(--color-text); margin-bottom: var(--space-5); text-align: center; }

/* ============ VENDOR ORDER CARDS ============ */
.order-card { background: var(--color-surface); border-radius: var(--radius-lg); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow var(--transition); display: flex; flex-direction: column; }
.order-card:hover { box-shadow: var(--shadow-md); }
.order-card-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); background: #F9FAFB; border-bottom: 1px solid var(--color-border); }
.order-card-body { padding: var(--space-4); flex: 1; }
.order-card-footer { padding: var(--space-3) var(--space-4); background: #F9FAFB; border-top: 1px solid var(--color-border); display: flex; flex-wrap: wrap; gap: var(--space-2); }
.call-link { font-weight: 700; font-size: var(--text-base); color: var(--color-info); display: inline-flex; align-items: center; gap: var(--space-1); }
.call-link:hover { color: #2563EB; text-decoration: none; }
.price-value { font-size: var(--text-xl); font-weight: 800; color: var(--color-success); white-space: nowrap; }
.price-negotiation-box { background: #F5F3FF; border: 1px solid #DDD6FE; border-radius: var(--radius-md); padding: var(--space-3); margin-top: var(--space-3); }
.price-row { display: flex; justify-content: space-between; align-items: center; font-size: var(--text-sm); margin-bottom: var(--space-1); }
.price-row:last-child { margin-bottom: 0; }
.price-label { color: var(--color-text-muted); }
.price-final { color: var(--color-success); font-weight: 700; font-size: var(--text-base); }
.order-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-4); margin-top: var(--space-3); }
.order-meta-item { display: flex; flex-direction: column; gap: 2px; }
.order-meta-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.order-meta-value { font-size: var(--text-sm); color: var(--color-text); font-weight: 500; }
.wa-btn { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-3); background: #25D366; color: #fff; border-radius: var(--radius-md); font-size: var(--text-xs); font-weight: 600; text-decoration: none; transition: background var(--transition); }
.wa-btn:hover { background: #128C7E; text-decoration: none; color: #fff; }
.priority-badge { font-size: var(--text-sm); font-weight: 700; }
.priority-high { color: var(--color-danger); }
.priority-mid { color: var(--color-warning); }
.priority-low { color: var(--color-info); }
.vendor-section-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); background: var(--color-surface); border-radius: var(--radius-md); border: 1px solid var(--color-border); margin-bottom: var(--space-3); }
.collapsible-content { display: none; }
.collapsible-content.open { display: block; }
.call-log-item { padding: var(--space-3); border-radius: var(--radius-md); border-left: 3px solid var(--color-border); background: var(--color-bg); margin-bottom: var(--space-2); }
.call-log-item.connected { border-left-color: var(--color-success); }
.call-log-item.not_answered { border-left-color: var(--color-warning); }
.call-log-item.cancelled { border-left-color: var(--color-danger); }

/* ============ CHARTS ============ */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.chart-container { position: relative; height: 260px; }

/* ============ PAGE TABS ============ */
.page-tabs { display: flex; gap: 0; background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-1); box-shadow: var(--shadow-sm); border: 1px solid var(--color-border); width: fit-content; flex-wrap: wrap; }
.page-tab { padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); transition: all var(--transition); display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.page-tab.active { background: var(--brand-charcoal); color: var(--brand-orange); font-weight: 700; }
.page-tab:hover:not(.active) { color: var(--color-text); background: var(--color-bg); text-decoration: none; }

/* ============ FILTERS BAR ============ */
.filters-bar { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--space-4); padding: var(--space-4); background: var(--color-bg); border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.filters-bar .form-control { width: auto; min-width: 160px; }

/* ============ BULK BAR ============ */
.bulk-bar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--radius-md); margin-bottom: var(--space-3); flex-wrap: wrap; }

/* ============ UTILITY ============ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.fw-bold { font-weight: 700; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--space-4); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .charts-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .main-content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
  .login-body { padding: var(--space-5); }
  .modal { max-width: 100%; }
  .page-tabs { width: 100%; }
  .page-tab { flex: 1; justify-content: center; font-size: var(--text-xs); padding: var(--space-2); }
  .topbar-left .page-title { font-size: var(--text-base); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .order-meta { grid-template-columns: 1fr; }
}


/* Add these to your existing style.css */

/* ============ IMPROVED RESPONSIVE FIXES ============ */

/* Better sidebar behavior */
@media (max-width: 768px) {
  .app-layout {
    position: relative;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    background: var(--brand-charcoal);
    box-shadow: var(--shadow-lg);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Overlay when sidebar is open */
  .sidebar.open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }
  
  .main-area {
    margin-left: 0 !important;
    width: 100%;
  }
  
  .topbar {
    position: sticky;
    top: 0;
    z-index: 99;
    background: var(--color-surface);
    padding: 0 var(--space-3);
  }
  
  .topbar-left {
    flex: 1;
    min-width: 0;
  }
  
  .page-title {
    font-size: var(--text-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }
  
  #sidebarToggle {
    display: flex !important;
    background: transparent;
    border: none;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
  }
  
  #sidebarToggle:hover {
    background: var(--color-bg);
  }
  
  .main-content {
    padding: var(--space-3);
  }
  
  /* Stats grid - 2 columns on tablet, 1 on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
  
  /* Charts stack vertically */
  .charts-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  
  .chart-container {
    height: 220px;
  }
  
  /* Cards */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .card-header .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Tables - ensure horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1px;
  }
  
  .data-table {
    min-width: 650px;
  }
  
  .data-table th,
  .data-table td {
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
  }
  
  /* Filters bar */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filters-bar .form-control,
  .filters-bar .btn {
    width: 100%;
  }
  
  /* Page tabs - horizontal scroll on mobile */
  .page-tabs {
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-1);
  }
  
  .page-tab {
    flex: 0 0 auto;
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
  }
  
  /* Bulk bar */
  .bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .bulk-bar select,
  .bulk-bar button {
    width: 100%;
  }
  
  /* Vendor cards */
  .order-card-footer {
    flex-wrap: wrap;
  }
  
  .order-card-footer .btn,
  .order-card-footer .wa-btn {
    flex: 1 0 auto;
    font-size: var(--text-xs);
  }
  
  /* Order meta grid */
  .order-meta {
    grid-template-columns: 1fr;
  }
  
  /* Modals */
  .modal {
    max-width: calc(100% - var(--space-4));
    max-height: calc(100vh - var(--space-4));
  }
  
  .modal-body {
    padding: var(--space-4);
  }
  
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
  
  /* Grid layouts */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  /* Sidebar navigation */
  .sidebar-nav {
    padding: var(--space-2) 0;
  }
  
  .nav-item {
    padding: var(--space-2) var(--space-4);
  }
  
  .sidebar-footer {
    margin-top: auto;
  }
  
  /* Vendor sections */
  .vendor-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  
  /* Action buttons in tables */
  .actions {
    flex-wrap: wrap;
  }
  
  .actions .btn {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
  }
}

/* Extra small devices (phones, 480px and down) */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .topbar-right .text-muted {
    display: none;
  }
  
  .page-title {
    max-width: 140px;
    font-size: var(--text-sm);
  }
  
  .badge {
    font-size: 10px;
    padding: 1px var(--space-1);
  }
  
  .price-value {
    font-size: var(--text-base);
  }
  
  .order-card-footer .btn,
  .order-card-footer .wa-btn {
    font-size: 10px;
    padding: var(--space-1) var(--space-2);
  }
  
  .alert {
    font-size: var(--text-xs);
    padding: var(--space-2);
  }
  
  .login-card {
    margin: var(--space-3);
  }
  
  .login-header {
    padding: var(--space-5);
  }
  
  .login-body {
    padding: var(--space-4);
  }
}

/* Tablet landscape (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .charts-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .main-content {
    padding: var(--space-4);
  }
  
  .data-table {
    min-width: auto;
  }
}

/* Ensure proper sidebar toggle button visibility */
#sidebarToggle {
  display: none;
}

/* Fix for stat card animations */
.stat-card-value {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Improve touch targets on mobile */
@media (max-width: 768px) {
  button, 
  .btn, 
  .nav-item, 
  .page-tab,
  .modal-close,
  [onclick] {
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .btn-sm {
    min-height: 36px;
  }
  
  input, 
  select, 
  textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
}

/* Fix for modal backdrop */
.modal-overlay {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Ensure proper stacking context */
.sidebar {
  z-index: 1000;
}

.topbar {
  z-index: 99;
}

/* Fix for price negotiation box */
.price-negotiation-box {
  overflow-x: auto;
}

/* Ensure images are responsive */
.sidebar-logo img {
  max-width: 100%;
  height: auto;
}

/* Fix for order cards grid on different screen sizes */
@media (min-width: 1200px) {
  [style*="grid-template-columns:repeat(auto-fill,minmax(320px,1fr))"] {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)) !important;
  }
}

@media (max-width: 768px) {
  [style*="grid-template-columns:repeat(auto-fill,minmax(320px,1fr))"] {
    grid-template-columns: 1fr !important;
  }
}

/* Purple button for admin price approval */
.btn-purple {
  background: var(--color-purple);
  color: #fff;
  border-color: var(--color-purple);
}
.btn-purple:hover {
  background: #7C3AED;
  border-color: #7C3AED;
}

/* Ensure buttons are visible at all zoom levels */
@media (max-width: 768px) {
  .order-card-footer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-2);
  }
  
  .order-card-footer .btn,
  .order-card-footer .wa-btn {
    width: 100%;
    font-size: 11px;
    padding: var(--space-2) var(--space-2);
    white-space: normal;
    word-break: keep-all;
  }
  
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
  }
  
  .actions .btn {
    padding: var(--space-1) var(--space-2);
    font-size: 10px;
  }
  
  /* Make table more compact */
  .data-table th,
  .data-table td {
    padding: var(--space-2) var(--space-2);
    font-size: 11px;
  }
  
  /* Stats cards more compact */
  .stat-card {
    padding: var(--space-2) var(--space-3);
  }
  
  .stat-card-value {
    font-size: var(--text-lg);
  }
  
  /* Filter bar better spacing */
  .filters-bar {
    gap: var(--space-2);
  }
  
  .filters-bar .form-control,
  .filters-bar .btn {
    font-size: 12px;
    padding: var(--space-1) var(--space-2);
  }
}

/* For very small screens (320px) */
@media (max-width: 380px) {
  .order-card-footer {
    grid-template-columns: 1fr 1fr;
  }
  
  .topbar-left .page-title {
    font-size: 14px;
    max-width: 120px;
  }
  
  .badge {
    font-size: 9px;
    padding: 1px 6px;
  }
  
  .price-value {
    font-size: 14px;
  }
  
  .call-link {
    font-size: 12px;
  }
}

/* Purple button for admin price approval */
.btn-purple {
  background: #8B5CF6;
  color: #fff;
  border-color: #8B5CF6;
}
.btn-purple:hover {
  background: #7C3AED;
  border-color: #7C3AED;
}

/* Modal responsiveness fixes */
@media (max-width: 768px) {
  .modal {
    max-width: calc(100vw - 20px) !important;
    width: calc(100% - 20px) !important;
    max-height: 85vh !important;
    margin: 10px;
  }
  
  .modal-lg {
    max-width: calc(100vw - 20px) !important;
  }
  
  .modal-body {
    padding: var(--space-3) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-footer {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .modal-footer .btn {
    flex: 1;
    min-width: 100px;
  }
  
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: var(--space-2) !important;
  }
  
  .form-group {
    margin-bottom: var(--space-2);
  }
  
  .form-label {
    font-size: 12px;
  }
  
  .form-control {
    font-size: 14px !important;
    padding: 8px 10px;
  }
}

/* For very small screens */
@media (max-width: 480px) {
  .modal-footer {
    flex-direction: column;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
  
  .modal-header {
    padding: var(--space-3);
  }
  
  .modal-title {
    font-size: var(--text-base);
  }
}

/* Ensure buttons are visible at all zoom levels */
@media (max-width: 768px) {
  .order-card-footer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  
  .order-card-footer .btn,
  .order-card-footer .wa-btn {
    width: 100%;
    font-size: 11px;
    padding: 6px 8px;
    white-space: normal;
    word-break: keep-all;
  }
  
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .actions .btn {
    padding: 4px 8px;
    font-size: 10px;
  }
  
  .data-table th,
  .data-table td {
    padding: 8px 8px;
    font-size: 11px;
  }
  
  .stat-card {
    padding: 8px 12px;
  }
  
  .stat-card-value {
    font-size: 18px;
  }
  
  .filters-bar {
    gap: 8px;
  }
  
  .filters-bar .form-control,
  .filters-bar .btn {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  .page-tab {
    font-size: 11px;
    padding: 6px 10px;
  }
  
  .btn-sm {
    padding: 4px 8px;
    font-size: 10px;
  }
}

@media (max-width: 380px) {
  .order-card-footer {
    grid-template-columns: 1fr 1fr;
  }
  
  .topbar-left .page-title {
    font-size: 14px;
    max-width: 120px;
  }
  
  .badge {
    font-size: 9px;
    padding: 1px 6px;
  }
  
  .price-value {
    font-size: 14px;
  }
  
  .call-link {
    font-size: 12px;
  }
}

/* Date input styling */
input[type="text"][placeholder="DD/MM/YYYY"] {
  font-family: monospace;
  letter-spacing: 0.5px;
}

@media (max-width: 768px) {
  input[placeholder="DD/MM/YYYY"] {
    width: 110px !important;
    font-size: 12px !important;
  }
}

/* Better modal scrolling */
.modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.modal {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Desktop modal width fix */
@media (min-width: 769px) {
  .modal {
    max-width: 600px;
  }
  .modal-lg {
    max-width: 800px;
  }
}

@media (min-width: 769px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}