/* ==========================================================================
   PlanifCook Design System & Responsive Foundation (PWA Ready)
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Brand Palette: Warm Culinary Orange */
  --brand-50: #fff7ed;
  --brand-100: #ffedd5;
  --brand-200: #fed7aa;
  --brand-300: #fdba74;
  --brand-400: #fb923c;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --brand-800: #9a3412;
  --brand-900: #7c2d12;

  /* Sage Green Palette */
  --sage-50: #f4f7f4;
  --sage-100: #e5ece5;
  --sage-200: #cbdbcb;
  --sage-300: #a5c1a5;
  --sage-400: #7aa07a;
  --sage-500: #5a825a;
  --sage-600: #456645;
  --sage-700: #385238;
  --sage-800: #2f412f;

  /* Slate / Dark neutrals */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Elevation Shadows */
  --shadow-2xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-xs: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 25px -5px rgba(249, 115, 22, 0.25);

  /* Safe Area Variables */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

[x-cloak] {
  display: none !important;
}

html {
  font-family: var(--font-sans);
  color: var(--slate-800);
  background-color: var(--slate-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: var(--sal);
  padding-right: var(--sar);
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 100%;
}

/* Empêcher le zoom automatique intempestif sur mobile lors du focus d'un champ de saisie */
@media screen and (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Touch targets >= 44px for primary interactions */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Base Component Classes */
.card {
  background-color: #ffffff;
  border-radius: 1.5rem;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-soft);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 700;
  border-radius: 0.875rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: all 0.15s ease-in-out;
  cursor: pointer;
  border: none;
  min-height: 40px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--brand-500);
  color: #ffffff;
  box-shadow: 0 4px 12px -2px rgba(249, 115, 22, 0.25);
}

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

.btn-secondary {
  background-color: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.btn-secondary:hover {
  background-color: var(--slate-200);
  color: var(--slate-900);
}

.btn-dark {
  background-color: var(--slate-900);
  color: #ffffff;
}

.btn-dark:hover {
  background-color: var(--slate-800);
}

/* Form Controls */
.form-control {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--slate-200);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--slate-800);
  background-color: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 42px;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-600);
  margin-bottom: 0.375rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.badge-primary {
  background-color: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-200);
}

/* Glassmorphism */
.glass-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

/* Horizontal Scroll Utilities */
.scroll-x-smooth {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Responsive Table Container with subtle scroll hint */
.responsive-table-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 1rem;
}

.responsive-table-container::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  pointer-events: none;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.05), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.responsive-table-container.has-scroll-right::after {
  opacity: 1;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--slate-200);
  padding-bottom: max(0.5rem, var(--sab));
  padding-top: 0.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.04);
}

.mobile-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--slate-500);
  transition: color 0.15s ease;
  min-height: 44px;
}

.mobile-bottom-nav-item.active {
  color: var(--brand-600);
  font-weight: 800;
}

.mobile-bottom-nav-item.active .nav-icon-wrapper {
  background-color: var(--brand-50);
  color: var(--brand-600);
  border-radius: 0.75rem;
}

.mobile-bottom-nav-item .nav-icon-wrapper {
  width: 32px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
  overscroll-behavior: contain;
}

.modal-dialog {
  background: #ffffff;
  border-radius: 1.5rem;
  max-width: 32rem;
  width: 100%;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--slate-100);
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .modal-dialog {
    padding: 1.75rem;
  }
}

@media (max-width: 639px) {
  .modal-dialog {
    padding: 1.25rem;
    border-radius: 1.25rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Keyboard Shortcut Key Pill */
.kbd-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  background-color: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-radius: 0.375rem;
  color: var(--slate-600);
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}
