/* ==========================================================================
   WORK ORDER & TECHNICIAN MANAGEMENT SYSTEM - STYLESHEET
   Design Aesthetic: Dark Glassmorphism, Modern Vibrant Palette, Responsive UI
   ========================================================================== */

:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-glow: rgba(14, 165, 233, 0.3);
  --accent: #6366f1;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  --purple: #a855f7;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: radial-gradient(circle at top right, #1e1b4b, #0f172a 60%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 231, 242, 0.05);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Sidebar Layout */
.sidebar {
  width: 260px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}
.brand-title p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-menu {
  padding: 20px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 14px 12px 6px;
  font-weight: 700;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.2), rgba(99, 102, 241, 0.15));
  color: var(--primary);
  border-left: 3px solid var(--primary);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.nav-btn i {
  font-size: 1.1rem;
}

.user-profile-widget {
  padding: 16px;
  margin: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
}

.user-info p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 70px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 15px var(--success-glow);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--success-glow);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 4px 15px var(--warning-glow);
}
.btn-warning:hover {
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* App View Containers */
.app-content {
  padding: 32px;
  flex: 1;
}

.view-panel {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-glow);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.kpi-card.warning::before { background: var(--warning); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.purple::before { background: var(--purple); }

.kpi-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--primary);
}

.kpi-info h3 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.kpi-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Work Order Cards Grid */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.wo-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: var(--transition);
  position: relative;
}

.wo-card:hover {
  border-color: rgba(14, 165, 233, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.wo-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-assigned { background: rgba(14, 165, 233, 0.15); color: var(--primary); border: 1px solid var(--primary); }
.badge-in_progress { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid var(--warning); }
.badge-waiting_part { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid var(--danger); }
.badge-completed { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid var(--success); }

.wo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.wo-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.sap-number {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.wo-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.wo-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 10px;
}

.wo-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wo-photo-preview {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wo-photo-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s;
}

.wo-photo-preview img:hover {
  transform: scale(1.1);
}

.wo-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.live-timer {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--warning);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tables Styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.custom-table th {
  background: rgba(15, 23, 42, 0.9);
  padding: 16px 20px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.custom-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-container {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}
.close-modal:hover { color: var(--danger); }

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

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

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.5);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 0.85rem;
}

.file-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(15, 23, 42, 0.4);
}

.file-dropzone:hover {
  border-color: var(--primary);
  background: rgba(14, 165, 233, 0.05);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Shopping Cart Badge & Modal */
.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Role Switch Banner */
.role-banner {
  background: linear-gradient(90deg, #4f46e5, #0ea5e9);
  padding: 8px 16px;
  font-size: 0.8rem;
  text-align: center;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Strict Technician Mode - Hides all SPV Sidebar & Admin Controls */
body.technician-mode .sidebar {
  display: none !important;
}

body.technician-mode .main-wrapper {
  margin-left: 0 !important;
  width: 100% !important;
}

body.technician-mode .spv-only {
  display: none !important;
}

body.technician-mode .topbar {
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 2px solid var(--primary);
}

/* Mobile Responsive Optimization (Smartphone HP View) */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-header {
    padding: 12px 16px;
  }

  .sidebar-menu {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  .menu-section {
    display: none !important;
  }

  .nav-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .user-profile-widget {
    display: none;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    padding: 0 16px;
    height: 56px;
  }

  .topbar-title h1 {
    font-size: 1rem;
  }

  .app-content {
    padding: 16px 12px;
  }

  .wo-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .wo-card {
    padding: 16px;
    border-radius: 12px;
  }

  .modal-container {
    width: 95%;
    max-height: 92vh;
    border-radius: 14px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
  }

  .btn {
    padding: 12px 16px;
    font-size: 0.92rem;
  }

  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 16px;
  }

  .file-dropzone {
    padding: 18px 12px;
  }
}
