/* Food AI - Health Assistant Styling */
:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: #ecfdf5;
  --primary-dark: #065f46;
  --accent: #0284c7;
  --accent-light: #f0f9ff;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Header */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.brand-icon {
  font-size: 26px;
  background: var(--primary-light);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d1fae5;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.health-pill {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s;
}

.health-pill:hover {
  background: #e2e8f0;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: #f8fafc;
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  font-size: 16px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Tab Navigation */
.tab-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.tab-nav {
  display: flex;
  max-width: 1080px;
  width: 100%;
  padding: 0 16px;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

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

.tab-btn.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

/* Main Container */
.main-content {
  max-width: 1080px;
  margin: 20px auto;
  padding: 0 16px;
  width: 100%;
  flex: 1;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

/* Cards & Layout */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Meal Type Selector */
.meal-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.meal-option {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.meal-option.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Image Upload & Camera Box */
.upload-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 28px 16px;
  text-align: center;
  background: #fbfcfe;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.upload-dropzone:hover {
  border-color: var(--primary);
  background: #f0fdf4;
}

.upload-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-camera {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.25);
  transition: all 0.2s;
}

.btn-camera:hover {
  background: var(--primary-hover);
}

.btn-gallery {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-gallery:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Image Thumbnails Tray */
.image-tray {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.image-thumb-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1;
  background: #000;
}

.image-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* Action Button: Analyse My Intake */
.btn-analyze {
  width: 100%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}

.btn-analyze:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.btn-analyze:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Scanning Animation */
.scanner-overlay {
  display: none;
  padding: 30px;
  text-align: center;
}

.scanner-overlay.active {
  display: block;
}

.pulse-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 16px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Results Dashboard */
.analysis-result-view {
  display: none;
}

.analysis-result-view.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.badge-status {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-safe {
  background: #dcfce7;
  color: #15803d;
}

.badge-caution {
  background: #fef3c7;
  color: #b45309;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}

@media (max-width: 600px) {
  .macro-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.macro-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: center;
}

.macro-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.macro-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.item-row:last-child {
  border-bottom: none;
}

.alert-card {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  font-size: 13px;
  display: flex;
  gap: 10px;
  line-height: 1.4;
}

.alert-warning {
  background: var(--warning-light);
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-safe {
  background: var(--primary-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-critical {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: var(--accent-light);
  border: 1px solid #bae6fd;
  color: #075985;
}

/* Medical History Chips */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  user-select: none;
}

.chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: white;
  width: 100%;
  max-width: 460px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.modal-body {
  padding: 20px;
}

.btn-social {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.btn-social:hover {
  background: #f8fafc;
}

.btn-google {
  color: #1f2937;
}

.btn-apple {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}

.btn-apple:hover {
  background: #18181b;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider:not(:empty)::before {
  margin-right: 0.5em;
}

.divider:not(:empty)::after {
  margin-left: 0.5em;
}

.input-group {
  margin-bottom: 14px;
}

.input-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.input-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  display: none;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}


/* =========================================================
   LAB REPORT BIOMARKER TABLE
   ========================================================= */

.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lab-table thead tr {
  background: #f8fafc;
  text-align: left;
}

.lab-table th {
  padding: 10px 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.lab-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

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

.lab-table tbody tr:hover {
  filter: brightness(0.97);
}

/* Status badges */
.lab-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.lab-badge-high {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.lab-badge-low {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.lab-badge-normal {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Lab report card pulse animation on fresh upload */
@keyframes labCardHighlight {
  0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

#lab-report-card.highlight {
  animation: labCardHighlight 0.8s ease-out;
}

/* =========================================================
   GOOGLE OAUTH ACCOUNT CHOOSER MODAL (AUTHENTIC GOOGLE UI)
   ========================================================= */

#google-oauth-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.google-chooser-card {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  padding: 32px 32px 24px;
  position: relative;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  box-sizing: border-box;
}

.google-chooser-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 20px;
  color: #5f6368;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.google-chooser-close:hover {
  background: #f1f3f4;
  color: #202124;
}

.google-chooser-logo {
  margin-bottom: 12px;
}

.google-chooser-title {
  font-size: 24px;
  font-weight: 500;
  color: #202124;
  margin: 0 0 6px 0;
  letter-spacing: -0.2px;
}

.google-chooser-subtitle {
  font-size: 14px;
  color: #5f6368;
  margin: 0 0 24px 0;
}

.google-chooser-subtitle strong {
  color: #202124;
  font-weight: 600;
}

.google-accounts-list {
  border-top: 1px solid #dadce0;
  margin-bottom: 8px;
}

.google-acc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-bottom: 1px solid #dadce0;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 4px;
}

.google-acc-row:hover {
  background: #f8f9fa;
}

.google-acc-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.google-acc-info {
  flex: 1;
  min-width: 0;
}

.google-acc-name {
  font-size: 14px;
  font-weight: 600;
  color: #202124;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.google-acc-email {
  font-size: 12px;
  color: #5f6368;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.google-acc-status {
  font-size: 12px;
  color: #5f6368;
  padding-left: 8px;
  flex-shrink: 0;
}

.google-acc-action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 8px;
  border-bottom: 1px solid #dadce0;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 4px;
  color: #202124;
}

.google-acc-action-row:hover {
  background: #f8f9fa;
}

.google-acc-action-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5f6368;
  border: 1px solid #dadce0;
  font-size: 16px;
  flex-shrink: 0;
}

.google-acc-action-label {
  font-size: 14px;
  font-weight: 500;
  color: #202124;
}

.google-chooser-footer {
  font-size: 12px;
  color: #5f6368;
  line-height: 1.5;
  margin-top: 20px;
}

.google-chooser-footer a {
  color: #1a73e8;
  text-decoration: none;
}

.google-chooser-footer a:hover {
  text-decoration: underline;
}

/* Custom account input pane inside Google modal */
#google-custom-account-form {
  display: none;
  border-top: 1px solid #dadce0;
  padding-top: 16px;
  margin-top: 8px;
}
