/* ============================================
   Costinit — Earthy, warm, approachable
   Palette: oranges, creams, clean whites
   ============================================ */

:root {
  --orange: #d4742c;
  --orange-light: #e8955a;
  --orange-dark: #b35d1e;
  --cream: #fdf6ee;
  --cream-dark: #f0e4d4;
  --white: #ffffff;
  --text: #3a3027;
  --text-light: #7a6e62;
  --green: #3a8a5c;
  --blue: #4a7fb5;
  --red: #c44b4b;
  --border: #e5ddd3;
  --shadow: 0 2px 8px rgba(58, 48, 39, 0.08);
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Layout --- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand h1 {
  font-size: 22px;
  color: var(--orange);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-brand .sub-brand {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.sidebar-nav a:hover {
  background: var(--cream);
}

.sidebar-nav a.active {
  background: var(--orange);
  color: var(--white);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-footer .business-name {
  font-size: 12px;
  color: var(--text-light);
}

.sidebar-footer button {
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.sidebar-footer button:hover {
  color: var(--red);
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 960px;
}

/* Mobile hamburger */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  z-index: 99;
}

.mobile-header h1 {
  font-size: 18px;
  color: var(--orange);
  font-weight: 700;
}

.hamburger {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99;
}

/* --- Auth pages (login/signup/onboarding) --- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--cream);
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  font-size: 24px;
  color: var(--orange);
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-card .sub-brand {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 24px;
}

/* --- Forms --- */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--orange);
}

.form-group .hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-primary {
  background: var(--orange);
  color: var(--white);
  width: 100%;
}

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

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

.btn-secondary:hover {
  background: var(--cream-dark);
}

.btn-danger {
  background: none;
  color: var(--red);
  padding: 6px 12px;
  font-size: 13px;
}

.btn-danger:hover {
  background: rgba(196, 75, 75, 0.08);
}

.btn-small {
  padding: 6px 14px;
  font-size: 13px;
}

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-light);
}

.auth-toggle a {
  color: var(--orange);
  text-decoration: none;
  font-weight: 600;
}

.error-message {
  background: rgba(196, 75, 75, 0.08);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.success-message {
  background: rgba(58, 138, 92, 0.08);
  color: var(--green);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* --- Dashboard --- */

.greeting {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--orange);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- Cards / Tables --- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.card-row:last-child {
  border-bottom: none;
}

.recipe-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.recipe-card:hover {
  box-shadow: 0 4px 16px rgba(58, 48, 39, 0.12);
}

.recipe-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.recipe-card-top h3 {
  font-size: 16px;
  font-weight: 600;
}

.recipe-card-stats {
  display: flex;
  gap: 24px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-light);
}

.recipe-card-stats span {
  display: flex;
  flex-direction: column;
}

.recipe-card-stats .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.recipe-card-stats .value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* Margin badge */
.margin-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.margin-green {
  background: rgba(58, 138, 92, 0.1);
  color: var(--green);
}

.margin-blue {
  background: rgba(74, 127, 181, 0.1);
  color: var(--blue);
}

.margin-red {
  background: rgba(196, 75, 75, 0.1);
  color: var(--red);
}

/* --- Ingredient table --- */

.ingredient-table {
  width: 100%;
  border-collapse: collapse;
}

.ingredient-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}

.ingredient-table td {
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.ingredient-table tr:hover {
  background: var(--cream);
}

.ingredient-table .actions {
  display: flex;
  gap: 8px;
}

.ingredient-table .actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-light);
}

.ingredient-table .actions button:hover {
  background: var(--cream-dark);
  color: var(--text);
}

/* --- Recipe detail --- */

.recipe-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.recipe-pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.pricing-item {
  background: var(--cream);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.pricing-item .pricing-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.pricing-item .pricing-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}

/* --- Modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* --- Empty state --- */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* --- Back link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
}

.back-link:hover {
  color: var(--orange);
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 72px 16px 24px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .recipe-card-stats {
    flex-wrap: wrap;
    gap: 12px;
  }

  .recipe-pricing {
    grid-template-columns: 1fr 1fr;
  }

  .ingredient-table {
    font-size: 13px;
  }

  .ingredient-table th,
  .ingredient-table td {
    padding: 8px 6px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* --- Utility --- */

.hidden {
  display: none !important;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}
