/* =====================================================================
   MARK ONE TAILOR CRM — Design System
   Premium White (default) + Dark Mode via CSS variables
   ===================================================================== */

:root {
  --mt-bg: #f7f7f5;
  --mt-surface: #ffffff;
  --mt-surface-alt: #fafaf9;
  --mt-border: #e7e5e2;
  --mt-text: #1c1c1a;
  --mt-text-muted: #6b6b66;
  --mt-text-faint: #9a9a94;
  --mt-accent: #b4141e;      /* Mark One red, used sparingly */
  --mt-accent-soft: #fbe9ea;
  --mt-sidebar-bg: #14140f;
  --mt-sidebar-text: #d9d9d3;
  --mt-sidebar-text-muted: #8b8b83;
  --mt-sidebar-active: #23231b;
  --mt-success: #1c7c4d;
  --mt-success-bg: #e7f5ee;
  --mt-warning: #a86a06;
  --mt-warning-bg: #fdf2e0;
  --mt-danger: #b3261e;
  --mt-danger-bg: #fbe9e8;
  --mt-info: #2f6fa8;
  --mt-info-bg: #e8f1fa;
  --mt-radius: 10px;
  --mt-radius-lg: 14px;
  --mt-shadow: 0 1px 2px rgba(20,20,15,0.04), 0 2px 8px rgba(20,20,15,0.04);
  --mt-shadow-lg: 0 4px 16px rgba(20,20,15,0.08);
  --mt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --mt-bg: #101010;
  --mt-surface: #171715;
  --mt-surface-alt: #1c1c19;
  --mt-border: #2b2b27;
  --mt-text: #eeeeea;
  --mt-text-muted: #a6a69f;
  --mt-text-faint: #74746c;
  --mt-accent: #e15057;
  --mt-accent-soft: #2c1516;
  --mt-sidebar-bg: #0b0b09;
  --mt-sidebar-text: #d9d9d3;
  --mt-sidebar-text-muted: #79796f;
  --mt-sidebar-active: #1c1c19;
  --mt-success: #3fbf83;
  --mt-success-bg: #10231a;
  --mt-warning: #d9a441;
  --mt-warning-bg: #2a2113;
  --mt-danger: #e2665f;
  --mt-danger-bg: #2a1615;
  --mt-info: #6ba3d6;
  --mt-info-bg: #131f2a;
  --mt-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.25);
  --mt-shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  background: var(--mt-bg);
  color: var(--mt-text);
  font-family: var(--mt-font);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--mt-accent); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--mt-sidebar-bg);
  color: var(--mt-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1030;
  transition: transform .2s ease;
}

.app-main {
  margin-left: 248px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.15rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px;}
.sidebar-brand .brand-name { font-weight: 700; font-size: .95rem; line-height: 1.1; color: #fff; }
.sidebar-brand .brand-sub { font-size: .68rem; color: var(--mt-sidebar-text-muted); letter-spacing: .03em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .65rem; }
.sidebar-section-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--mt-sidebar-text-muted); padding: .8rem .6rem .35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .65rem; border-radius: 8px; font-size: .87rem;
  color: var(--mt-sidebar-text); margin-bottom: 2px;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; color: var(--mt-sidebar-text-muted); }
.sidebar-link:hover { background: var(--mt-sidebar-active); color: #fff; }
.sidebar-link.active { background: var(--mt-sidebar-active); color: #fff; }
.sidebar-link.active i { color: var(--mt-accent); }

.sidebar-footer {
  padding: .85rem .9rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user { display: flex; align-items: center; gap: .55rem; margin-bottom: .6rem; }
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--mt-accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-user .name { font-size: .82rem; color: #fff; line-height: 1.1; }
.sidebar-user .role { font-size: .68rem; color: var(--mt-sidebar-text-muted); text-transform: capitalize; }

/* ---------- Topbar ---------- */
.app-topbar {
  height: 62px; flex-shrink: 0;
  background: var(--mt-surface);
  border-bottom: 1px solid var(--mt-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.4rem;
  position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 1.05rem; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.theme-toggle-btn {
  border: 1px solid var(--mt-border); background: var(--mt-surface-alt);
  color: var(--mt-text); border-radius: 8px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Content ---------- */
.app-content { padding: 1.5rem; flex: 1; }

/* ---------- Cards ---------- */
.mt-card {
  background: var(--mt-surface);
  border: 1px solid var(--mt-border);
  border-radius: var(--mt-radius-lg);
  box-shadow: var(--mt-shadow);
}
.mt-card .mt-card-header {
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--mt-border);
  display: flex; align-items: center; justify-content: space-between;
}
.mt-card .mt-card-header h2, .mt-card .mt-card-header h3 { margin: 0; font-size: 1rem; font-weight: 650; }
.mt-card .mt-card-body { padding: 1.2rem; }

.stat-card {
  background: var(--mt-surface); border: 1px solid var(--mt-border);
  border-radius: var(--mt-radius-lg); padding: 1.1rem 1.25rem; box-shadow: var(--mt-shadow);
}
.stat-card .stat-label { font-size: .74rem; color: var(--mt-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 700; margin-top: .25rem; }
.stat-card .stat-sub { font-size: .76rem; color: var(--mt-text-faint); margin-top: .15rem; }

/* ---------- Tables ---------- */
.table { color: var(--mt-text); margin-bottom: 0; }
.table > :not(caption) > * > * {
  border-bottom-color: var(--mt-border);
  background: transparent;
  padding: .7rem .85rem;
}
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--mt-text-muted); font-weight: 650; border-bottom-width: 1px;
  background: var(--mt-surface-alt);
}
.table-hover > tbody > tr:hover > * { background: var(--mt-surface-alt); }

/* ---------- Badges ---------- */
.badge-status { font-weight: 600; font-size: .72rem; padding: .32em .6em; border-radius: 6px; }
.badge-paid, .badge-active { background: var(--mt-success-bg); color: var(--mt-success); }
.badge-pending { background: var(--mt-warning-bg); color: var(--mt-warning); }
.badge-cancelled, .badge-archived, .badge-inactive { background: var(--mt-danger-bg); color: var(--mt-danger); }
.badge-info { background: var(--mt-info-bg); color: var(--mt-info); }

/* ---------- Forms ---------- */
.form-control, .form-select {
  background: var(--mt-surface); border: 1px solid var(--mt-border); color: var(--mt-text);
  border-radius: 8px; font-size: .87rem;
}
.form-control:focus, .form-select:focus {
  background: var(--mt-surface); color: var(--mt-text);
  border-color: var(--mt-accent); box-shadow: 0 0 0 3px var(--mt-accent-soft);
}
.form-label { font-size: .82rem; font-weight: 600; margin-bottom: .3rem; }
label.form-label .text-danger { font-weight: 400; }

/* ---------- Buttons ---------- */
.btn { border-radius: 8px; font-size: .85rem; font-weight: 600; }
.btn-dark { background: var(--mt-text); border-color: var(--mt-text); color: var(--mt-bg); }
.btn-accent { background: var(--mt-accent); border-color: var(--mt-accent); color: #fff; }
.btn-accent:hover { background: #96101a; border-color: #96101a; color: #fff; }
.btn-outline-soft { border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-text); }
.btn-outline-soft:hover { background: var(--mt-surface-alt); color: var(--mt-text); }

/* ---------- Modals ---------- */
.modal-content { background: var(--mt-surface); color: var(--mt-text); border: 1px solid var(--mt-border); }
.modal-header, .modal-footer { border-color: var(--mt-border); }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 3.2rem 1rem; color: var(--mt-text-muted); }
.empty-state i { font-size: 2.4rem; color: var(--mt-text-faint); margin-bottom: .8rem; display: block; }
.empty-state h4 { font-size: 1rem; color: var(--mt-text); margin-bottom: .3rem; }

/* ---------- Login page ---------- */
.login-page { background: var(--mt-bg); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  width: 100%; max-width: 380px; background: var(--mt-surface); border: 1px solid var(--mt-border);
  border-radius: var(--mt-radius-lg); box-shadow: var(--mt-shadow-lg); padding: 2rem 1.8rem;
}
.login-brand { text-align: center; margin-bottom: 1.4rem; }
.login-brand img { width: 64px; margin-bottom: .5rem; }
.login-brand h1 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.login-brand p { font-size: .78rem; color: var(--mt-text-muted); margin: .15rem 0 0; }

/* ---------- Utility ---------- */
.text-muted-mt { color: var(--mt-text-muted) !important; }
.section-divider { border-top: 1px solid var(--mt-border); margin: 1.2rem 0; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; background: var(--mt-accent-soft); color: var(--mt-accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }

/* Measurement groups */
.measure-group-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--mt-text-muted); margin: 1.2rem 0 .6rem; }
.measure-group-title:first-child { margin-top: 0; }

/* ---------- Global search ---------- */
.global-search { position: relative; }
.global-search input {
  width: 260px; background: var(--mt-surface-alt); border: 1px solid var(--mt-border);
  border-radius: 8px; padding: .45rem .75rem .45rem 2.1rem; font-size: .84rem; color: var(--mt-text);
}
.global-search i.bi-search { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--mt-text-faint); }
.search-results-panel {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; width: 340px; max-height: 360px; overflow-y: auto;
  background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: 10px; box-shadow: var(--mt-shadow-lg); z-index: 1050;
}
.search-results-panel.show { display: block; }
.search-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mt-text-faint); padding: .6rem .9rem .2rem; }
.search-result-item { display: flex; align-items: center; gap: .5rem; padding: .5rem .9rem; font-size: .84rem; color: var(--mt-text); }
.search-result-item:hover { background: var(--mt-surface-alt); }
.search-result-item i { color: var(--mt-text-faint); }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1025;
  }
  .sidebar-backdrop.show { display: block; }
}
