/* =============================================================
   TechCare CRM — Main Stylesheet
   ============================================================= */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 0px;
  --topbar-height: 58px;
  --primary: #1a3c5e;
  --primary-light: #2563a8;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --sidebar-bg: #0f2540;
  --sidebar-text: #c8d8e8;
  --sidebar-active-bg: rgba(255,255,255,0.12);
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --card-shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

/* Dark mode variables */
[data-bs-theme="dark"] {
  --bs-body-bg: #0d1117;
  --bs-body-color: #e6edf3;
  --bs-card-bg: #161b22;
  --bs-border-color: #30363d;
}

/* -------------------------------------------------------
   Base
------------------------------------------------------- */
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; }

/* -------------------------------------------------------
   Auth Layout
------------------------------------------------------- */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2540 0%, #1a3c5e 50%, #2563a8 100%);
  display: flex; align-items: center; justify-content: center;
}
.auth-wrapper { width: 100%; padding: 20px; }
.auth-card {
  background: #fff; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px 36px; max-width: 420px; margin: auto;
}
[data-bs-theme="dark"] .auth-card { background: #161b22; }
.auth-logo { text-align: center; margin-bottom: 28px; }

/* -------------------------------------------------------
   Top Navbar
------------------------------------------------------- */
.top-navbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e9f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  z-index: 1040;
}
[data-bs-theme="dark"] .top-navbar { background: #161b22; border-color: #30363d; }
.sidebar-toggler { color: #64748b; padding: 4px 8px; }
.sidebar-toggler:hover { color: var(--primary-light); }
.navbar-logo { height: 42px; width: auto; object-fit: contain; }
.avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-light); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}

/* -------------------------------------------------------
   Sidebar
------------------------------------------------------- */
.wrapper { display: flex; padding-top: var(--topbar-height); min-height: 100vh; }

#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed; top: var(--topbar-height); left: 0;
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto; overflow-x: hidden;
  transition: width .25s ease, transform .25s ease;
  z-index: 1030;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

#sidebar .sidebar-inner { width: var(--sidebar-width); padding: 8px 0 24px; }

.sidebar-logo-area {
  text-align: center; padding: 20px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
}
.sidebar-logo-img { height: 48px; width: auto; object-fit: contain; }
.sidebar-tagline { color: rgba(200,216,232,.55); font-size: 10px; letter-spacing: .5px; margin: 6px 0 0; }

#sidebar .nav-link {
  color: var(--sidebar-text); padding: 9px 20px; border-radius: 0;
  font-size: 13.5px; display: flex; align-items: center;
  white-space: nowrap; transition: background .15s;
}
#sidebar .nav-link:hover  { background: var(--sidebar-hover-bg); color: #fff; }
#sidebar .nav-link.active { background: var(--sidebar-active-bg); color: #fff; border-left: 3px solid var(--accent); }
#sidebar .nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(200,216,232,.45); padding: 16px 20px 6px; pointer-events: none;
}

/* Collapsed sidebar */
body.sidebar-collapsed #sidebar { width: 0; }
body.sidebar-collapsed .main-content { margin-left: 0; }

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1; transition: margin-left .25s ease;
  min-width: 0;
}
.page-content { padding: 24px; }

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1025;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 991px) {
  #sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  #sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* -------------------------------------------------------
   Page Header
------------------------------------------------------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--primary); margin: 0; }
[data-bs-theme="dark"] .page-title { color: #e6edf3; }

/* -------------------------------------------------------
   KPI Cards
------------------------------------------------------- */
.kpi-card {
  border: none; border-radius: 12px; box-shadow: var(--card-shadow);
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.kpi-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.kpi-icon.bg-primary-soft { background: rgba(37,99,168,.12); color: #2563a8; }
.kpi-icon.bg-success-soft { background: rgba(22,163,74,.12);  color: #16a34a; }
.kpi-icon.bg-warning-soft { background: rgba(217,119,6,.12);  color: #d97706; }
.kpi-icon.bg-danger-soft  { background: rgba(220,38,38,.12);  color: #dc2626; }
.kpi-icon.bg-info-soft    { background: rgba(14,165,233,.12); color: #0ea5e9; }
.kpi-icon.bg-purple-soft  { background: rgba(139,92,246,.12); color: #8b5cf6; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-label { font-size: 12px; color: #64748b; margin-top: 2px; }

/* -------------------------------------------------------
   Tables
------------------------------------------------------- */
.table-card { border: none; border-radius: 12px; box-shadow: var(--card-shadow); overflow: hidden; }
.table-card .card-header {
  background: #fff; border-bottom: 1px solid #f0f4f8; padding: 14px 20px;
  font-weight: 600; font-size: 14px;
}
[data-bs-theme="dark"] .table-card .card-header { background: #161b22; border-color: #30363d; }

.table > :not(caption) > * > * { padding: 10px 14px; vertical-align: middle; }
.table thead th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #64748b; background: #f8fafc; border-bottom: 2px solid #e5e9f0; }
[data-bs-theme="dark"] .table thead th { background: #0d1117; border-color: #30363d; }

/* -------------------------------------------------------
   Status Badges
------------------------------------------------------- */
.badge-active         { background: #dcfce7; color: #16a34a; }
.badge-expired        { background: #fee2e2; color: #dc2626; }
.badge-pending        { background: #fef9c3; color: #854d0e; }
.badge-expiring-soon  { background: #ffedd5; color: #c2410c; }
.badge-draft          { background: #f0f4f8; color: #475569; }
.badge-sent           { background: #e0f2fe; color: #0369a1; }
.badge-approved       { background: #dcfce7; color: #16a34a; }
.badge-rejected       { background: #fee2e2; color: #dc2626; }

/* Row coloring for expiry */
.row-expired      { background: rgba(220,38,38,.06) !important; }
.row-expiring-soon{ background: rgba(217,119,6,.06) !important; }

/* -------------------------------------------------------
   Forms
------------------------------------------------------- */
.form-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
[data-bs-theme="dark"] .form-label { color: #9ca3af; }
.form-control, .form-select { font-size: 13.5px; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }

/* -------------------------------------------------------
   Customer Profile
------------------------------------------------------- */
.profile-header { background: linear-gradient(135deg, #0f2540, #1a3c5e); color: #fff; border-radius: 14px; padding: 28px; margin-bottom: 24px; }
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex;
  align-items: center; justify-content: center; font-size: 32px;
}

/* -------------------------------------------------------
   Quotation Print
------------------------------------------------------- */
@media print {
  .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .top-navbar, #sidebar { display: none !important; }
  body { padding: 0 !important; }
}

/* -------------------------------------------------------
   Chart containers
------------------------------------------------------- */
.chart-container { position: relative; height: 260px; }

/* -------------------------------------------------------
   Utilities
------------------------------------------------------- */
.cursor-pointer { cursor: pointer; }
.btn-action { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Days remaining pills */
.days-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.days-pill.expired      { background: #fee2e2; color: #dc2626; }
.days-pill.critical     { background: #ffedd5; color: #c2410c; }
.days-pill.warning      { background: #fef9c3; color: #854d0e; }
.days-pill.safe         { background: #dcfce7; color: #16a34a; }

/* -------------------------------------------------------
   Animations
------------------------------------------------------- */
@keyframes fadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }
.page-content { animation: fadeIn .25s ease; }
