/* ── PriceCalc — Dark Sidebar Design ───────────────────────────────────── */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --sidebar-w:              220px;
  --sidebar-bg:             #0d1117;
  --sidebar-border:         rgba(255,255,255,.07);
  --sidebar-text:           #7d8590;
  --sidebar-text-hover:     #e6edf3;
  --sidebar-hover-bg:       rgba(255,255,255,.06);
  --sidebar-active-bg:      rgba(99,102,241,.18);
  --sidebar-active-text:    #a5b4fc;
  --sidebar-active-icon:    #6366f1;

  --accent:                 #6366f1;
  --accent-dark:            #4f46e5;
  --accent-light:           #eef2ff;

  --content-bg:             #f8fafc;
  --card-bg:                #ffffff;
  --border:                 #e2e8f0;
  --border-light:           #f1f5f9;

  --text:                   #0f172a;
  --text-muted:             #64748b;
  --text-subtle:            #94a3b8;

  --radius:                 10px;
  --radius-sm:              6px;
  --shadow-xs:              0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:              0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:                 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg:              0 10px 30px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  --t:                      150ms ease;
}

/* ── Reset / Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  display: flex;
  min-height: 100vh;
  background: var(--content-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: .9rem;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--t);
  overflow: hidden;
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1rem .85rem .85rem;
  color: #e6edf3;
  text-decoration: none;
  font-size: .92rem;
  font-weight: 800;
  letter-spacing: -.02em;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  transition: opacity var(--t);
}
.sidebar-logo:hover { opacity: .85; color: #fff; }

.sidebar-logo-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,.4);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: .6rem .5rem;
  overflow-y: auto;
}

.sidebar-nav-section {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.18);
  padding: .7rem .5rem .25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .46rem .7rem;
  margin-bottom: .05rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .855rem;
  font-weight: 500;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
}
.sidebar-link i {
  font-size: .88rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  transition: color var(--t);
}
.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}
.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}
.sidebar-link.active i { color: var(--sidebar-active-icon); }

/* Footer */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: .7rem .75rem .85rem;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .55rem;
}

.sidebar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(99,102,241,.25);
  border: 1px solid rgba(99,102,241,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--sidebar-active-text);
  flex-shrink: 0;
  letter-spacing: 0;
}

.sidebar-username {
  font-size: .83rem;
  font-weight: 600;
  color: #c9d1d9;
  line-height: 1.25;
}
.sidebar-role {
  font-size: .67rem;
  color: var(--sidebar-text);
  margin-top: .05rem;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .38rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: .82rem;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  text-align: left;
}
.sidebar-logout:hover {
  background: rgba(239,68,68,.1);
  color: #f87171;
}
.sidebar-logout i { font-size: .85rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════ */

.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: 1.75rem 2rem 4rem;
}

/* No sidebar (login page) */
body.no-sidebar .main-wrap { margin-left: 0; }

/* ── Mobile ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: .7rem;
  left: .7rem;
  z-index: 200;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  color: #c9d1d9;
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}

@media (max-width: 991px) {
  .sidebar-toggle { display: flex; }
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-backdrop.open { display: block; }
  .main-wrap { margin-left: 0; }
  .main-content { padding-top: 3.5rem; padding-left: 1rem; padding-right: 1rem; }
}

@media (max-width: 575px) {
  .main-content { padding-left: .75rem; padding-right: .75rem; padding-bottom: 3rem; }
  .card { border-radius: var(--radius-sm); }
  /* Stack filter rows on mobile */
  .filter-row-mobile > [class*="col-"] { width: 100%; }
  /* Shrink action buttons in table headers */
  .d-flex.gap-2.flex-wrap { gap: .5rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--card-bg);
}

/* Alerts */
.alert {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: .88rem;
}

/* Tables */
.table th {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  border-top: none;
  white-space: nowrap;
  padding-top: .65rem;
  padding-bottom: .65rem;
  background: #f8fafc;
}
.table td {
  vertical-align: middle;
  padding-top: .55rem;
  padding-bottom: .55rem;
  font-variant-numeric: tabular-nums;
}
.table-hover > tbody > tr { transition: background var(--t); }
.table-hover > tbody > tr:hover > td { background: #f8fafc; }

/* Sticky thead */
.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}

/* Buttons */
.btn { font-weight: 500; letter-spacing: .01em; transition: all var(--t); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-icon { padding: .25rem .48rem; font-size: .8rem; line-height: 1.4; }

/* Form controls */
.form-control, .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--t), box-shadow var(--t);
}
.form-control:focus, .form-select:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .3rem; color: #374151; }

/* Section labels */
.section-label {
  font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted);
}

/* Custom badges */
.profit-badge {
  background: #dcfce7; color: #166534;
  padding: .2em .65em; border-radius: var(--radius-sm);
  font-size: .81rem; font-weight: 500; white-space: nowrap;
}
.margin-badge {
  background: var(--accent-light); color: var(--accent-dark);
  padding: .2em .65em; border-radius: var(--radius-sm);
  font-size: .81rem; font-weight: 500; white-space: nowrap;
}
.warn-badge {
  background: #fef9c3; color: #854d0e;
  padding: .2em .65em; border-radius: var(--radius-sm);
  font-size: .81rem; font-weight: 500;
}

/* Dropdowns */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .88rem;
  padding: .4rem;
}
.dropdown-item { border-radius: var(--radius-sm); padding: .38rem .65rem; transition: background var(--t); }
.filter-dropdown-menu { min-width: 180px; max-height: 260px; overflow-y: auto; }

/* Popovers */
.popover {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  font-size: .84rem;
  min-width: 210px;
}
.popover-header {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); background: #f8fafc;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: .5rem .8rem;
}
.popover-body { padding: .65rem .8rem; }

/* Modals */
.modal-content { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border-light); padding: 1rem 1.25rem .75rem; }
.modal-footer { border-top: 1px solid var(--border-light); padding: .75rem 1.25rem; }

/* Tabs */
.nav-tabs .nav-link {
  font-size: .86rem; font-weight: 500; color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color var(--t), background var(--t);
}
.nav-tabs .nav-link:hover { color: var(--text); background: #f8fafc; }
.nav-tabs .nav-link.active { color: var(--accent); font-weight: 600; }

/* Accordion */
.accordion-button { font-weight: 600; font-size: .9rem; }
.accordion-button:not(.collapsed) { color: var(--accent); background: var(--accent-light); box-shadow: none; }
.accordion-button:focus { box-shadow: none; }

/* Settings section */
.settings-section { border-left: 3px solid var(--border); padding-left: 1rem; }

/* Login */
.login-logo-wrap {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
}
.login-card { border-radius: 14px; box-shadow: var(--shadow-lg); }

/* Misc */
.text-muted { color: var(--text-muted) !important; }
hr { border-color: var(--border-light); opacity: 1; }
.border { border-color: var(--border) !important; }
.badge { font-weight: 500; letter-spacing: .01em; }

/* Animations */
.tab-pane.show { animation: fadeIn .15s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}

/* Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Sidebar scrollbar — darker */
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
