@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  /* Warm Culinary Palette (Mockup Version B) */
  --bg-primary: #f7f6f4;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #faf9f7;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #faf9f7;

  --text-primary: #171513;
  --text-secondary: #665c54;
  --text-muted: #898582;

  --border-color: #e1ddda;
  --border-glow: #d4d1cf;

  --color-primary: #493b31;
  --color-primary-soft: #f4f1ef;

  /* Macronutrient Colors */
  --color-prot: #991b1b;
  --color-prot-bg: linear-gradient(135deg, #f8ddd6, #fbece7);
  --color-prot-border: #fca5a5;

  --color-veg: #166534;
  --color-veg-bg: linear-gradient(135deg, #e5f6df, #c9ebc3);
  --color-veg-border: #86efac;

  --color-carb: #78350f;
  --color-carb-bg: linear-gradient(135deg, #f0e9e4, #e5dbd5);
  --color-carb-border: #fde047;

  --color-fat: #9a3412;
  --color-fat-bg: linear-gradient(135deg, #fbf4cf, #f5e9a7);
  --color-fat-border: #fb923c;

  /* Glassmorphism */
  --glass-blur: blur(12px);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(32, 50, 74, 0.06);
  --shadow-md: 0 12px 30px rgba(32, 50, 74, 0.12);
  --shadow-glow: 0 6px 18px rgba(51, 103, 200, 0.1);

  --font-family: 'DM Sans', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
}

@media (min-width: 1024px) {
  html, body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }
}

/* Layout Header */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 246, 244, 0.94);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: transparent;
}

.brand-icon svg {
  display: block;
  stroke: var(--text-primary);
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.brand span.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #ede9e6;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
}

/* Main Nav Tabs */
nav.app-nav {
  display: flex;
  background: #ede9e6;
  border: 1px solid var(--border-color);
  padding: 3px 4px;
  border-radius: var(--radius-full);
  gap: 3px;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.18s ease;
}

.nav-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.nav-tab-icon svg {
  display: block;
  stroke: currentColor;
  transition: transform 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab:hover .nav-tab-icon svg {
  transform: scale(1.08);
}

.nav-tab.active {
  background: #ffffff;
  color: var(--text-primary);
  border: none;
  box-shadow: 0 2px 6px rgba(37, 30, 23, 0.09);
  font-weight: 600;
}

/* Main Container */
main.app-main {
  flex: 1;
  max-width: 1650px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Utility buttons */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 3px 8px rgba(51, 103, 200, 0.18);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(51, 103, 200, 0.22);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background: #fff0ee;
  color: #b83c37;
  border: 1px solid #f3c4bf;
}

.btn-danger:hover {
  background: #ffe4e0;
  color: #a42f2a;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Footer */
footer.app-footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem 2rem;
  text-align: center;
  font-size: 0.825rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive adjustments */
@media (max-width: 1023px) {
  header.app-header {
    height: 52px;
    padding: 0 1rem;
    padding-top: env(safe-area-inset-top, 0px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(247, 246, 244, 0.94);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: static;
  }

  .brand {
    gap: 0.45rem;
  }

  .brand-icon {
    width: auto;
    height: auto;
    font-size: 1.25rem;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .brand h1 {
    font-size: 1.15rem;
    font-weight: 750;
    color: var(--text-primary);
    letter-spacing: -0.03em;
  }

  .brand span.tag,
  .brand div div:nth-child(2) {
    display: none !important;
  }

  nav.app-nav {
    padding: 3px 4px;
    gap: 2px;
    border-radius: var(--radius-full);
    overflow: visible;
    background: #ede9e6;
    border: 1px solid var(--border-color);
  }

  .nav-tab {
    padding: 0.45rem 0.65rem;
    min-width: 38px;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    gap: 0.25rem;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.18s ease;
  }

  .nav-tab:hover {
    color: var(--text-primary);
  }

  .nav-tab.active {
    background: #ffffff;
    color: var(--text-primary);
    box-shadow: 0 2px 6px rgba(37, 30, 23, 0.1);
  }

  .nav-tab .nav-tab-label {
    display: none;
  }

  main.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    height: 100%;
    min-height: 0;
    max-width: 100%;
  }

  .tab-pane {
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: none;
  }

  .tab-pane.active {
    display: flex;
    flex-direction: column;
  }

  /* Pestañas secundarias scrolleables de forma independiente */
  #library.tab-pane.active,
  #planner.tab-pane.active,
  #settings.tab-pane.active {
    display: block;
    overflow-y: auto;
    padding: 0.85rem;
    -webkit-overflow-scrolling: touch;
  }

  footer.app-footer {
    display: none !important;
  }
}
