/**
 * Lubcom Tech Solutions - Staff Administration Suite CSS
 * Human-Crafted, Ultra-Clean Enterprise Design System
 */

:root {
  --admin-sidebar-bg: #0F172A;
  --admin-sidebar-hover: #1E293B;
  --admin-sidebar-active: #0A4D8C;
  --admin-sidebar-text: #94A3B8;
  --admin-sidebar-text-active: #FFFFFF;
  
  --admin-topbar-bg: #FFFFFF;
  --admin-body-bg: #F8FAFC;
  --admin-card-bg: #FFFFFF;
  --admin-border: #E2E8F0;
  
  --admin-primary: #0A4D8C;
  --admin-primary-dark: #073460;
  --admin-primary-light: #E0F2FE;
  --admin-secondary: #0284C7;
  --admin-accent-red: #D32F2F;
  --admin-success: #16A34A;
  --admin-warning: #F59E0B;
  --admin-danger: #DC2626;
  
  --admin-text-main: #0F172A;
  --admin-text-muted: #64748B;
  
  --admin-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --admin-radius: 8px;
  --admin-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --admin-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

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

html {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--admin-font);
  background-color: var(--admin-body-bg);
  color: var(--admin-text-main);
  font-size: 0.9rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* overflow-x: clip preserves position:sticky (unlike hidden which creates a scroll container) */
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  position: relative;
}

/* Layout Wrapper */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1040;
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
}

.sidebar-backdrop.show {
  display: block;
}

/* Sidebar - Fixed Position On Scroll */
.admin-sidebar {
  width: 270px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background-color: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1E293B;
  transition: transform 0.25s ease;
  z-index: 1050;
  overflow: hidden;
}

.admin-sidebar-brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1E293B;
}

.admin-sidebar-brand img {
  height: 38px;
  background: #FFFFFF;
  padding: 3px 6px;
  border-radius: 6px;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--admin-secondary);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* User Profile Badge in Sidebar */
.admin-user-pill {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid #1E293B;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--admin-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  border: 2px solid var(--admin-secondary);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 0.7rem;
  color: #38BDF8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.user-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22C55E;
  display: inline-block;
}

/* Nav Menu */
.admin-nav-container {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #64748B;
  text-transform: uppercase;
  padding: 10px 12px 6px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  transition: all 0.15s ease;
  margin-bottom: 3px;
}

.admin-nav-item:hover {
  background-color: var(--admin-sidebar-hover);
  color: #FFFFFF;
}

.admin-nav-item.active {
  background-color: var(--admin-primary);
  color: #FFFFFF;
  font-weight: 700;
}

.admin-nav-item i {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

.admin-nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  background: #334155;
  color: #F8FAFC;
}

.admin-nav-badge.badge-primary {
  background: var(--admin-secondary);
  color: #FFFFFF;
}

.admin-nav-badge.badge-red {
  background: var(--admin-accent-red);
  color: #FFFFFF;
}

.admin-nav-badge.badge-green {
  background: var(--admin-success);
  color: #FFFFFF;
}

/* Sidebar Footer - Pinned fixed to bottom of sidebar */
.admin-sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 14px 20px;
  background: #0B1120;
  border-top: 1px solid #1E293B;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.admin-sidebar-footer a {
  color: #94A3B8;
  font-size: 0.82rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.admin-sidebar-footer a:hover {
  color: #FFFFFF;
}

/* Main Area - Offset by fixed 270px sidebar */
.admin-main-wrapper {
  margin-left: 270px;
  width: calc(100% - 270px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* Topbar */
.admin-topbar {
  height: 64px;
  background-color: var(--admin-topbar-bg);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--admin-shadow-sm);
}

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

.mobile-toggle-btn {
  display: none;
  background: none;
  border: 1px solid var(--admin-border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 1.1rem;
  color: var(--admin-text-main);
  cursor: pointer;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--admin-text-muted);
}

.topbar-breadcrumb a {
  color: var(--admin-primary);
  text-decoration: none;
  font-weight: 600;
}

.topbar-breadcrumb span.current {
  font-weight: 700;
  color: var(--admin-text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.system-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
  border-radius: 20px;
}

.system-status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22C55E;
}

/* Page Content */
.admin-content-body {
  padding: 28px;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.page-headline h1 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--admin-text-main);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-headline p {
  color: var(--admin-text-muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

.page-actions-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Enterprise Admin Cards */
.admin-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.admin-card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #FAFAFA;
}

.admin-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--admin-text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-card-body {
  padding: 22px;
  min-width: 0;
  max-width: 100%;
}

/* Metric KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 26px;
}

.kpi-card {
  background: #FFFFFF;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--admin-shadow-sm);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  box-shadow: var(--admin-shadow);
  transform: translateY(-2px);
}

.kpi-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.icon-blue { background: #E0F2FE; color: var(--admin-primary); }
.icon-cyan { background: #E0F7FA; color: var(--admin-secondary); }
.icon-green { background: #DCFCE7; color: var(--admin-success); }
.icon-amber { background: #FEF3C7; color: var(--admin-warning); }
.icon-red { background: #FEE2E2; color: var(--admin-accent-red); }
.icon-purple { background: #F3E8FF; color: #7E22CE; }

.kpi-content {
  flex: 1;
}

.kpi-val {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--admin-text-main);
  line-height: 1.1;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.kpi-subtext {
  font-size: 0.74rem;
  color: var(--admin-text-muted);
  margin-top: 2px;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
}

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

.admin-table th {
  background: #F8FAFC;
  padding: 12px 16px;
  font-weight: 700;
  color: #475569;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 2px solid var(--admin-border);
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-text-main);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background-color: #F8FAFC;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-received { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.pill-diagnosis { background: #E0F2FE; color: #075985; border: 1px solid #BAE6FD; }
.pill-repair { background: #EEF2FF; color: #3730A3; border: 1px solid #C7D2FE; }
.pill-ready { background: #CCFBF1; color: #115E59; border: 1px solid #99F6E4; }
.pill-delivered { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.pill-cancelled { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.pill-pending { background: #FFF7ED; color: #9A3412; border: 1px solid #FFEDD5; }
.pill-open { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.pill-closed { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; }

/* Action Buttons */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-admin-primary {
  background-color: var(--admin-primary);
  color: #FFFFFF;
}

.btn-admin-primary:hover {
  background-color: var(--admin-primary-dark);
  color: #FFFFFF;
}

.btn-admin-secondary {
  background-color: var(--admin-secondary);
  color: #FFFFFF;
}

.btn-admin-secondary:hover {
  background-color: #0369A1;
  color: #FFFFFF;
}

.btn-admin-outline {
  background-color: transparent;
  border-color: var(--admin-border);
  color: var(--admin-text-main);
}

.btn-admin-outline:hover {
  background-color: #F1F5F9;
  border-color: #CBD5E1;
}

.btn-admin-whatsapp {
  background-color: #25D366;
  color: #FFFFFF;
  border-color: #22C55E;
}

.btn-admin-whatsapp:hover {
  background-color: #1EBE5D;
  color: #FFFFFF;
}

.btn-admin-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 4px;
}

/* Modal Styling (Scrollable & Responsive on all screens) */
.admin-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(3px);
  z-index: 2500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  box-sizing: border-box;
}

.admin-modal-backdrop.show {
  display: flex;
}

.admin-modal-window {
  background: #FFFFFF;
  border-radius: var(--admin-radius);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--admin-border);
  overflow: hidden;
  position: relative;
  margin: auto;
}

.admin-modal-window > form,
.admin-modal-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  min-height: 0;
  overflow: hidden;
  margin: 0;
  flex: 1 1 auto;
}

.admin-modal-header {
  padding: 14px 22px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F8FAFC;
  flex-shrink: 0;
}

.admin-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--admin-text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #64748B;
  cursor: pointer;
  line-height: 1;
}

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

.admin-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  max-height: calc(100vh - 160px);
  overscroll-behavior: contain;
}

.admin-modal-body::-webkit-scrollbar {
  width: 6px;
}
.admin-modal-body::-webkit-scrollbar-track {
  background: #F1F5F9;
}
.admin-modal-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}
.admin-modal-body::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

.admin-modal-footer {
  padding: 13px 22px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #F8FAFC;
  flex-shrink: 0;
}

/* Form Controls */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group-admin {
  margin-bottom: 16px;
}

.form-label-admin {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.form-control-admin {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.88rem;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  background: #FFFFFF;
  color: var(--admin-text-main);
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-control-admin:focus {
  outline: none;
  border-color: var(--admin-secondary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Alerts */
.admin-alert {
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.admin-alert-success {
  background-color: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

.admin-alert-danger {
  background-color: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Two column admin grids stack cleanly at 1024px */
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1.6fr 1fr"],
  div[style*="grid-template-columns: 1.4fr 1fr"],
  div[style*="grid-template-columns: 320px 1fr"],
  .admin-chat-layout {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }

  .stats-overview-grid,
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform 0.25s ease-in-out;
  }

  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
  }

  .mobile-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

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

  .admin-topbar {
    padding: 0 12px;
    gap: 10px;
    height: 58px;
  }

  .topbar-left {
    gap: 10px;
    min-width: 0;
    flex: 1;
  }

  .topbar-breadcrumb {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
  }

  .topbar-breadcrumb-parent {
    display: none;
  }

  .topbar-right {
    gap: 8px;
    flex-shrink: 0;
  }

  .system-status-pill {
    display: none;
  }

  .topbar-btn-text {
    display: none;
  }

  .admin-content-body {
    padding: 16px 12px;
  }

  .page-header-row {
    margin-bottom: 18px;
    gap: 12px;
  }

  .page-headline h1 {
    font-size: 1.35rem;
  }

  .page-headline p {
    font-size: 0.82rem;
  }

  .page-actions-group {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .kpi-card {
    padding: 14px;
    gap: 14px;
  }

  .kpi-icon-box {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }

  .kpi-val {
    font-size: 1.5rem;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  .stats-overview-grid,
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  .admin-card-header {
    padding: 14px 16px;
  }

  .admin-card-body {
    padding: 16px;
  }

  /* Table responsive styling for mobile */
  .admin-table th,
  .admin-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  /* Filter form responsiveness */
  form[style*="display:flex; gap:8px"],
  form[style*="display:flex; gap:6px"] {
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  form[style*="display:flex; gap:8px"] input[type="text"],
  form[style*="display:flex; gap:6px"] input[type="text"] {
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .admin-content-body {
    padding: 14px 10px;
  }

  .admin-topbar {
    padding: 0 10px;
  }

  .btn-admin {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .admin-modal-window {
    max-width: calc(100vw - 20px);
    margin: 10px;
  }

  .admin-modal-header {
    padding: 12px 16px;
  }

  .admin-modal-body {
    padding: 14px 16px;
  }

  .admin-modal-footer {
    padding: 12px 16px;
  }
}
