/* ============================================================
   Annie Insights Report — Unified Design System
   Ported from Annie-Insights-Web-Angular _variables.scss
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Core colors */
  --annie-primary-rgb: 9, 156, 213;
  --annie-secondary-rgb: 25, 29, 125;
  --annie-success-rgb: 38, 191, 148;
  --annie-danger-rgb: 230, 83, 60;
  --annie-warning-rgb: 245, 184, 73;
  --annie-info-rgb: 73, 182, 245;

  /* Typography */
  --annie-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --annie-font-size: 0.875rem;
  --annie-text-color: #333335;
  --annie-text-muted: #8c9097;
  --annie-text-light: #a8afc7;

  /* Backgrounds */
  --annie-body-bg: #f0f1f7;
  --annie-card-bg: #ffffff;
  --annie-card-border: #f3f3f3;
  --annie-header-bg: linear-gradient(120deg, rgb(var(--annie-primary-rgb)) 0%, rgb(var(--annie-secondary-rgb)) 100%);

  /* Borders & Radius */
  --annie-border-color: #e9edf6;
  --annie-radius: 0.5rem;
  --annie-radius-lg: 0.75rem;

  /* Shadows */
  --annie-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.04);
  --annie-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
  --annie-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);

  /* Spacing */
  --annie-header-height: 3.5rem;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--annie-font-family);
  font-size: var(--annie-font-size);
  color: var(--annie-text-color);
  background-color: var(--annie-body-bg);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* ---------- App Layout ---------- */
.app-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--annie-header-bg);
  padding: 0 1.5rem;
  height: var(--annie-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.app-header .header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
}

.app-header .header-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.app-header .header-brand .brand-text {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.app-header .header-brand .brand-text small {
  display: block;
  font-weight: 400;
  font-size: 0.7rem;
  opacity: 0.85;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.app-header .header-title {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
  opacity: 0.95;
}

.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header .header-actions .btn-download {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.35rem 1rem;
  border-radius: var(--annie-radius);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.app-header .header-actions .btn-download:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

/* ---------- Main Content ---------- */
.app-content {
  flex: 1;
  padding: 1.25rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Cards ---------- */
.annie-card {
  background: var(--annie-card-bg);
  border: 1px solid var(--annie-card-border);
  border-radius: var(--annie-radius-lg);
  box-shadow: var(--annie-shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.annie-card:hover {
  box-shadow: var(--annie-shadow);
}

.annie-card .card-body {
  padding: 1.25rem;
}

/* ---------- Section Header (gradient pill) ---------- */
.section-header {
  background: var(--annie-header-bg);
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: var(--annie-radius);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header i {
  font-size: 0.9rem;
  opacity: 0.85;
}

.section-header.section-header-sm {
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
}

/* ---------- Patient Info Header ---------- */
.patient-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.patient-header .patient-field {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--annie-card-border);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.patient-header .patient-field:nth-child(odd) {
  border-right: 1px solid var(--annie-card-border);
}

.patient-header .patient-field:nth-last-child(-n+2) {
  border-bottom: none;
}

.patient-header .field-label {
  font-size: 0.75rem;
  color: var(--annie-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  min-width: 100px;
  flex-shrink: 0;
}

.patient-header .field-value {
  font-weight: 600;
  color: var(--annie-text-color);
  font-size: 0.85rem;
}

/* ---------- Data Fields (label:value rows) ---------- */
.data-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f5f6f8;
}

.data-field:last-child {
  border-bottom: none;
}

.data-field .data-label {
  color: var(--annie-text-muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.data-field .data-value {
  font-weight: 500;
  color: var(--annie-text-color);
  font-size: 0.85rem;
  text-align: right;
}

/* ---------- Data Tables ---------- */
.annie-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.annie-table thead th {
  background: #f8f9fb;
  color: var(--annie-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--annie-card-border);
  white-space: nowrap;
}

.annie-table tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f5f6f8;
  color: var(--annie-text-color);
  vertical-align: middle;
}

.annie-table tbody tr:last-child td {
  border-bottom: none;
}

.annie-table tbody tr:hover {
  background: #fafbfc;
}

/* ---------- No Data State ---------- */
.no-data-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--annie-text-muted);
}

.no-data-state .no-data-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
  color: rgb(var(--annie-primary-rgb));
}

.no-data-state .no-data-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--annie-text-color);
  margin-bottom: 0.35rem;
}

.no-data-state .no-data-text {
  font-size: 0.8rem;
  color: var(--annie-text-muted);
}

/* ---------- Alert / Info Box ---------- */
.annie-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--annie-radius);
  font-size: 0.82rem;
  line-height: 1.5;
}

.annie-alert-info {
  background: rgba(var(--annie-info-rgb), 0.08);
  color: rgb(var(--annie-primary-rgb));
  border: 1px solid rgba(var(--annie-info-rgb), 0.15);
}

.annie-alert-warning {
  background: rgba(var(--annie-warning-rgb), 0.08);
  color: #b8860b;
  border: 1px solid rgba(var(--annie-warning-rgb), 0.2);
}

.annie-alert i {
  font-size: 1rem;
  margin-top: 0.1rem;
  flex-shrink: 0;
}

/* ---------- Copy to Clipboard Button ---------- */
.btn-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--annie-border-color);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: var(--annie-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 5;
  line-height: 1;
  backdrop-filter: blur(4px);
}

.btn-copy:hover {
  background: rgb(var(--annie-primary-rgb));
  color: #fff;
  border-color: rgb(var(--annie-primary-rgb));
  transform: scale(1.05);
}

/* ---------- Copy Toast Notification ---------- */
.copy-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: #10b981;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--annie-radius);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(0);
}

.copy-toast i {
  font-size: 1rem;
}

/* ---------- Footer ---------- */
.app-footer {
  background: var(--annie-card-bg);
  border-top: 1px solid var(--annie-card-border);
  padding: 1rem 1.5rem;
  text-align: center;
  color: var(--annie-text-muted);
  font-size: 0.75rem;
  margin-top: auto;
}

.app-footer a {
  color: rgb(var(--annie-primary-rgb));
  text-decoration: none;
}

/* ---------- Grid Helpers ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
}

/* ---------- Error Page ---------- */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.error-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.error-card .error-icon {
  font-size: 3.5rem;
  color: var(--annie-text-light);
  margin-bottom: 1rem;
}

.error-card .error-title {
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.error-card .error-text {
  color: var(--annie-text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.error-card .error-details {
  text-align: left;
  padding: 1rem;
  background: #f8f9fb;
  border-radius: var(--annie-radius);
  font-size: 0.8rem;
}

.error-card .error-details ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.25rem;
  color: var(--annie-text-muted);
}

.error-card .error-details li {
  margin-bottom: 0.35rem;
}

/* ---------- Print Styles ---------- */
@media print {
  .app-header {
    position: static;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-header .btn-download {
    display: none;
  }

  .app-footer {
    page-break-before: avoid;
  }

  .annie-card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .section-header {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: #fff;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app-header {
    padding: 0 1rem;
    height: auto;
    min-height: var(--annie-header-height);
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .app-header .header-brand .brand-text small {
    display: none;
  }

  .app-content {
    padding: 1rem;
  }

  .patient-header {
    grid-template-columns: 1fr;
  }

  .patient-header .patient-field:nth-child(odd) {
    border-right: none;
  }

  .patient-header .patient-field:nth-last-child(-n+2) {
    border-bottom: 1px solid var(--annie-card-border);
  }

  .patient-header .patient-field:last-child {
    border-bottom: none;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .app-header .header-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
