/* AOP Software — Design System
   Extracted from docs/AOP_UI_Mockup.html
   Font: Inter (loaded in base.html via Google Fonts)
*/

/* ========== RESET & ROOT VARIABLES ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1d4ed8;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #1d4ed8;
  --accent-light: #eff6ff;
  --success: #059669;
  --success-light: #ecfdf5;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --transition: all 0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.5;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-brand {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: 72px;
  text-decoration: none;
}

.sidebar-brand .logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 14px;
  flex-shrink: 0;
  font-family: inherit;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand .brand-name {
  color: white;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.sidebar-brand .brand-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
  margin-top: 1px;
}

.sidebar-section {
  padding: 16px 12px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* nav-item: each sidebar link (like a PHP menu item) */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.3);
}

.nav-item .icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

/* Badge on nav item (e.g., Quotes count) */
.nav-item .badge {
  margin-left: auto;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.nav-item .phase-tag {
  margin-left: auto;
  font-size: 10px;
  color: #475569;
  font-weight: 500;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-user .avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sidebar-user .user-info {
  display: flex;
  flex-direction: column;
}

.sidebar-user .user-name {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user .user-role {
  color: #64748b;
  font-size: 11px;
}

/* ========== MAIN CONTENT AREA ========== */
.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: var(--transition);
}

/* ========== TOPBAR ========== */
.topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-left h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.topbar-user a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
}

/* ========== PAGE CONTENT WRAPPER ========== */
.page-content {
  padding: 28px 32px;
  max-width: 1440px;
}

/* ========== DJANGO MESSAGES (flash alerts) ========== */
.messages {
  padding: 20px 32px 0;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.alert-success,
.alert-info {
  background: var(--success-light);
  color: var(--success);
  border-color: #a7f3d0;
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border-color: #fde68a;
}

.alert-error,
.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: #fecaca;
}

/* ========== CARDS ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-body {
  padding: 24px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* ========== KPI CARDS ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: default;
}

.kpi-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.kpi-icon.blue  { background: var(--accent-light);   color: var(--accent);   }
.kpi-icon.green { background: var(--success-light);  color: var(--success);  }
.kpi-icon.amber { background: var(--warning-light);  color: var(--warning);  }
.kpi-icon.red   { background: var(--danger-light);   color: var(--danger);   }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.kpi-change.up   { color: var(--success); background: var(--success-light); }
.kpi-change.down { color: var(--danger);  background: var(--danger-light);  }

/* ========== DASHBOARD WELCOME CARD ========== */
.welcome-card {
  margin-bottom: 24px;
}

.welcome-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========== QUICK ACTION CARDS (Dashboard) ========== */
.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.action-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.action-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--accent);
}

.action-card .action-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.action-card .action-icon.blue  { background: var(--accent-light);  color: var(--accent);  }
.action-card .action-icon.green { background: var(--success-light); color: var(--success); }
.action-card .action-icon.amber { background: var(--warning-light); color: var(--warning); }
.action-card .action-icon.slate { background: #f1f5f9; color: #475569; }

.action-card .action-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.action-card .action-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ========== CONTENT GRID ========== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  margin-bottom: 28px;
}

/* ========== TABLES ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 24px;
  font-size: 13.5px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
}

.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }

.product-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.product-cell .name { font-weight: 600; color: var(--text-primary); }
.product-cell .meta { font-size: 11.5px; color: var(--text-muted); }

/* ========== PILL / STATUS BADGES ========== */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

/* Packaging type pills */
.pill.drum { background: #eff6ff; color: #1d4ed8; }
.pill.tote { background: #f0fdf4; color: #15803d; }
.pill.bag  { background: #fefce8; color: #a16207; }

/* Quote status pills */
.pill.draft    { background: #f1f5f9; color: #64748b; }
.pill.sent     { background: #eff6ff; color: #1d4ed8; }
.pill.accepted { background: #f0fdf4; color: #059669; }
.pill.expired  { background: var(--danger-light); color: var(--danger); }

/* Status dot indicator (used in quote lists) */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
}

.status-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.draft    { color: #64748b; }
.status-dot.draft::before    { background: #94a3b8; }
.status-dot.sent     { color: #1d4ed8; }
.status-dot.sent::before     { background: #3b82f6; }
.status-dot.accepted { color: #059669; }
.status-dot.accepted::before { background: #10b981; }
.status-dot.expired  { color: #dc2626; }
.status-dot.expired::before  { background: #ef4444; }

/* ========== PRICE / TIER TAGS ========== */
.price { font-weight: 600; font-variant-numeric: tabular-nums; }

.tier-prices { display: flex; gap: 6px; }

.tier-tag {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.tier-tag.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: #1e40af;
  box-shadow: 0 2px 8px rgba(29,78,216,0.3);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #047857; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b91c1c; }

/* ========== FORM CONTROLS ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: var(--transition);
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.form-input::placeholder { color: var(--text-muted); }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ========== FILTER BAR ========== */
.filter-bar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  margin-bottom: -1px;
  text-decoration: none;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ========== LOGIN PAGE ========== */
/* Full-screen centered layout for the login card */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-brand .logo {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 18px;
  font-family: inherit;
}

.login-brand .brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-brand .brand-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -6px;
}

/* .login-form reuses global .form-group, .form-label, .form-input — no overrides needed */
.login-form .form-group {
  margin-bottom: 16px;
}

.login-form .btn-primary {
  width: 100%;
  padding: 11px 14px;
  justify-content: center;
  font-size: 14px;
  border-radius: 8px;
  margin-top: 8px;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}

.login-error.login-info {
  background: var(--accent-light);
  color: var(--accent);
  border-color: #bfdbfe;
}

/* ========== QUOTE LIST ITEMS ========== */
.quote-list { padding: 0; }

.quote-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
  transition: var(--transition);
  cursor: pointer;
}

.quote-item:hover { background: #f8fafc; }
.quote-item:last-child { border-bottom: none; }

.quote-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quote-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.quote-icon.draft    { background: #f1f5f9; color: #64748b; }
.quote-icon.sent     { background: #eff6ff; color: #1d4ed8; }
.quote-icon.accepted { background: #f0fdf4; color: #059669; }

.quote-info .quote-customer {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.quote-info .quote-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.quote-right { text-align: right; }

.quote-right .quote-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ========== RESPONSIVE ========== */
/* Sidebar collapses on small screens (hamburger toggle done via Alpine.js) */
@media (max-width: 1200px) {
  .content-grid  { grid-template-columns: 1fr; }
  .kpi-grid      { grid-template-columns: repeat(2, 1fr); }
  .action-grid   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Sidebar slides off-screen; toggle with [x-show] in Alpine */
  .sidebar      { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main         { margin-left: 0; }
  .kpi-grid     { grid-template-columns: 1fr; }
  .action-grid  { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 20px 16px; }
  .topbar       { padding: 0 16px; }
  .messages     { padding: 12px 16px 0; }
}

/* Hamburger button (mobile only) */
.hamburger {
  display: none;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
}

/* Mobile overlay behind open sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

@media (max-width: 768px) {
  .sidebar-overlay.open { display: block; }
}

/* ========== STATUS BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-draft {
  background: #f1f5f9;
  color: #475569;
}

.badge-sent {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-accepted {
  background: var(--success-light);
  color: var(--success);
}

.badge-expired {
  background: var(--danger-light);
  color: var(--danger);
}

/* ========== QUOTE LIST / DETAIL UTILITIES ========== */

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

.table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 14px 24px;
  font-size: 13.5px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
}

.table tr:hover td { background: #f8fafc; }
.table tr:last-child td { border-bottom: none; }
