/* ============================================================
   Tailor360 CRM — Main Stylesheet
   ============================================================ */

:root {
  --primary:      #1a2e5a;
  --secondary:    #c9a84c;
  --sidebar-bg:   #1a2e5a;
  --sidebar-text: #ffffff;
  --accent-text:  #1a2e5a;
  --sidebar-w:    250px;
  --header-h:     60px;
  --bg:           #f4f6fb;
  --border:       #e2e8f0;
  --text:         #2d3748;
  --muted:        #718096;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ===================== SIDEBAR ===================== */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  overflow-y: auto; overflow-x: hidden;
  transition: width 0.25s ease;
  z-index: 1000;
  scrollbar-width: thin; scrollbar-color: rgba(128,128,128,.3) transparent;
}
#sidebar.collapsed { width: 64px; }
#sidebar.collapsed .brand-text,
#sidebar.collapsed .nav-link span,
#sidebar.collapsed .nav-section { display: none; }
#sidebar.collapsed .nav-link { justify-content: center; padding: 0.75rem; }
#sidebar.collapsed .sidebar-logo { width: 36px; }

.sidebar-brand {
  padding: 1rem;
  border-bottom: 1px solid rgba(128,128,128,.2);
  text-align: center;
}
.sidebar-logo {
  width: 100%;
  max-width: 170px;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}
.sidebar-brand-name {
  color: var(--sidebar-text);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 0.25rem 0;
  word-break: break-word;
}
#sidebar.collapsed .sidebar-brand-name { display: none; }

.sidebar-tenant-name {
  color: var(--sidebar-text);
  opacity: 0.55;
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-top: 0.4rem;
}
#sidebar.collapsed .sidebar-tenant-name { display: none; }
#sidebar.collapsed .sidebar-logo { max-width: 38px; }

.sidebar-nav { padding: 0.5rem 0; list-style: none; margin: 0; }
.nav-section {
  color: var(--sidebar-text);
  opacity: 0.4;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 1rem 1.2rem 0.3rem;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--sidebar-text);
  opacity: 0.82;
  padding: 0.6rem 1.25rem;
  border-radius: 0;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  font-size: 0.875rem;
  text-decoration: none;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: rgba(128,128,128,.15); opacity: 1; }
.sidebar-nav .nav-link.active { background: var(--secondary); color: var(--accent-text); opacity: 1; font-weight: 600; }

/* ===================== MAIN WRAPPER ===================== */
#main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}
#main-wrapper.expanded { margin-left: 64px; }

/* ===================== TOP HEADER ===================== */
.top-header {
  position: sticky; top: 0; z-index: 999;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

/* ===================== PAGE CONTENT ===================== */
.page-content {
  padding: 1.5rem;
  max-width: 1400px;
}

/* ===================== KPI CARDS ===================== */
.kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.kpi-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.bg-primary-soft { background: #e8edf7; color: var(--primary); }
.bg-success-soft { background: #e6f4ea; color: #1e7e34; }
.bg-warning-soft { background: #fff8e1; color: #c87d00; }
.bg-info-soft    { background: #e1f5fe; color: #0277bd; }
.bg-danger-soft  { background: #fdecea; color: #c62828; }

.kpi-value { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* ===================== STATUS CARDS ===================== */
.status-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-left: 4px solid;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

/* ===================== PAGE HEADER ===================== */
.page-header { margin-bottom: 1.5rem; }
.page-header h4 { color: var(--primary); }

/* ===================== TABLES ===================== */
.table thead th { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.table tbody tr:hover { background: #f8faff; }
.table td { vertical-align: middle; }

/* ===================== CARDS ===================== */
.card { border: 1px solid var(--border); border-radius: 10px; }
.card-header { font-size: 0.875rem; }

/* ===================== BREADCRUMB ===================== */
.breadcrumb { font-size: 0.8rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--muted); }

/* ===================== BUTTONS ===================== */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: #152445; border-color: #152445; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); }

/* ===================== BADGES ===================== */
.badge { font-weight: 500; }

/* ===================== FORMS ===================== */
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 0.2rem rgba(26,46,90,.15); }

/* ===================== RESPONSIVE ===================== */
body { overflow-x: hidden; }
#main-wrapper { overflow-x: hidden; }

/* Sidebar hidden on tablets + phones (< 1024px) */
@media (max-width: 1023.98px) {
  #sidebar { width: 0; overflow: hidden; }
  #sidebar.mobile-open { width: var(--sidebar-w); }
  #main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0.75rem; }
  .page-content > * { min-width: 0; }
  .row { --bs-gutter-x: 0.5rem; }
  input, select, textarea { max-width: 100% !important; box-sizing: border-box; }
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }

/* ===================== ORDER PROGRESS STEPPER ===================== */
.step-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: #e2e8f0; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; border: 2px solid #e2e8f0;
  transition: all 0.2s;
}
.step-circle.done   { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-circle.active { background: var(--secondary); color: var(--primary); border-color: var(--secondary); box-shadow: 0 0 0 4px rgba(201,168,76,.2); }
.progress-line {
  position: absolute; top: 18px; left: 10%; right: 10%;
  height: 2px; background: #e2e8f0; z-index: 0;
}

/* ===================== PRODUCT CARD ===================== */
.product-card { transition: box-shadow 0.15s; }
.product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12) !important; }

/* ===================== UTILITIES ===================== */
.text-purple { color: #6f42c1; }
.cursor-pointer { cursor: pointer; }

/* ===================== AUTOCOMPLETE DROPDOWNS ===================== */
.product-suggestions .list-group-item { cursor: pointer; user-select: none; }
.product-suggestions .list-group-item.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.product-suggestions .list-group-item.active .text-primary { color: #fff !important; }
