/**
 * Desktop-first shell + comfortable density.
 * Overrides medic-shell's aggressive shrink / cramped sidebar.
 */

:root {
  --app-ink: #111827;
  --app-muted: #6b7280;
  --app-line: #e5e7eb;
  --app-surface: #ffffff;
  --app-page: #f3f4f6;
  --app-primary: #1e4d7b;
  --app-primary-dark: #153a5c;
  --app-sidebar-w: 16.5rem;
  --font-app: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

html {
  font-size: 16px !important;
}

.medic-shell-body {
  font-family: var(--font-app);
  color: var(--app-ink);
  background: var(--app-page);
  letter-spacing: -0.01em;
}

/* Kill medic-shell viewport font/sidebar crush */
@media (max-width: 1024px) {
  :root,
  html {
    font-size: 15px !important;
  }

  .main-content {
    padding: 1.25rem 1.15rem 1.75rem !important;
  }

  button:not(#top-header button):not(#sidebar button):not(.hotel-pos-card):not(.hotel-pos-tab),
  .btn,
  a[role="button"]:not(#top-header a) {
    padding: 0.55rem 1rem !important;
    font-size: 0.875rem !important;
    min-height: auto;
  }

  .main-content .card,
  .main-content [class*="rounded-lg"],
  .main-content [class*="rounded-xl"] {
    padding: inherit;
  }
}

@media (max-width: 800px) {
  :root,
  html {
    font-size: 15px !important;
  }

  .main-content {
    padding: 1rem 0.9rem 1.5rem !important;
  }
}

@media (min-width: 1024px) {
  :root,
  html {
    font-size: 16px !important;
  }

  #sidebar {
    width: var(--app-sidebar-w) !important;
  }

  .medic-main,
  .footer-content {
    margin-left: var(--app-sidebar-w) !important;
  }

  body.htl-sidebar-hidden .medic-main,
  body.htl-sidebar-hidden .footer-content,
  html.htl-sidebar-hidden .medic-main,
  html.htl-sidebar-hidden .footer-content {
    margin-left: 0 !important;
  }

  .main-content {
    padding: 1.25rem 1.25rem 1.75rem !important;
  }
}

@media (min-width: 1400px) {
  :root {
    --app-sidebar-w: 17rem;
  }

  .main-content {
    padding: 1.35rem 1.5rem 2rem !important;
  }
}

@media (max-width: 1023px) {
  #sidebar,
  .htl-sidebar {
    width: min(20rem, 92vw) !important;
  }

  .medic-main,
  .footer-content {
    margin-left: 0 !important;
  }
}

/* ——— Sidebar density (keep compact; htl-sidebar.css is source of truth) ——— */
#sidebar {
  width: var(--app-sidebar-w) !important;
}

.sidebar-header {
  padding: 0.65rem 0.75rem !important;
  gap: 0.5rem;
}

.sidebar-header-text span:first-child,
.sidebar-header .text-sm {
  font-size: 0.8125rem !important;
  line-height: 1.25 !important;
  font-weight: 700 !important;
}

.sidebar-header-subtitle {
  margin-top: 0.05rem !important;
  font-size: 0.625rem !important;
  color: #9ca3af !important;
}

.sidebar-search {
  margin: 0.45rem 0.6rem 0.25rem !important;
}

.sidebar-search input {
  min-height: 2.1rem !important;
  padding: 0.35rem 0.6rem 0.35rem 2.1rem !important;
  font-size: 0.8125rem !important;
  border-radius: 0.5rem !important;
  border-color: #e5e7eb !important;
  background: #f9fafb !important;
}

.sidebar-search input:focus {
  border-color: #6ee7b7 !important;
  background: #fff !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12) !important;
}

.sidebar-search-icon {
  left: 0.65rem !important;
}

#sidebarMenu {
  padding-bottom: 0.5rem !important;
}

.menu-section + .menu-section {
  margin-top: 0.15rem;
  padding-top: 0;
}

.sidebar-section-header {
  font-size: 0.625rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
  color: #94a3b8 !important;
  padding: 0.55rem 0.85rem 0.2rem !important;
  margin-top: 0 !important;
}

#sidebarMenu > .menu-section:first-child > .sidebar-section-header:first-child {
  padding-top: 0.35rem !important;
}

.sidebar-menu-item {
  min-height: 2.15rem !important;
  padding: 0.4rem 0.55rem !important;
  margin: 0.05rem 0.35rem !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  border-radius: 0.5rem !important;
  gap: 0.5rem;
}

#sidebar .sidebar-menu-item,
#sidebar a.sidebar-menu-item,
#sidebar button.sidebar-menu-item {
  padding: 0.4rem 0.55rem !important;
  font-size: 0.8125rem !important;
  min-height: 2.15rem !important;
}

.sidebar-menu-item .sidebar-menu-icon,
.sidebar-menu-icon {
  width: 1.5rem !important;
  height: 1.5rem !important;
  font-size: 0.7rem !important;
  margin-right: 0 !important;
  opacity: 1;
}

.sidebar-sub-item {
  min-height: 1.9rem !important;
  padding: 0.35rem 0.55rem !important;
  margin: 0.05rem 0 !important;
  font-size: 0.8125rem !important;
  border-radius: 0.4rem !important;
}

.sidebar-sub-panel {
  margin: 0.1rem 0.35rem 0.25rem 0.55rem !important;
  padding: 0 !important;
}

/* Top bar */
#top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-line);
}

.app-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.65rem 0.3rem 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--app-line);
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--app-ink);
  cursor: pointer;
}

.app-user-btn .avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #2a6a9e, #1e4d7b);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.app-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  width: 13rem;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: 0.75rem;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.12);
  padding: 0.4rem;
  z-index: 60;
}

.app-user-menu a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--app-ink);
  text-decoration: none;
}

.app-user-menu a:hover {
  background: #f9fafb;
}

.app-user-menu a.is-danger {
  color: #b91c1c;
}

.app-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.65rem;
  color: #6b7280;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.app-menu-btn:hover {
  background: #f3f4f6;
  color: var(--app-ink);
}

.htl-bottom-nav {
  display: none !important;
}

/* Content uses full available width */
.content-container {
  max-width: none !important;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.main-content {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.medic-main > .main-content > .content-container {
  max-width: none !important;
  width: 100% !important;
}

.htl-page-head {
  margin-bottom: 1.5rem !important;
  gap: 1rem !important;
}

.htl-page-head h1 {
  font-size: 1.5rem !important;
}

.htl-page-head p {
  margin-top: 0.35rem !important;
  font-size: 0.875rem !important;
  line-height: 1.45 !important;
}

.htl-table th,
.htl-table td {
  padding: 0.9rem 1.05rem !important;
}

.htl-table th {
  font-size: 0.72rem !important;
}

.htl-table td {
  font-size: 0.875rem !important;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #f8fafc 0%, #e8f0f7 45%, #f3f4f6 100%);
  font-family: var(--font-app);
}

.login-shell {
  width: 100%;
  max-width: 54rem;
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: 1rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .login-shell {
    grid-template-columns: 1.15fr 0.85fr;
  }
}

.login-main {
  padding: 2rem 1.75rem;
}

@media (min-width: 768px) {
  .login-main {
    padding: 2.75rem 2.5rem;
  }
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand .mark {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.85rem;
  border-radius: 0.75rem;
  background: #1e4d7b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--app-ink);
}

.login-brand p {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--app-muted);
}

.login-form label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #334155;
}

.login-form input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.55rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.9375rem;
  margin-bottom: 1.1rem;
}

.login-form input:not([type="checkbox"]):not([type="radio"]):focus {
  outline: none;
  border-color: #1e4d7b;
  box-shadow: 0 0 0 3px rgba(30, 77, 123, 0.18);
}

.login-form .login-remember {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  line-height: 1.25;
}

.login-form .login-remember input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: #1e4d7b;
  vertical-align: middle;
}

.login-form .login-remember span {
  line-height: 1.25;
}

.login-form button {
  width: 100%;
  border: 0;
  border-radius: 0.55rem;
  background: #1e4d7b;
  color: #fff;
  font-weight: 650;
  font-size: 0.9375rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
}

.login-form button:hover {
  background: #153a5c;
}

.login-error {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.55rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.875rem;
  font-weight: 600;
}

.login-side {
  background: linear-gradient(160deg, #153a5c 0%, #1e4d7b 55%, #2a6a9e 100%);
  color: #fff;
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-side h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-side p {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

.login-side a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 0.55rem;
  padding: 0.7rem 1rem;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  font-size: 0.875rem;
}

.login-side a:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 767px) {
  .login-side {
    order: 2;
  }
}

/* Meals admin spacing */
.meals-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 1100px) {
  .meals-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(21rem, 0.85fr);
    gap: 1.75rem;
  }
}

.meals-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.meals-tabs a {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--app-line);
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
}

.meals-tabs a.is-on {
  background: #e8f0f7;
  border-color: #6ee7b7;
  color: #153a5c;
}

.meals-form-card,
.meals-list-card {
  background: #fff;
  border: 1px solid var(--app-line);
  border-radius: 0.85rem;
  padding: 1.35rem 1.4rem;
}

.meals-form-card h2,
.meals-list-card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}

.meals-form-card .hint {
  font-size: 0.8125rem;
  color: var(--app-muted);
  margin-bottom: 1.15rem;
  line-height: 1.45;
}

.meals-form-card label.meals-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.875rem;
  font-weight: 650;
  color: #0f172a;
  margin-bottom: 0.35rem;
  cursor: pointer;
}
.meals-form-card label.meals-check input {
  width: auto;
  margin: 0;
  accent-color: #1e4d7b;
}
.meals-form-card #mealRecipeHint {
  margin-top: 0;
  margin-bottom: 1rem;
}
.meals-form-card .hidden,
.meals-form-card #recipeBlock.hidden,
.meals-form-card #mealStockBlock.hidden {
  display: none !important;
}

.meals-form-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 650;
  color: #334155;
  margin-bottom: 0.35rem;
}

.meals-form-card input,
.meals-form-card select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.55rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  background: #fff;
}

.meals-form-card .row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.meals-comp-row {
  display: grid;
  grid-template-columns: 1fr 5rem 2.35rem;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.55rem;
}

.meals-comp-row input,
.meals-comp-row select {
  margin-bottom: 0;
}

.meals-comp-row .rm {
  height: 2.4rem;
  border: 0;
  border-radius: 0.5rem;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 700;
  cursor: pointer;
}

.meals-note {
  background: #f8fafc;
  border: 1px solid var(--app-line);
  border-radius: 0.75rem;
  padding: 1rem 1.15rem;
  font-size: 0.875rem;
  color: #475569;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ——— Mobile cards & dense grids ——— */
@media (max-width: 767px) {
  .main-content {
    padding: 0.75rem 0.7rem 1.25rem !important;
  }

  .htl-page-wrap,
  .medic-bank-page {
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  /* Stack wide multi-column layouts; keep native 2-col pairs */
  .main-content .grid.md\:grid-cols-2,
  .main-content .grid.lg\:grid-cols-2,
  .main-content .grid.lg\:grid-cols-3,
  .main-content .grid.lg\:grid-cols-4,
  .main-content .grid.xl\:grid-cols-4,
  .main-content .grid.xl\:grid-cols-12,
  .main-content .grid.md\:grid-cols-3,
  .main-content .grid.md\:grid-cols-4 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .main-content .grid.grid-cols-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.6rem !important;
  }

  .main-content .rounded-xl,
  .main-content .rounded-lg,
  .main-content .dash-panel,
  .main-content .bg-white.border,
  .main-content [class*="shadow-sm"].border {
    border-radius: 0.75rem !important;
  }

  .main-content .p-4,
  .main-content .p-5,
  .main-content .p-6,
  .main-content .sm\:p-5,
  .main-content .sm\:p-4 {
    padding: 0.85rem !important;
  }

  .main-content .px-3\.5,
  .main-content .px-4,
  .main-content .sm\:px-4 {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
  }

  /* Gradient KPI tiles — readable on narrow screens */
  .main-content .bg-gradient-to-br {
    min-height: 0 !important;
    padding: 0.85rem !important;
  }
  .main-content .bg-gradient-to-br .text-lg,
  .main-content .bg-gradient-to-br .sm\:text-xl {
    font-size: 1.05rem !important;
    line-height: 1.2 !important;
  }
  .main-content .bg-gradient-to-br .text-2xl,
  .main-content .bg-gradient-to-br .sm\:text-3xl,
  .main-content .bg-gradient-to-br .fa-2xl,
  .main-content .bg-gradient-to-br .text-3xl {
    font-size: 1.15rem !important;
  }

  /* Tables in cards: allow horizontal scroll without breaking layout */
  .main-content .overflow-x-auto,
  .main-content .dash-panel,
  .main-content .rounded-xl {
    max-width: 100%;
  }
  .main-content table {
    min-width: 0;
    width: 100%;
  }
  .main-content table th,
  .main-content table td {
    padding: 0.55rem 0.6rem !important;
    font-size: 0.78rem !important;
    white-space: nowrap;
  }

  /* Action button rows wrap cleanly */
  .main-content .flex.flex-wrap,
  .main-content .flex.gap-2 {
    gap: 0.45rem !important;
  }
  .main-content a.inline-flex,
  .main-content button.inline-flex {
    min-height: 2.35rem;
  }

  /* Form cards full bleed of content area */
  .main-content .max-w-xl,
  .main-content .max-w-2xl,
  .main-content .max-w-3xl,
  .main-content .max-w-4xl {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .odash-stats {
    grid-template-columns: 1fr !important;
  }
  .odash-stat + .odash-stat {
    border-left: 0 !important;
    border-top: 1px solid var(--od-line, #e3e8e4);
  }
  .odash-board--chart-row,
  .odash-board--3,
  .odash-board--2 {
    grid-template-columns: 1fr !important;
  }
}

