/* ══ SFS Stock Control - Brand Styles ══ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4a7c59;
  --primary-dark: #3a6347;
  --primary-light: #e8f3ec;
  --accent: #2d8659;
  --bg: #f5f7f5;
  --white: #ffffff;
  --text: #1a2e1a;
  --text-muted: #5a6b5a;
  --border: #d4ddd4;
  --success: #2d8659;
  --warning: #c57b1a;
  --danger: #c53030;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── NAVIGATION ── */
.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── LOGIN ── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #e8f3ec 0%, #f5f7f5 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ── FORMS ── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.form-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.form-info {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── PAGE LAYOUT ── */
.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ── DASHBOARD GRID ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.dashboard-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.dashboard-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.card-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.card-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── LOADING ── */
.loading-spinner {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── RESPONSIVE (TABLET) ── */
@media (max-width: 768px) {
  .main-nav {
    padding: 0 1rem;
  }

  .page-container {
    padding: 1.5rem 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-card {
    padding: 1rem 1.25rem;
  }

  .login-card {
    padding: 1.5rem;
  }
}

/* ── STOCK PAGE ── */
.stock-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* Summary Cards */
.summary-cards {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-width: 120px;
  flex: 1;
}

.summary-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Stock Grid */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.stock-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stock-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.stock-card.low-stock {
  border-color: var(--warning);
  border-left: 4px solid var(--warning);
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.stock-type-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.stock-type-badge.raw-material { background: #e8f3ec; color: #2d6b3f; }
.stock-type-badge.bug-mix { background: #e8ecf3; color: #2d3f6b; }
.stock-type-badge.finished-product { background: #f3ece8; color: #6b4f2d; }

.low-stock-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: #fff3e0;
  color: var(--warning);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.stock-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.stock-quantity {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.stock-unit {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

.stock-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stock-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stock-detail .label {
  font-weight: 600;
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── SCAN PAGE ── */
.scan-section {
  margin-bottom: 1.5rem;
}

.scanner-box {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  background: #1a1a1a;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: none;
  margin-bottom: 1rem;
}

.scanner-box.active {
  display: block;
}

.scanner-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-frame {
  width: 200px;
  height: 200px;
  border: 3px solid var(--primary);
  border-radius: 12px;
  opacity: 0.8;
}

.scan-help {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.manual-toggle {
  margin-bottom: 2rem;
}

.scan-form-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.form-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.form-status-msg {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.form-status-msg.success {
  background: #e8f9ee;
  color: var(--success);
  border: 1px solid #b8e8c8;
}

.form-status-msg.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.form-status-msg.loading {
  background: #f0f8f4;
  color: var(--primary);
  border: 1px solid #d4ddd4;
}

/* ── Input with Unit Selector ── */
.input-with-unit {
  display: flex;
  gap: 0.5rem;
}

.input-with-unit input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}

.input-with-unit select {
  padding: 0.75rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  min-width: 120px;
}

.input-with-unit input:focus,
.input-with-unit select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

/* ── RECIPES PAGE ── */
.page-actions {
  margin-bottom: 1.5rem;
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.recipe-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.2s;
}

.recipe-card:hover { border-color: var(--primary); }

.recipe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.btn-icon:hover { opacity: 1; }

.recipe-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.recipe-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Recipe Form */
.recipe-form-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
}

.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Steps */
.steps-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.steps-section h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.steps-help {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.step-entry {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.step-number {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* View Recipe */
.recipe-detail-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.recipe-detail-card h2 {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.recipe-detail-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.view-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.view-step {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
}

.view-step-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
}

.view-step-text {
  font-size: 0.95rem;
  color: var(--text);
}

.view-step-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.view-step-scan {
  font-size: 0.78rem;
  color: var(--warning);
}

/* ── PRODUCTION MIX GUIDE ── */
.guide-select {
  width: 100%;
  padding: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  -webkit-appearance: none;
}

.guide-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.setup-form {
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  min-height: 60px;
}

/* Full-screen step view */
.guide-fullscreen {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  text-align: center;
}

.guide-progress {
  width: 100%;
  max-width: 500px;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.guide-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}

.guide-step-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 2rem;
}

.guide-instruction {
  margin-bottom: 2rem;
  width: 100%;
  max-width: 500px;
}

.guide-action {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 1rem;
}

.guide-ingredient-detail {
  background: var(--white);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
}

.guide-ingredient-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
  margin-bottom: 0.75rem;
}

.guide-qty-edit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.guide-qty-edit label {
  font-weight: 600;
  color: var(--text-muted);
}

.guide-qty-input {
  width: 120px;
  padding: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  font-family: inherit;
}

.guide-qty-input:focus {
  outline: none;
  border-color: var(--primary);
}

.guide-unit {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

.guide-actions {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.scan-instruction {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Scanner in guide */
.guide-scanner-box {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 4/3;
  background: #1a1a1a;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem auto;
}

.guide-scanner-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scan success */
.guide-scan-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.success-tick {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
}

.success-tick.large {
  width: 100px;
  height: 100px;
  font-size: 3rem;
}

.guide-scan-success p {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--success);
}

/* Completion screen */
.completion-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 500px;
}

.completion-screen h2 {
  color: var(--success);
  margin-bottom: 0;
}

.completion-form {
  width: 100%;
  margin-top: 1rem;
}

.completion-details {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 2;
  margin: 1rem 0;
}

/* ── Manual code entry ── */
.manual-code-section {
  margin-top: 1.5rem;
}

.or-divider {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.manual-code-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
