/*
 * Miracle Automation — Light Theme
 * Navy BG:  #003366
 * Blue:     #1a73e8
 * White cards, light inputs, dark text
 */

:root {
  --navy: #003366;
  --blue: #1a73e8;
  --blue-dark: #0a59c6;
  --blue-light: #e8f0fe;
  --blue-dim: rgba(26, 115, 232, 0.08);
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --border: #e5e7eb;
  --border-light: #d1d5db;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --green: #059669;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --yellow: #d97706;
  --yellow-bg: #fffbeb;
  --yellow-border: #fde68a;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Fira Code", monospace;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-blue: 0 4px 14px rgba(26, 115, 232, 0.25);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: 260px;
  background: var(--navy);
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 18px;
}
.sidebar-brand img {
  height: 38px;
  width: auto;
  object-fit: contain;
  filter: brightness(1.1);
}
.sidebar-brand h1 {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}
.sidebar-brand h1 span {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
  font-size: 11px;
  display: block;
  margin-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}
.nav-item.active {
  background: rgba(26, 115, 232, 0.25);
  color: #fff;
  font-weight: 600;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ═══ MAIN ═══ */
.main {
  flex: 1;
  margin-left: 260px;
  padding: 28px 32px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

/* ═══ STAT CARDS ═══ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  box-shadow: var(--shadow);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}
.stat-card.blue::before {
  background: var(--blue);
}
.stat-card.green::before {
  background: var(--green);
}
.stat-card.red::before {
  background: var(--red);
}
.stat-card.yellow::before {
  background: var(--yellow);
}
.stat-card.purple::before {
  background: var(--purple);
}
.stat-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.stat-card .value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1;
}
.stat-card .sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}
.stat-card.blue .value {
  color: var(--blue);
}
.stat-card.green .value {
  color: var(--green);
}
.stat-card.red .value {
  color: var(--red);
}
.stat-card.yellow .value {
  color: var(--yellow);
}
.stat-card.purple .value {
  color: var(--purple);
}

/* ═══ PANELS ═══ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface-2);
}
.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.panel-body {
  padding: 20px;
}

/* ═══ TABLE ═══ */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 10px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-3);
  color: var(--text);
}
tr:hover td {
  background: var(--blue-dim);
}

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge.yes {
  background: var(--green-bg);
  color: var(--green);
}
.badge.no {
  background: var(--red-bg);
  color: var(--red);
}
.badge.maybe {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.badge.pending {
  background: var(--purple-bg);
  color: var(--purple);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge.yes::before {
  background: var(--green);
}
.badge.no::before {
  background: var(--red);
}
.badge.maybe::before {
  background: var(--yellow);
}
.badge.pending::before {
  background: var(--purple);
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn-primary {
  background: linear-gradient(135deg, #1a73e8, #0a59c6);
  color: #fff;
  border: none;
}
.btn-primary:hover {
  box-shadow: var(--shadow-blue);
  transform: translateY(-1px);
}
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
}
.btn-success:hover {
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-outline:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
}
.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover {
  background: #fee2e2;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ═══ FORMS ═══ */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: all 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
  background: #fff;
}
.form-control::placeholder {
  color: var(--text-dim);
}
textarea.form-control {
  resize: vertical;
  min-height: 80px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ═══ TOOLBAR ═══ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-box input {
  padding-left: 36px;
}
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}
.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
}
.pill:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.pill.active {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
}

/* ═══ ACTIVITY ═══ */
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-3);
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.activity-dot.yes {
  background: var(--green);
}
.activity-dot.no {
  background: var(--red);
}
.activity-dot.maybe {
  background: var(--yellow);
}
.activity-text {
  flex: 1;
  font-size: 13px;
}
.activity-text strong {
  color: var(--text);
}
.activity-time {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ═══ PROGRESS ═══ */
.progress-bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.progress-bar .seg {
  height: 100%;
  transition: width 0.6s ease;
}
.progress-bar .seg.green {
  background: var(--green);
}
.progress-bar .seg.red {
  background: var(--red);
}
.progress-bar .seg.yellow {
  background: var(--yellow);
}
.progress-bar .seg.purple {
  background: var(--purple);
}
.progress-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.progress-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.progress-legend span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.progress-legend .lg::before {
  background: var(--green);
}
.progress-legend .lr::before {
  background: var(--red);
}
.progress-legend .ly::before {
  background: var(--yellow);
}
.progress-legend .lp::before {
  background: var(--purple);
}

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
}
.modal-close:hover {
  color: var(--text);
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-2);
}

/* ═══ TOAST ═══ */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.toast.success {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.toast.error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}
.toast.info {
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid #bfdbfe;
}
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface-2);
}
.upload-zone:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.page-section {
  display: none;
}
.page-section.active {
  display: block;
}
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}
.mobile-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
    padding: 16px;
  }
  .mobile-toggle {
    display: block;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
