/* assets/css/app.css — Subtle Light Flat Theme & Rebuild Layout Styles */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-base:       #FAF8F5;   /* Subtle premium warm off-white */
  --bg-surface:    #FFFFFF;   /* Pure white main area */
  --bg-card:       #FFFFFF;   /* Clean white cards */
  --bg-input:      #FDFDFD;   /* Off-white input fields */
  --bg-hover:      #F4F1EA;   /* Warm light grey-cream hover effect */
  
  --gold:          #A8813B;   /* Muted brass/gold - primary brand accent */
  --gold-dim:      #86652A;   /* Dimmed brass */
  --gold-glow:     rgba(168, 129, 59, 0.05);
  
  --amber:         #C9610C;   /* Flat warm amber - alert indicator */
  
  --text-primary:  #2B2824;   /* Soft charcoal/brown */
  --text-secondary:#6B655D;   /* Warm grey-taupe secondary text */
  --text-muted:    #9C958C;   /* Muted text */
  
  --border:        #E6E1D8;   /* Clean subtle borders */
  --border-focus:  #A8813B;
  
  --danger:        #D32F2F;   /* Subtle red */
  --danger-bg:     rgba(211, 47, 47, 0.04);
  --success:       #2E7D32;   /* Soft emerald green */
  --success-bg:    rgba(46, 125, 50, 0.04);
  --warn:          #EF6C00;
  --warn-bg:       rgba(239, 108, 0, 0.04);
  
  --radius:        8px;
  --radius-lg:     12px;
  --font-display:  'Cinzel', Georgia, serif;
  --font-body:     'Inter', system-ui, sans-serif;
  
  --header-h:      60px;
  --nav-h:         64px;
  --sidebar-w:     220px;
  
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.03);
  --shadow-lg:     0 10px 30px rgba(0,0,0,0.04);
}

/* ============================================================
   Reset & Core Styling
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Scrollbar adjustment */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ============================================================
   Typography & Elements
   ============================================================ */
h1, h2, h3, h4, h5 {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--gold);
  text-decoration: none;
}

p {
  color: var(--text-secondary);
}

/* ============================================================
   Layout Wrapper
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(250, 248, 245, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 100;
}

.header-logo-container {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-logo {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  font-weight: 600;
}

.brand-divider {
  color: var(--border);
  font-size: 1rem;
}

#page-title {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

#page-content {
  flex: 1;
  padding: calc(var(--header-h) + 1.25rem) 1rem calc(var(--nav-h) + 1.5rem);
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   Navigation Shell
   ============================================================ */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  width: 60px;
  height: 100%;
  transition: color 0.2s ease, transform 0.1s ease;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: stroke 0.2s ease;
}

.nav-item:hover, .nav-item.active {
  color: var(--gold);
}

.nav-item.active svg {
  stroke: var(--gold);
}

/* ============================================================
   Form Controls
   ============================================================ */
.form-group {
  margin-bottom: 1.25rem;
  width: 100%;
}

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

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: bold;
  cursor: help;
  margin-left: 0.25rem;
  position: relative;
  vertical-align: middle;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
  width: max-content;
  max-width: 240px;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  transition: all 0.15s ease;
  border: 1px solid var(--border);
}

.info-icon:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 550;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--bg-hover);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--gold-dim);
  border-color: var(--gold-dim);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #B71C1C;
  border-color: #B71C1C;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

/* ============================================================
   Cards & Layout Panels
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.card-header h2 {
  font-size: 1.05rem;
  color: var(--text-primary);
}

/* ============================================================
   Lists & Table Grid Rows
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.list-item:hover {
  border-color: var(--border-focus);
  background: var(--bg-hover);
}

.list-item-icon {
  font-size: 1.25rem;
  margin-right: 0.85rem;
  width: 32px;
  height: 32px;
  background: var(--bg-base);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.list-item-body {
  flex: 1;
}

.list-item-title {
  font-weight: 550;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.list-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.list-item-right {
  text-align: right;
  margin-left: 0.75rem;
}

.list-item-value {
  font-weight: 600;
  font-size: 0.9rem;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn); }
.badge-smoke   { background: var(--bg-hover);   color: var(--text-secondary); }

/* ============================================================
   Stats Display
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   Pricing / Margin Calculator Options
   ============================================================ */
.price-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.price-option {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.price-option:hover {
  border-color: var(--border-focus);
}

.price-option.selected {
  border-color: var(--gold);
  background: var(--gold-glow);
  box-shadow: 0 0 0 2px var(--gold);
}

.price-option-mult {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.price-option-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.2rem 0;
}

.price-option-gst {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ============================================================
   Alert Banners
   ============================================================ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger); }
.alert-warn    { background: var(--warn-bg);    border-color: var(--warn);    color: var(--warn); }

/* ============================================================
   Stock Sufficiency Bar Styling
   ============================================================ */
.stock-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.stock-bar {
  height: 100%;
  border-radius: 2px;
}

.stock-bar.stock-empty { background: var(--danger); }
.stock-bar.stock-low   { background: var(--warn); }
.stock-bar.stock-good  { background: var(--success); }

.margin-good { color: var(--success); font-weight:600; }
.margin-mid  { color: var(--warn); font-weight:600; }
.margin-low  { color: var(--danger); font-weight:600; }

/* ============================================================
   Spinners & Loaders
   ============================================================ */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Toast Message Boxes
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  width: calc(100% - 2rem);
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  text-align: center;
  animation: toast-in 0.25s ease;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
}

@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast-success { border-color: var(--success); color: var(--success); background: var(--bg-surface); }
.toast-error   { border-color: var(--danger);  color: var(--danger); background: var(--bg-surface); }
.toast-warn    { border-color: var(--warn);    color: var(--warn); background: var(--bg-surface); }

/* ============================================================
   Overlay Modal Dialog Box
   ============================================================ */
.sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(43, 40, 36, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 500;
  transition: opacity 0.25s ease;
}

.sheet-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  bottom: -100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.25rem 1.25rem calc(var(--nav-h) + 1.25rem);
  z-index: 600;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -5px 25px rgba(0,0,0,0.05);
}

.sheet.visible {
  transform: translateY(-100%);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: -0.5rem auto 1rem;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sheet-header h2 {
  font-size: 1.05rem;
}

.sheet-body {
  margin-bottom: 1rem;
  max-height: 50vh;
  overflow-y: auto;
}

.sheet-footer {
  margin-top: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
}

.empty-state-icon {
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ============================================================
   Responsive Layout Overrides (Desktop >= 900px)
   ============================================================ */
@media (min-width: 900px) {
  #app {
    display: block;
    min-height: 100vh;
  }
  
  #page-header {
    left: var(--sidebar-w);
    right: 0;
    height: var(--header-h);
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
  }
  
  #page-content {
    margin: 0 0 0 var(--sidebar-w);
    max-width: 100%;
    width: auto;
    padding: calc(var(--header-h) + 2rem) 2rem 2rem;
  }
  
  /* Transform Bottom Nav into a Left Sidebar */
  #bottom-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    border-top: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 1.5rem 0.5rem;
    gap: 0.35rem;
    box-shadow: 2px 0 10px rgba(0,0,0,0.01);
  }
  
  /* Add Brand Header inside the Sidebar on Desktop */
  #bottom-nav::before {
    content: "Ishmaya MM";
    display: block;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
    text-align: center;
    padding: 0.5rem 0 1.25rem;
    letter-spacing: 0.05em;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 1.5rem;
  }
  
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.75rem 1.25rem;
    gap: 0.875rem;
    font-size: 0.85rem;
    text-transform: capitalize;
    color: var(--text-secondary);
    border-radius: var(--radius);
    transition: all 0.2s ease;
    width: 100%;
    height: auto;
  }
  
  .nav-item svg {
    width: 18px;
    height: 18px;
  }
  
  .nav-item:hover {
    background: var(--bg-hover);
    color: var(--gold);
  }
  
  .nav-item.active {
    background: var(--gold-glow);
    color: var(--gold);
    box-shadow: inset 3px 0 0 var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-left: -0.5rem;
    padding-left: 1.75rem;
    width: calc(100% + 0.5rem);
  }
  
  /* Floating Action Buttons centered correctly on Desktop */
  .btn-primary[style*="position:fixed"] {
    right: 2rem !important;
    bottom: 2rem !important;
  }
  
  #toast-container {
    left: calc(var(--sidebar-w) + (100% - var(--sidebar-w)) / 2);
    bottom: 2rem;
  }
  
  /* Stats Grid expansion */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  /* Centered Modal Overlay Prompt on Desktop */
  .sheet {
    max-width: 480px;
    left: 50%;
    bottom: 50%;
    transform: translate(-50%, 50%) scale(0.95);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  }
  
  .sheet.visible {
    transform: translate(-50%, 50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  
  .sheet-handle {
    display: none;
  }
}

/* Settings tab style additions */
.settings-tab {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 0;
  padding: .5rem 1rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}
.settings-tab:hover {
  color: var(--gold);
}
.settings-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: transparent;
}

