/* ═══════════════════════════════════════════════════════
   Peter Alexander Carpets CRM  |  style.css
   Aesthetic: Refined luxury — deep navy sidebar, warm cream content
   Fonts: Cormorant Garamond (display) + DM Sans (UI)
═══════════════════════════════════════════════════════ */

:root {
  --navy:        #1a2744;
  --navy-deep:   #111c36;
  --navy-mid:    #243057;
  --navy-light:  #2e3f6e;
  --gold:        #c8960a;
  --gold-light:  #e8b830;
  --cream:       #f7f4ef;
  --cream-dark:  #ede9e1;
  --white:       #ffffff;
  --text-dark:   #1a1a2e;
  --text-mid:    #4a4a6a;
  --text-light:  #8a8aaa;
  --green:       #1e7e4e;
  --green-bg:    #e6f7ee;
  --red:         #c0392b;
  --red-bg:      #fdecea;
  --amber:       #d97706;
  --amber-bg:    #fef3cd;
  --border:      #e2ddd5;
  --shadow-sm:   0 1px 3px rgba(26,39,68,0.08);
  --shadow-md:   0 4px 16px rgba(26,39,68,0.12);
  --shadow-lg:   0 8px 32px rgba(26,39,68,0.16);
  --sidebar-w:   260px;
  --radius:      8px;
  --radius-lg:   14px;
}

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

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--cream);
  color: var(--text-dark);
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy-deep);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(0,0,0,0.25);
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
}

/* ── SIDEBAR BRAND ───────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--navy-deep);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.3px;
}

.brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

/* ── NAV MENU ────────────────────────────────────────── */
.nav-menu {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: all 0.18s ease;
  position: relative;
}

.nav-item a svg {
  width: 18px; height: 18px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item a:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
}

.nav-item.active a {
  background: rgba(200,150,10,0.15);
  color: var(--gold-light);
  font-weight: 600;
}

.nav-item.active a svg { opacity: 1; }

.nav-item.active a::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}

.nav-item.nav-disabled a {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.35);
  padding: 2px 6px;
  border-radius: 20px;
}

/* ── SIDEBAR FOOTER ──────────────────────────────────── */
.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-light), var(--navy-mid));
  border: 2px solid rgba(200,150,10,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-light);
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-transform: capitalize;
}

.logout-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.3);
  transition: all 0.18s;
  flex-shrink: 0;
}

.logout-btn:hover {
  background: rgba(192,57,43,0.2);
  color: #e74c3c;
}

.logout-btn svg { width: 17px; height: 17px; fill: currentColor; }

/* ── PAGE HEADER ─────────────────────────────────────── */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.3px;
  line-height: 1.1;
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a { color: var(--navy-mid); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); }

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

/* ── PAGE BODY ───────────────────────────────────────── */
.page-body {
  padding: 28px 32px;
  flex: 1;
}

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
}

.card-body { padding: 22px; }

/* ── STATS ROW (Dashboard) ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.gold::after  { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.stat-card.blue::after  { background: linear-gradient(90deg, var(--navy), var(--navy-light)); }
.stat-card.green::after { background: linear-gradient(90deg, #1e7e4e, #27ae60); }
.stat-card.red::after   { background: linear-gradient(90deg, #c0392b, #e74c3c); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 34px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ── SEARCH BAR ──────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 500px;
}

.search-wrap svg {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  fill: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--white);
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-input:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(46,63,110,0.1);
}

.search-input::placeholder { color: var(--text-light); }

/* ── TABLE ───────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

table.crm-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: 13.5px;
}

.crm-table thead th {
  background: var(--navy);
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border: none;
}

.crm-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.crm-table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.crm-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}

.crm-table tbody tr:last-child { border-bottom: none; }

.crm-table tbody tr:hover { background: #f0eee9; }

.crm-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--text-dark);
}

.crm-table tbody td.muted { color: var(--text-light); font-size: 12.5px; }

/* ── BADGES / STATUS ──────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-paid       { background: var(--green-bg); color: var(--green); }
.badge-outstanding { background: var(--amber-bg); color: var(--amber); }
.badge-void       { background: #f0f0f0; color: #999; }
.badge-cancelled  { background: var(--red-bg); color: var(--red); }

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; fill: currentColor; }

.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover { background: var(--navy-light); box-shadow: var(--shadow-md); }

.btn-gold {
  background: var(--gold);
  color: var(--navy-deep);
  font-weight: 600;
}
.btn-gold:hover { background: var(--gold-light); box-shadow: var(--shadow-md); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--navy-mid); background: var(--cream); }

.btn-sm { padding: 6px 13px; font-size: 12.5px; }

/* ── CUSTOMER PROFILE ────────────────────────────────── */
.customer-profile {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.profile-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.profile-card-top {
  background: linear-gradient(135deg, var(--navy-deep), var(--navy-mid));
  padding: 28px 22px;
  text-align: center;
}

.profile-avatar {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy-deep);
  margin: 0 auto 12px;
}

.profile-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.profile-id {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.profile-details {
  padding: 18px 22px;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--cream-dark);
}

.detail-row:last-child { border-bottom: none; }

.detail-icon {
  width: 16px; height: 16px;
  fill: var(--text-light);
  flex-shrink: 0;
  margin-top: 1px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  min-width: 70px;
}

.detail-value {
  font-size: 13px;
  color: var(--text-dark);
  flex: 1;
}

/* ── ORDERS PANEL ─────────────────────────────────────── */
.orders-panel { flex: 1; }

.orders-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.mini-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: center;
}

.mini-stat-val {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
}

.mini-stat-label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── PAGINATION ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--cream);
  font-size: 13px;
  color: var(--text-mid);
}

.page-links { display: flex; gap: 4px; }

.page-links a, .page-links span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  font-size: 13px;
  text-decoration: none;
  color: var(--text-mid);
  border: 1px solid transparent;
  transition: all 0.15s;
}

.page-links a:hover { background: var(--cream-dark); border-color: var(--border); }
.page-links span.current { background: var(--navy); color: var(--white); font-weight: 600; }
.page-links span.dots { border: none; color: var(--text-light); cursor: default; }

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state svg {
  width: 52px; height: 52px;
  fill: var(--border);
  margin-bottom: 14px;
}

.empty-state p { font-size: 15px; }

/* ── ALERT ────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-error   { background: var(--red-bg); color: var(--red); border: 1px solid #f5c6c2; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #b2dfcb; }

/* ── LOGIN PAGE ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy-mid) 60%, var(--navy-light) 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(200,150,10,0.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(200,150,10,0.05) 0%, transparent 50%);
}

.login-card {
  background: var(--white);
  border-radius: 18px;
  width: 400px;
  padding: 48px 44px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  position: relative;
  z-index: 1;
  animation: fadeUp 0.5s ease both;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px; height: 58px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 14px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-deep);
  margin-bottom: 14px;
}

.login-logo h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 12.5px;
  color: var(--text-light);
  letter-spacing: 0.3px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mid);
  margin-bottom: 7px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--white);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.form-control:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(46,63,110,0.1);
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-login:hover {
  background: linear-gradient(135deg, var(--navy-light), var(--navy));
  box-shadow: 0 6px 20px rgba(26,39,68,0.3);
  transform: translateY(-1px);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-light);
}

/* ── NO-DB DEMO MODE ──────────────────────────────────── */
.demo-notice {
  background: linear-gradient(135deg, #fff8e6, #fef3cd);
  border: 1px solid #f0c040;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 12.5px;
  color: #7a5800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .customer-profile { grid-template-columns: 1fr; }
  .orders-summary { grid-template-columns: repeat(3, 1fr); }
}
