/* AutoWash Pro - Core Design System & Styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #0f172a;
  
  --border-color: #334155;
  --border-highlight: #475569;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subdued: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Outfit', sans-serif;
}

/* App Header & Topbar */
.topbar {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-tag {
  font-size: 0.65rem;
  background: rgba(59, 130, 246, 0.2);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-left: 6px;
}

/* Role Selector Badge & Controls */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.role-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.role-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 36px;
  touch-action: manipulation;
}

.role-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-highlight);
}

.role-btn.superadmin-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(239, 68, 68, 0.3));
  color: #d8b4fe;
  border: 1px solid #a855f7;
}

.auth-badge {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
/* Mobile Menu Overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6);
  z-index: 998;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

/* App Layout & Navigation Tabs */
.app-container {
  display: flex;
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.sidebar {
  width: 240px;
  background: rgba(15, 23, 42, 0.95);
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  touch-action: manipulation;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.3);
  font-weight: 600;
}

.nav-item.superadmin-nav {
  background: rgba(139, 92, 246, 0.1);
  color: #c084fc;
  border: 1px dotted #a855f7;
}

.nav-item.superadmin-nav.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(236, 72, 153, 0.25));
  color: #e9d5ff;
  border: 1px solid #a855f7;
}

.main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

/* Common Section Layout */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* UI Cards & Grids */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
}

.stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.icon-blue { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.icon-green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.icon-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.icon-red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  min-height: 38px;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-purple {
  background: var(--purple);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.775rem;
  min-height: 32px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  width: 100%;
}

.input-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* OCR Camera & Scanner Widget */
.ocr-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.ocr-viewport {
  width: 100%;
  max-width: 480px;
  height: 240px;
  margin: 0 auto 1.25rem;
  background: #000;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--primary);
}

.ocr-scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 15px var(--cyan);
  animation: scan 2s infinite linear;
}

@keyframes scan {
  0% { top: 0; }
  50% { top: 100%; }
  100% { top: 0; }
}

.plate-overlay-box {
  width: 220px;
  height: 70px;
  border: 2px solid var(--success);
  border-radius: 8px;
  box-shadow: 0 0 15px var(--success-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 2px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.plate-badge-mercosul {
  background: #012169;
  color: white;
  border: 2px solid white;
  padding: 6px 16px;
  border-radius: 6px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.plate-flag {
  font-size: 0.55rem;
  letter-spacing: 1px;
  margin-bottom: 2px;
  color: #ffd700;
}

/* Kanban Board & OS Status Cards */
.kanban-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.kanban-col {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s ease;
}

.kanban-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.kanban-count {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.os-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: var(--transition);
  position: relative;
  user-select: none;
  touch-action: pan-y;
}

.os-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.os-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.os-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--primary); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.2); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

.os-vehicle {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vehicle-name {
  font-weight: 700;
  font-size: 1rem;
}

.os-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--success);
}

/* WhatsApp Simulator Modal & Widget */
.whatsapp-phone-mockup {
  width: 100%;
  max-width: 360px;
  height: 520px;
  background: #0b141a;
  border: 12px solid #1f2c34;
  border-radius: 36px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

.wa-header {
  background: #202c33;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #e9edef;
  border-bottom: 1px solid #2a3942;
}

.wa-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
}

.wa-chat-body {
  flex: 1;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
}

.wa-msg-bubble {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.825rem;
  line-height: 1.4;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.wa-msg-sent {
  background: #005c4b;
  color: #e9edef;
  align-self: flex-end;
  border-top-right-radius: 0;
}

.wa-msg-time {
  font-size: 0.65rem;
  color: #8696a0;
  text-align: right;
  margin-top: 4px;
}

/* Thermal Printer Receipt Modal */
.thermal-receipt {
  width: 300px;
  background: #fff;
  color: #000;
  padding: 1.5rem 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  border-radius: 4px;
  margin: 0 auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  line-height: 1.3;
}

.receipt-header {
  text-align: center;
  border-bottom: 1px dashed #000;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.receipt-title {
  font-size: 1.1rem;
  font-weight: bold;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  margin: 0.25rem 0;
}

.receipt-divider {
  border-bottom: 1px dashed #000;
  margin: 0.5rem 0;
}

/* Superadmin Analytical Dashboard Components */
.superadmin-banner {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.15));
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.audit-table th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.audit-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.audit-table tr:hover {
  background: var(--bg-card-hover);
}

/* Modal Overlay System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-x: hidden;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-xl);
  width: 92%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px 8px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

/* Progress bar */
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.fill-success { background: var(--success); }
.fill-warning { background: var(--warning); }
.fill-danger { background: var(--danger); }

/* Responsive adjustments */
@media (max-width: 900px) {
  .mobile-menu-btn {
    display: block;
  }

  .mobile-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    flex-direction: column;
    z-index: 999;
    transition: left 0.3s ease;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    overflow-y: auto;
  }

  .sidebar.sidebar-open {
    left: 0;
  }
  
  .nav-item {
    font-size: 1rem;
    padding: 1rem;
  }
  
  .topbar {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }
  
  .topbar-actions {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .modal-container {
    padding: 1.15rem;
    width: 95%;
    max-height: 85vh;
  }

  .main-content {
    padding: 1rem;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  .printable-area, .printable-area * {
    visibility: visible;
  }
  .printable-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}
