/* ============================================================
   Outpost — Base Stylesheet (light UI, brand-variable driven)
   ============================================================ */

:root {
  /* These are overridden per-store via inline <style> in header.php */
  --store-color:      #3a506b;
  --store-color-dark: #2b3d52;
  --store-accent:     #7e5c3a;

  /* Layout / structure */
  --sidebar-w:   248px;
  --topbar-h:    60px;
  --radius:      8px;
  --radius-sm:   5px;
  --t:           150ms ease;

  /* Status colors (consistent across themes) */
  --red:         #c0392b;
  --red-bg:      #fde8e8;
  --red-text:    #922b21;
  --yellow:      #b7770d;
  --yellow-bg:   #fef9e7;
  --green:       #1a7a4a;
  --green-bg:    #e8f8f0;
  --blue:        #1a5276;
  --blue-bg:     #e8f0f8;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--store-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  font-size: 22px;
  color: var(--store-color);
  line-height: 1;
  flex-shrink: 0;
}

.brand-app {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--text);
  text-transform: uppercase;
}

.brand-store {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  font-family: var(--font-sans);
}

/* Nav */
.sidebar-nav {
  list-style: none;
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav li { margin: 1px 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t), color var(--t);
  text-decoration: none;
}

.nav-link svg { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; }

.nav-link:hover {
  background: var(--nav-hover-bg);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--nav-active-bg);
  color: var(--store-color);
  font-weight: 600;
  border-left: 3px solid var(--store-color);
  padding-left: 8px;
}

/* Nav dividers */
.nav-divider {
  margin: 6px 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 6px;
  opacity: .6;
  list-style: none;
}
.nav-divider:empty { padding-top: 0; }

/* Collapsible group headers */
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background var(--t), color var(--t);
  list-style: none;
}
.nav-group-header:hover { background: var(--nav-hover-bg); color: var(--text); }
.nav-group-header.open  { color: var(--text); }
.nav-group-header svg   { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; }

/* Group sub-items */
.nav-group-items {
  list-style: none;
  padding: 2px 0 4px 0;
  margin: 0;
}
.nav-sub-link {
  padding-left: 38px !important;
  font-size: 13px;
}
.nav-sub-link.active {
  border-left: 3px solid var(--store-color);
  padding-left: 35px !important;
}

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.user-avatar {
  width: 30px; height: 30px;
  background: var(--store-color);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}

.user-name  { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: var(--text-muted); }

.btn-logout {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: color var(--t), background var(--t);
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--red); background: var(--red-bg); text-decoration: none; }
.btn-logout svg   { width: 14px; height: 14px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px var(--topbar-shadow);
}

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 4px; display: none;
}

.page-title { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; font-family: var(--font-sans); }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.store-badge {
  background: var(--badge-bg);
  color: var(--store-color);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
  border: 1px solid var(--badge-border);
  text-transform: uppercase;
}

.topbar-date { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.page-body { flex: 1; overflow-y: auto; padding: 28px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px var(--card-shadow);
}

.card-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 7px;
}
.card-title svg { width: 13px; height: 13px; }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 4px var(--card-shadow);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--store-color);
  opacity: .5;
}

.stat-card.danger::after  { background: var(--red);    opacity: 1; }
.stat-card.warning::after { background: var(--yellow); opacity: 1; }
.stat-card.ok::after      { background: var(--green);  opacity: 1; }
.stat-card.info::after    { background: var(--blue);   opacity: 1; }

.stat-label { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }

.stat-value {
  font-family: var(--font-mono);
  font-size: 30px; font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-card.danger  .stat-value { color: var(--red); }
.stat-card.warning .stat-value { color: var(--yellow); }
.stat-card.ok      .stat-value { color: var(--green); }

.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left; padding: 9px 13px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: var(--bg-surface);
}

td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  font-family: var(--font-mono);
}

.badge-red    { background: var(--red-bg);    color: var(--red-text); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-muted  { background: var(--bg-surface); color: var(--text-muted); border: 1px solid var(--border); }

.days-pill {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
}
.days-pill.expired  { background: var(--red-bg);    color: var(--red-text); }
.days-pill.critical { background: var(--red-bg);    color: var(--red-text); }
.days-pill.warning  { background: var(--yellow-bg); color: var(--yellow); }
.days-pill.ok       { background: var(--green-bg);  color: var(--green); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }

label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: .5px; color: var(--text-muted);
  margin-bottom: 5px; text-transform: uppercase;
}

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=number], input[type=tel],
input[type=url], select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color var(--t), box-shadow var(--t);
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--store-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: background var(--t), opacity var(--t), transform var(--t);
  text-decoration: none; letter-spacing: .2px;
}

.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--store-color); color: #fff; }
.btn-primary:hover { background: var(--store-color-dark); text-decoration: none; color: #fff; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text); text-decoration: none; }

.btn-danger { background: var(--red-bg); color: var(--red-text); border: 1px solid rgba(192,57,43,.2); }
.btn-danger:hover { background: #fad7d5; text-decoration: none; color: var(--red-text); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px;
}

.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text); font-family: var(--font-display); }
.page-header p  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px; border-radius: var(--radius-sm);
  margin-bottom: 18px; font-size: 13.5px;
}
.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }

.alert-success { background: var(--green-bg); color: var(--green);  border: 1px solid rgba(26,122,74,.2); }
.alert-danger  { background: var(--red-bg);   color: var(--red);    border: 1px solid rgba(192,57,43,.2); }
.alert-warning { background: var(--yellow-bg);color: var(--yellow); border: 1px solid rgba(183,119,13,.2); }
.alert-info    { background: var(--blue-bg);  color: var(--blue);   border: 1px solid rgba(26,82,118,.2); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; padding: 26px;
  box-shadow: 0 8px 40px rgba(0,0,0,.15);
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 700; font-family: var(--font-display); }

.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--bg-surface); }
.modal-close svg { width: 17px; height: 17px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state svg { width: 36px; height: 36px; opacity: .25; margin-bottom: 14px; }
.empty-state p { font-size: 14px; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--login-bg);
}

.login-box {
  width: 100%; max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 38px 34px;
  box-shadow: 0 4px 24px var(--card-shadow);
}

.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand .brand-mark  { font-size: 30px; color: var(--store-color); display: block; margin-bottom: 10px; }
.login-brand .brand-app   { font-family: var(--font-mono); font-size: 16px; font-weight: 700; letter-spacing: 4px; color: var(--text); }
.login-brand .brand-store { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0;
    transition: left var(--t); z-index: 200;
  }
  .sidebar.open    { left: 0; }
  .sidebar-toggle  { display: flex; }
  .topbar-date     { display: none; }
  .page-body       { padding: 16px; }
}
