/* ============================================================
   EasyMealz -- main.css
   Brand tokens, animations, modal / toast / scrollbar styles
   ALL dimensions in rem (0 px values)
   ============================================================ */

/* ----- Brand colour tokens --------------------------------- */
:root {
  /* Primary */
  --color-primary:        #f59e0b;
  --color-primary-hover:  #d97706;
  --color-primary-light:  #fbbf24;

  /* Accent */
  --color-accent:         #10b981;
  --color-accent-hover:   #059669;

  /* Danger / Warning / Info / Success */
  --color-danger:         #ef4444;
  --color-danger-hover:   #dc2626;
  --color-warning:        #f59e0b;
  --color-info:           #3b82f6;
  --color-success:        #10b981;

  /* Light-theme surfaces */
  --bg-body:              #f9fafb;
  --bg-surface:           #ffffff;
  --bg-surface-alt:       #f3f4f6;
  --text-primary:         #111827;
  --text-secondary:       #6b7280;
  --border-color:         #e5e7eb;

  /* Misc */
  --radius-sm:            0.375rem;
  --radius-md:            0.5rem;
  --radius-lg:            0.75rem;
  --radius-xl:            1rem;
  --shadow-sm:            0 0.0625rem 0.125rem rgba(0,0,0,0.05);
  --shadow-md:            0 0.25rem 0.375rem rgba(0,0,0,0.1);
  --shadow-lg:            0 0.625rem 0.9375rem rgba(0,0,0,0.1);
  --transition-fast:      150ms ease;
  --transition-base:      250ms ease;
  --transition-slow:      350ms ease;
}

/* Dark-theme overrides (applied when <html class="dark">) */
.dark {
  --bg-body:              #0f172a;
  --bg-surface:           #1e293b;
  --bg-surface-alt:       #334155;
  --text-primary:         #f1f5f9;
  --text-secondary:       #94a3b8;
  --border-color:         #334155;
}

/* ----- Base resets ----------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;            /* 1 rem = 16 px equivalent */
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-width: 22.5rem;         /* 360 px equivalent */
  line-height: 1.6;
  transition: background-color var(--transition-base),
              color var(--transition-base);
}

/* ----- Keyframe animations --------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

@keyframes slideInUp {
  from { transform: translateY(1.25rem); opacity: 0; }
  to   { transform: translateY(0);       opacity: 1; }
}

@keyframes slideOutDown {
  from { transform: translateY(0);       opacity: 1; }
  to   { transform: translateY(1.25rem); opacity: 0; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ----- Modal ---------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn var(--transition-base) forwards;
  padding: 1rem;
}

.modal-overlay.closing {
  animation: fadeOut var(--transition-base) forwards;
}

.modal-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 32rem;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--transition-base) forwards;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 0.0625rem solid var(--border-color);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast),
              background-color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-alt);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 0.0625rem solid var(--border-color);
  flex-shrink: 0;
}

/* ----- Toast notifications --------------------------------- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  pointer-events: none;
  max-width: calc(100% - 2rem);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 18rem;
  max-width: 26rem;
  animation: slideInRight var(--transition-base) forwards;
  transition: opacity var(--transition-fast);
}

.toast.closing {
  animation: slideOutRight var(--transition-base) forwards;
}

.toast-icon {
  flex-shrink: 0;
  font-size: 1.125rem;
  margin-top: 0.125rem;
}

.toast-content {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.4;
}

.toast-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 0.875rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition-fast);
}

.toast-dismiss:hover {
  opacity: 1;
}

/* Toast colour variants */
.toast--success {
  background: #065f46;
  color: #d1fae5;
}
.toast--error {
  background: #991b1b;
  color: #fee2e2;
}
.toast--warning {
  background: #92400e;
  color: #fef3c7;
}
.toast--info {
  background: #1e3a5f;
  color: #dbeafe;
}

/* Light-mode toast overrides */
html:not(.dark) .toast--success {
  background: #d1fae5;
  color: #065f46;
}
html:not(.dark) .toast--error {
  background: #fee2e2;
  color: #991b1b;
}
html:not(.dark) .toast--warning {
  background: #fef3c7;
  color: #92400e;
}
html:not(.dark) .toast--info {
  background: #dbeafe;
  color: #1e3a5f;
}

/* ----- Full-page spinner ----------------------------------- */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: fadeIn var(--transition-fast) forwards;
}

.spinner-overlay.closing {
  animation: fadeOut var(--transition-fast) forwards;
}

.spinner-circle {
  width: 3rem;
  height: 3rem;
  border: 0.25rem solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ----- Custom scrollbar (dark mode) ----------------------- */
.dark ::-webkit-scrollbar {
  width: 0.5rem;
}

.dark ::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

.dark ::-webkit-scrollbar-thumb {
  background: var(--bg-surface-alt);
  border-radius: 0.25rem;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Firefox */
.dark * {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-surface-alt) var(--bg-surface);
}

/* ----- Utility helpers ------------------------------------- */
.touch-target {
  min-width: 2.75rem;
  min-height: 2.75rem;
}

.animate-fade-in {
  animation: fadeIn var(--transition-base) forwards;
}

.animate-slide-up {
  animation: slideInUp var(--transition-base) forwards;
}

/* Buttons base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  min-height: 2.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
}

.btn:hover {
  transform: translateY(-0.0625rem);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--color-primary);
  color: #111827;
}

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

.btn-secondary {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--color-danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

/* Form elements */
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  min-height: 2.75rem;
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 0.1875rem rgba(245, 158, 11, 0.2);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

/* Card */
.card {
  background: var(--bg-surface);
  border: 0.0625rem solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: box-shadow var(--transition-fast),
              transform var(--transition-fast);
}

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