/* ========================================
   PantryClean - Minimal Styles (~500 lines)
   ======================================== */

/* --- VARIABLES --- */
:root {
  --navy: #0a2540;
  --teal: #0ea5a3;
  --white: #fff;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #6c757d;
  --gray-700: #495057;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font: "Segoe UI", sans-serif;
  --font-mono: "SF Mono", monospace;
  --radius: 8px;
}

/* --- RESET --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 1rem; line-height: 1.5; color: var(--navy); background: var(--white); min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- UTILITIES --- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.container { max-width: 1400px; margin: 0 auto; padding: 0 1rem; }

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-weight: 500;
  border-radius: var(--radius);
}
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--gray-200); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.875rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.125rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- NAVBAR --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
}
.navbar-landing { background: var(--navy); border: none; }
.nav-container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.25rem; color: var(--navy); }
.logo svg { color: var(--teal); }
.navbar-landing .logo { color: var(--white); }
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a:not(.btn) { color: var(--gray-700); font-weight: 500; }
.nav-links a:not(.btn):hover { color: var(--teal); }
.navbar-landing .nav-links a:not(.btn) { color: rgba(255,255,255,0.8); }
.navbar-landing .theme-toggle { 
  background: rgba(255,255,255,0.15); 
  border-color: rgba(255,255,255,0.3); 
  color: var(--white); 
}
.navbar-landing .theme-toggle:hover { 
  background: rgba(255,255,255,0.25); 
}
.mobile-menu-btn { display: none; padding: 0.5rem; color: var(--navy); }
.navbar-landing .mobile-menu-btn { color: var(--white); }
.mobile-menu { display: none; position: fixed; top: 60px; left: 0; right: 0; background: var(--white); padding: 1rem; flex-direction: column; gap: 0.75rem; border-bottom: 1px solid var(--gray-300); z-index: 100; }
.mobile-menu.active { display: flex; }
.mobile-menu a { padding: 0.5rem 0; font-weight: 500; color: var(--navy); }

/* --- HERO (Landing) --- */
.hero { padding: calc(60px + 2rem) 0 2rem; background: var(--navy); }
.hero .container { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center; }
.hero-badge { display: inline-block; padding: 0.25rem 0.75rem; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); border-radius: 50px; font-size: 0.875rem; color: var(--white); margin-bottom: 1rem; }
.hero-title { font-size: 2.5rem; margin-bottom: 1rem; color: var(--white); }
.hero-title .highlight { color: var(--teal); }
.hero-subtitle { font-size: 1.125rem; color: rgba(255,255,255,0.85); margin-bottom: 1.5rem; }
.hero-cta { display: flex; gap: 1rem; }
.hero-stats { display: flex; gap: 2rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.2); }
.stat { text-align: center; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--white); }
.stat-label { font-size: 0.875rem; color: rgba(255,255,255,0.7); }
.hero-visual { display: flex; justify-content: center; }
.preview-card { background: var(--navy); border-radius: var(--radius); overflow: hidden; max-width: 400px; border: 1px solid rgba(255,255,255,0.1); }
.preview-header { display: flex; gap: 0.5rem; padding: 0.5rem 1rem; background: #061729; }
.preview-header .dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27ca3f; }
.preview-content { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.preview-input code { font-family: var(--font-mono); font-size: 0.875rem; color: var(--gray-500); display: block; }
.preview-arrow { text-align: center; color: var(--teal); }
.preview-row { display: flex; gap: 0.5rem; padding: 0.25rem 0.5rem; background: rgba(255,255,255,0.05); border-radius: 4px; font-family: var(--font-mono); font-size: 0.875rem; color: var(--white); }
.preview-row.flagged { border-left: 2px solid var(--warning); }
.preview-row .qty { color: var(--teal); min-width: 30px; }
.preview-row .unit { color: var(--gray-500); min-width: 25px; }

/* --- APP PAGE --- */
.app-page { background: var(--gray-100); min-height: 100vh; }
.app-main { padding-top: 60px; flex: 1; }
.app-section-full { padding: 1.5rem 0; }
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 1rem; }
.app-header h1 { font-size: 1.5rem; color: var(--navy); }
.app-controls { display: flex; gap: 0.75rem; }

/* --- APP LAYOUT (3-panel grid) --- */
.app-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  min-height: calc(100vh - 160px);
}

/* Input panel - top left, wide and short */
.input-panel {
  grid-column: 1;
  grid-row: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.panel-header h3 { font-size: 1rem; font-weight: 600; }
.sample-select { padding: 0.25rem 0.75rem; font-size: 0.875rem; border: 1px solid var(--gray-300); border-radius: var(--radius); background: var(--white); }
.recipe-textarea {
  width: 100%;
  height: 100px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  resize: none;
}
.recipe-textarea:focus { outline: none; border-color: var(--teal); }
.input-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.shortcut-hint { font-size: 0.75rem; color: var(--gray-500); }

/* Alternatives panel - top right */
.alternatives-panel {
  grid-column: 2;
  grid-row: 1;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-y: auto;
  max-height: 180px;
}

/* Notes panel - bottom right */
.notes-panel {
  grid-column: 2;
  grid-row: 2;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.notes-panel h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.notes-textarea {
  flex: 1;
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
  line-height: 1.5;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  resize: none;
  background: var(--gray-100);
}
.notes-textarea:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--white);
}
.alternatives-panel h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }
.alt-list { display: flex; flex-direction: column; gap: 0.5rem; }
.alt-item {
  padding: 0.5rem 0.75rem;
  background: var(--gray-100);
  border-radius: var(--radius);
  border-left: 3px solid var(--teal);
  font-size: 0.8rem;
}
.alt-item-header { font-weight: 600; color: var(--navy); }
.alt-item-sub { font-size: 0.7rem; color: var(--gray-500); margin-top: 0.25rem; }
.alt-empty { color: var(--gray-500); font-size: 0.8rem; text-align: center; padding: 1rem; }
/* Results panel - bottom left */
.results-panel {
  grid-column: 1;
  grid-row: 2;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.export-buttons { display: flex; gap: 0.25rem; }
.results-container { flex: 1; overflow: auto; border: 1px solid var(--gray-300); border-radius: var(--radius); }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 200px; color: var(--gray-500); }
.empty-state svg { margin-bottom: 0.5rem; opacity: 0.3; }

/* Results table */
.results-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.results-table th, .results-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
.results-table th { background: var(--gray-100); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; color: var(--gray-700); position: sticky; top: 0; }
.results-table tbody tr:hover { background: var(--gray-100); }
.results-table .original-cell { font-family: var(--font-mono); font-size: 0.75rem; color: var(--gray-700); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-table .qty-cell { font-weight: 600; color: var(--teal); }
.results-table .status-cell { text-align: center; }
.status-icon { cursor: pointer; position: relative; }
.results-legend { display: flex; gap: 1rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--gray-200); font-size: 0.75rem; color: var(--gray-500); }


/* --- TOOLTIP --- */
.tooltip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 0.25rem 0.5rem; background: var(--navy); color: var(--white); font-size: 0.75rem; border-radius: 4px; white-space: nowrap; opacity: 0; visibility: hidden; z-index: 100; }
.tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--navy); }
.status-icon:hover .tooltip { opacity: 1; visibility: visible; }

/* --- MODAL --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 1000; opacity: 0; visibility: hidden; }
.modal-overlay:not([hidden]) { opacity: 1; visibility: visible; }
.modal { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 480px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-lg { max-width: 640px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { font-size: 1.125rem; }
.modal-close { padding: 0.25rem; color: var(--gray-500); }
.modal-close:hover { color: var(--navy); }
.modal-body { padding: 1rem; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; padding: 1rem; border-top: 1px solid var(--gray-200); }

/* --- EDITOR MODAL --- */
.editor-original, .editor-parsed, .editor-reason, .editor-suggestions, .editor-custom { margin-bottom: 1rem; }
.editor-original label, .editor-parsed label, .editor-reason label, .editor-suggestions label, .editor-custom label { display: block; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--gray-500); margin-bottom: 0.25rem; }
.editor-original p { font-family: var(--font-mono); font-size: 0.875rem; padding: 0.5rem; background: var(--gray-100); border-radius: 4px; }
.parsed-preview { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.parsed-preview span { padding: 0.25rem 0.5rem; background: var(--gray-200); border-radius: 4px; font-size: 0.875rem; }
.parsed-preview .qty { color: var(--teal); font-weight: 600; }
.parsed-preview .unit { color: var(--gray-500); }
.parsed-preview .ing { color: var(--navy); }
.editor-reason p { font-size: 0.875rem; color: var(--warning); background: rgba(245,158,11,0.1); padding: 0.5rem; border-radius: 4px; border-left: 3px solid var(--warning); }
.suggestion-list { display: flex; flex-direction: column; gap: 0.25rem; }
.suggestion-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; background: var(--gray-100); border-radius: 4px; cursor: pointer; }
.suggestion-item:hover { background: var(--gray-200); }
.suggestion-item input[type="radio"] { accent-color: var(--teal); }
.suggestion-item label { flex: 1; cursor: pointer; font-size: 0.875rem; }
.custom-inputs { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.custom-inputs input, .custom-inputs select { flex: 1; padding: 0.5rem; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 0.875rem; }
.custom-inputs input:focus, .custom-inputs select:focus { outline: none; border-color: var(--teal); }
/* --- CORRECTIONS MODAL --- */
.corrections-info { font-size: 0.875rem; color: var(--gray-700); margin-bottom: 1rem; }
.corrections-info kbd { padding: 2px 6px; background: var(--gray-200); border: 1px solid var(--gray-300); border-radius: 4px; font-family: var(--font-mono); font-size: 0.75rem; }
.corrections-list { display: flex; flex-direction: column; gap: 0.5rem; }
.correction-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem; background: var(--gray-100); border-radius: var(--radius); }
.correction-key { font-family: var(--font-mono); font-size: 0.875rem; color: var(--navy); }
.correction-value { font-size: 0.875rem; color: var(--gray-700); }
.correction-actions button { padding: 0.25rem; color: var(--gray-500); }
.correction-actions button:hover { color: var(--danger); }
.corrections-empty { text-align: center; padding: 2rem; color: var(--gray-500); }

/* --- SETTINGS MODAL --- */
.settings-info { font-size: 0.875rem; color: var(--gray-700); margin-bottom: 1.5rem; padding: 0.75rem; background: var(--gray-100); border-radius: var(--radius); border-left: 3px solid var(--teal); }
.settings-section { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--gray-200); }
.settings-section:last-of-type { border-bottom: none; }
.settings-section-title { font-weight: 600; margin-bottom: 0.25rem; }
.settings-section-desc { font-size: 0.875rem; color: var(--gray-500); margin-bottom: 0.75rem; }
.settings-toggle-group { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.settings-radio-card { position: relative; cursor: pointer; }
.settings-radio-card input[type="radio"] { position: absolute; opacity: 0; }
.radio-card-content { display: flex; flex-direction: column; align-items: center; padding: 1rem; background: var(--gray-100); border: 2px solid var(--gray-300); border-radius: var(--radius); text-align: center; }
.settings-radio-card input[type="radio"]:checked + .radio-card-content { border-color: var(--teal); background: rgba(14,165,163,0.08); }
.radio-card-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.radio-card-label { font-weight: 600; }
.radio-card-desc { font-size: 0.75rem; color: var(--gray-500); }
.settings-select { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--gray-300); border-radius: var(--radius); }
.settings-reset button { color: var(--gray-500); }
.settings-reset button:hover { color: var(--danger); }
/* --- TOAST --- */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(100px); display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; background: var(--navy); color: var(--white); border-radius: var(--radius); z-index: 1100; opacity: 0; }
.toast:not([hidden]) { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-icon { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; background: var(--success); border-radius: 50%; font-size: 0.75rem; }

/* --- FOOTER --- */
.footer { padding: 1.5rem 0; background: var(--navy); color: var(--white); margin-top: auto; }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; text-align: center; }
.footer-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.footer-brand svg { color: var(--teal); }
.privacy-note { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: rgba(255,255,255,0.7); }
.privacy-note svg { color: var(--success); }
.footer-credit { font-size: 0.75rem; color: rgba(255,255,255,0.5); }

/* --- THEME TOGGLE --- */
.theme-toggle { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  width: 40px; 
  height: 40px; 
  background: rgba(255,255,255,0.15); 
  border: 2px solid rgba(255,255,255,0.3); 
  border-radius: 50%; 
  color: var(--white); 
  cursor: pointer; 
  position: relative; 
  overflow: hidden;
  transition: all 0.2s ease;
  z-index: 10;
}
.theme-toggle:hover { 
  background: rgba(255,255,255,0.25); 
  transform: scale(1.05);
}
.theme-toggle svg { 
  position: absolute; 
  transition: all 0.3s ease;
}
.theme-toggle .sun-icon { opacity: 0; transform: rotate(-90deg) scale(0); }
.theme-toggle .moon-icon { opacity: 1; transform: rotate(0deg) scale(1); }
.app-page .theme-toggle { 
  background: var(--teal); 
  border-color: var(--teal); 
  color: var(--white); 
}
.app-page .theme-toggle:hover {
  background: #0b8483;
}
[data-theme="dark"] .app-page .theme-toggle {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--navy);
}
.theme-toggle-mobile {
  width: 100%;
  height: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  justify-content: flex-start;
  gap: 0.75rem;
  background: var(--gray-100);
  border-color: var(--gray-300);
  color: var(--navy);
}
.theme-toggle-mobile svg { position: relative; }
.theme-toggle-mobile::after { content: 'Toggle Theme'; font-weight: 500; }

/* --- LIGHT THEME --- */
/* Dark theme - landing page */
[data-theme="dark"] { background: var(--navy); }
[data-theme="dark"] body { background: var(--navy); }
[data-theme="dark"] main { background: var(--navy); }
[data-theme="dark"] .hero { background: var(--navy); }
[data-theme="dark"] .footer { background: #071422; }

[data-theme="light"] .navbar-landing { background: var(--white); border-bottom: 1px solid var(--gray-200); }
[data-theme="light"] .navbar-landing .logo { color: var(--navy); }
[data-theme="light"] .navbar-landing .nav-links a:not(.btn) { color: var(--gray-700); }
[data-theme="light"] .hero { background: var(--gray-100); }
[data-theme="light"] .hero-title { color: var(--navy); }
[data-theme="light"] .hero-subtitle { color: var(--gray-700); }
[data-theme="light"] .hero-badge { background: rgba(14,165,163,0.1); border-color: var(--teal); color: var(--teal); }
[data-theme="light"] .hero-stats { border-color: var(--gray-300); }
[data-theme="light"] .stat-value { color: var(--navy); }
[data-theme="light"] .stat-label { color: var(--gray-500); }
[data-theme="light"] .theme-toggle { 
  background: rgba(10,37,64,0.1); 
  border-color: rgba(10,37,64,0.2); 
  color: var(--navy); 
}
[data-theme="light"] .theme-toggle .sun-icon { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle .moon-icon { opacity: 0; transform: rotate(90deg) scale(0); }

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
  .hero .container { grid-template-columns: 1fr; text-align: center; }
  .hero-cta { justify-content: center; }
  .hero-visual { order: -1; }
  .app-grid { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; }
  .input-panel { grid-column: 1; grid-row: 1; }
  .results-panel { grid-column: 1; grid-row: 2; }
  .alternatives-panel { grid-column: 1; grid-row: 3; max-height: none; }
  .notes-panel { grid-column: 1; grid-row: 4; }
}
@media (max-width: 768px) {
  .nav-links { display: none; }
  .mobile-menu-btn { display: block; }
  .hero-title { font-size: 2rem; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .app-controls { width: 100%; justify-content: space-between; }
  .pie-chart-container { flex-direction: column; }
}

@media (max-width: 480px) {
  .container { padding: 0 0.75rem; }
  .hero-title { font-size: 1.5rem; }
  .hero-cta { flex-direction: column; width: 100%; }
  .hero-cta .btn { width: 100%; }
  .custom-inputs { flex-direction: column; }
  .settings-toggle-group { grid-template-columns: 1fr; }
}

/* --- ACCESSIBILITY --- */
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
