/* =============================================================================
   BlueLine Backflow CRM — Core Stylesheet
   Colors: Navy #1B3A6B | Blue #2E6DA4 | White #FFFFFF | Gray #F5F7FA
   ============================================================================= */

/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #2d3748;
  background: #f5f7fa;
  min-height: 100%;
}

a { color: #2E6DA4; text-decoration: none; }
a:hover { text-decoration: underline; color: #1B3A6B; }

h1, h2, h3, h4 { color: #1B3A6B; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.crm-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Top navigation bar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 58px;
  background: #1B3A6B;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  flex-shrink: 0;
  text-decoration: none;
}
.topbar-logo:hover { color: #cce0ff; text-decoration: none; }
.topbar-logo img { height: 32px; width: auto; }

.topbar-hamburger {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}
.topbar-hamburger:hover { background: rgba(255,255,255,0.15); }

.topbar-search {
  flex: 1;
  max-width: 400px;
  margin: 0 auto;
}
.topbar-search input {
  width: 100%;
  padding: 7px 14px;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.875rem;
}
.topbar-search input::placeholder { color: rgba(255,255,255,0.6); }
.topbar-search input:focus { background: rgba(255,255,255,0.25); outline: none; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.topbar-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  position: relative;
}
.topbar-btn:hover { background: rgba(255,255,255,0.15); }

.topbar-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #e53e3e;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.test-mode-badge {
  background: #e65c00;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.05em;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 4px;
}
.user-menu:hover { background: rgba(255,255,255,0.15); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #2E6DA4;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* Left sidebar */
.sidebar {
  position: fixed;
  top: 58px;
  left: 0;
  bottom: 0;
  width: 240px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  z-index: 900;
  transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar.collapsed { width: 60px; }

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-label { display: none; }

.nav-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 16px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #4a5568;
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: 4px;
  margin: 1px 6px;
  transition: background 0.15s;
}
.nav-item:hover { background: #edf2f7; color: #1B3A6B; text-decoration: none; }
.nav-item.active { background: #dbeafe; color: #1B3A6B; font-weight: 600; }

.nav-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: #e53e3e;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Main content area */
.main-content {
  margin-top: 58px;
  margin-left: 240px;
  padding: 24px;
  flex: 1;
  transition: margin-left 0.2s ease;
  min-height: calc(100vh - 58px);
}

.main-content.sidebar-collapsed { margin-left: 60px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}
.card-title { font-size: 1.1rem; font-weight: 600; color: #1B3A6B; margin: 0; }

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

.stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px 20px;
}
.stat-label { font-size: 0.78rem; color: #718096; font-weight: 500; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: #1B3A6B; }
.stat-sub   { font-size: 0.78rem; color: #a0aec0; margin-top: 2px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: #1B3A6B;
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #e2e8f0; }
tbody tr:hover { background: #f7faff; }
tbody td { padding: 10px 14px; vertical-align: middle; }
tbody tr:nth-child(even) { background: #f9fafb; }
tbody tr:nth-child(even):hover { background: #f0f4ff; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4a5568;
  margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  font-size: 0.9rem;
  color: #2d3748;
  background: #fff;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2E6DA4;
  box-shadow: 0 0 0 3px rgba(46,109,164,0.15);
}

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

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary    { background: #1B3A6B; color: #fff; }
.btn-primary:hover { background: #142e55; color: #fff; }

.btn-secondary  { background: #fff; color: #1B3A6B; border-color: #1B3A6B; }
.btn-secondary:hover { background: #edf2f7; }

.btn-success    { background: #2f855a; color: #fff; }
.btn-success:hover { background: #276749; color: #fff; }

.btn-danger     { background: #c53030; color: #fff; }
.btn-danger:hover { background: #9b2c2c; color: #fff; }

.btn-warning    { background: #c05621; color: #fff; }
.btn-warning:hover { background: #9c4221; color: #fff; }

.btn-sm  { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg  { padding: 11px 22px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 5px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-danger  { background: #fff5f5; border: 1px solid #feb2b2; color: #c53030; }
.alert-success { background: #f0fff4; border: 1px solid #9ae6b4; color: #276749; }
.alert-info    { background: #ebf8ff; border: 1px solid #90cdf4; color: #2b6cb0; }
.alert-warning { background: #fffaf0; border: 1px solid #fbd38d; color: #c05621; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-active    { background: #c6f6d5; color: #276749; }
.badge-inactive  { background: #e2e8f0; color: #718096; }
.badge-locked    { background: #fed7d7; color: #c53030; }
.badge-suspended { background: #feebc8; color: #c05621; }
.badge-pending   { background: #bee3f8; color: #2b6cb0; }
.badge-pass      { background: #c6f6d5; color: #276749; }
.badge-fail      { background: #fed7d7; color: #c53030; }
.badge-draft     { background: #e2e8f0; color: #718096; }
.badge-sent      { background: #bee3f8; color: #2b6cb0; }
.badge-paid      { background: #c6f6d5; color: #276749; }
.badge-overdue   { background: #fed7d7; color: #c53030; }
.badge-retired   { background: #e2e8f0; color: #718096; }

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  background: linear-gradient(135deg, #1B3A6B 0%, #2E6DA4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  color: #fff;
  margin-bottom: 24px;
}
.login-logo img { height: 64px; margin-bottom: 12px; }
.login-logo h1 { font-size: 1.5rem; color: #fff; margin-bottom: 4px; }
.login-logo p  { font-size: 0.875rem; color: rgba(255,255,255,0.7); }

.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-card h2 { margin-bottom: 24px; color: #1B3A6B; font-size: 1.3rem; }

.form-footer { text-align: center; margin-top: 12px; font-size: 0.875rem; }

.login-version {
  text-align: center;
  margin-top: 24px;
  font-size: 0.75rem;
  color: #a0aec0;
}

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.text-muted   { color: #718096; }
.text-danger  { color: #c53030; }
.text-success { color: #276749; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .topbar-search { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
