/* ==========================================================================
   Sakura Bloom Bakery — Shared design tokens & layout
   ========================================================================== */

:root {
  /* Palette */
  --color-bg:            #FBEEE3;
  --color-surface:       #FFFFFF;
  --color-surface-soft:  #F7E9DC;
  --color-border:        #EFE0D0;

  --color-text:          #3B2A20;
  --color-text-muted:    #8B7364;
  --color-heading:       #8A4B22;

  --color-primary:       #A9707D;
  --color-primary-dark:  #8B5A68;
  --color-primary-soft:  #F4E3E7;

  --color-badge-ready-bg:    #DDEACD;
  --color-badge-ready-text:  #57742F;
  --color-badge-upcoming-bg: #F6DEB4;
  --color-badge-upcoming-text: #A9701F;
  --color-badge-due-bg:      #F8D2D2;
  --color-badge-due-text:    #B7473F;

  --color-cash-icon: #6B5138;
  --color-online-icon: #6B5138;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-card: 0 2px 10px rgba(90, 60, 40, 0.06);
  --shadow-modal: 0 20px 50px rgba(60, 35, 20, 0.25);

  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --sidebar-width: 240px;
  --bottom-nav-height: 72px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  /* 100dvh tracks the *actual* visible viewport as the mobile browser's URL
     bar shows/hides, instead of the old 100vh which assumes the URL bar is
     always hidden — that mismatch is what causes the layout to jump/scroll
     oddly as you scroll. Browsers without dvh support just use the vh
     fallback above. */
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  margin: 0;
}

button { font-family: inherit; cursor: pointer; }

a { color: inherit; text-decoration: none; }

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

/* --------------------------------------------------------------------------
   Sidebar (desktop / tablet)
   -------------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 28px 20px;
  border-right: 1px solid var(--color-border);
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 8px 28px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo-badge {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid var(--color-heading);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  color: var(--color-heading);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.sidebar-logo-name {
  font-family: var(--font-heading);
  color: var(--color-heading);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 15px;
  font-weight: 500;
}

.sidebar-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-nav-item.active {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 600;
}

.sidebar-nav-item:not(.active):hover {
  background: var(--color-surface-soft);
}

.sidebar-logout {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* ==========================================================================
   Shared danger button
   ========================================================================== */

.btn-danger {
  flex-shrink: 0;
  border: 1px solid var(--color-badge-due-text);
  color: var(--color-badge-due-text);
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
}
.btn-danger:hover { background: var(--color-badge-due-bg); }

.btn-danger-solid {
  background: var(--color-badge-due-text);
  color: #fff;
}
.btn-danger-solid:hover { background: #9a3a33; }
.btn-danger-solid:disabled { opacity: 0.45; cursor: not-allowed; background: var(--color-badge-due-text); }

.btn-success {
  background: #7FA35C;
  color: #fff;
  border: none;
}
.btn-success:hover { background: #6c8c4c; }

.row-edit-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  font-size: 13px;
  flex-shrink: 0;
}
.row-edit-btn:hover { background: var(--color-surface-soft); color: var(--color-primary-dark); }

/* ==========================================================================
   Card removal animations (Orders: Hand Off / Cancel)
   ========================================================================== */

@keyframes cardPop {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  35%  { transform: scale(1.04) rotate(-1deg); opacity: 1; }
  100% { transform: scale(0.55) rotate(2deg); opacity: 0; }
}
.card-anim-pop {
  animation: cardPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: none;
}

@keyframes cardPoof {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; filter: blur(0); }
  55%  { transform: scale(1.06) rotate(-3deg); opacity: 0.7; filter: blur(1px); }
  100% { transform: scale(0.35) rotate(9deg); opacity: 0; filter: blur(5px); }
}
.card-anim-poof {
  animation: cardPoof 0.45s ease-in forwards;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------------- */

.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  /* flex-wrap: wrap; */
}

.page-header h1 {
  font-size: 30px;
  color: var(--color-heading);
}

.page-subtitle {
  color: var(--color-text-muted);
  font-size: 14.5px;
  margin-top: 6px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--color-surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 14px;
  color: var(--color-heading);
  font-weight: 700;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-outline:hover { background: var(--color-surface-soft); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Filter tabs
   -------------------------------------------------------------------------- */

.filter-tabs {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
}

.filter-tab {
  border: none;
  background: transparent;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.filter-tab.active {
  background: var(--color-primary);
  color: #fff;
}

.custom-range-row {
  display: none;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.custom-range-row.visible { display: flex; }
.custom-range-row input {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Status badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-ready    { background: var(--color-badge-ready-bg);    color: var(--color-badge-ready-text); }
.badge-upcoming { background: var(--color-badge-upcoming-bg); color: var(--color-badge-upcoming-text); }
.badge-due      { background: var(--color-badge-due-bg);      color: var(--color-badge-due-text); }
.badge-default  { background: var(--color-surface-soft);      color: var(--color-text-muted); }

.detail-actions-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-actions-footer > .btn { width: 100%; }

.detail-actions {
  display: flex;
  gap: 10px;
}
.detail-actions .btn { width: auto; flex: 1; }

.btn-danger-outline {
  color: var(--color-badge-due-text);
  border-color: var(--color-badge-due-bg);
}
.btn-danger-outline:hover { background: var(--color-badge-due-bg); }

/* --------------------------------------------------------------------------
   Bottom nav (mobile only)
   -------------------------------------------------------------------------- */

.bottom-nav {
  display: none;
}

/* --------------------------------------------------------------------------
   Toast / inline error text
   -------------------------------------------------------------------------- */

.field-error {
  color: var(--color-badge-due-text);
  font-size: 12.5px;
  margin-top: 4px;
  display: none;
}
.field-error.visible { display: block; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--color-text);
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 500;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { background: #B7473F; }

/* --------------------------------------------------------------------------
   Responsive: mobile layout
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .sidebar { display: none; }

  .app-shell { flex-direction: column; }

  .main-content {
    padding: 20px 16px calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .page-header {
    align-items: center;
  }

  .page-header h1 { font-size: 24px; }

  .desktop-only { display: none !important; }

  .filter-tabs {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tabs .filter-tab { flex-shrink: 0; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    justify-content: space-around;
    align-items: center;
    z-index: 200;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-md);
  }

  .bottom-nav-item.active {
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
  }

  .bottom-nav-item svg { width: 20px; height: 20px; }

  .fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(139, 90, 104, 0.4);
    border: none;
    font-size: 26px;
    z-index: 210;
  }
}

@media (min-width: 861px) {
  .mobile-only { display: none !important; }
}

/* ==========================================================================
   Shared modal + form styles
   (used by the New Order, Record Expense, and any future modals)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(50, 30, 20, 0.35);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 400;
}

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

.modal-overlay-top { z-index: 450; }

.modal {
  background: var(--color-bg);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  color: var(--color-heading);
  font-size: 22px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 4px;
}

.modal-body {
  padding: 20px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.form-section-label {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-primary-dark);
  text-transform: uppercase;
  margin: 22px 0 12px;
}
.form-section-label:first-child { margin-top: 0; }

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

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

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 14.5px;
  color: var(--color-text);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-control.has-error {
  border-color: var(--color-badge-due-text);
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 0; }

.modal-footer {
  border-top: 1px solid var(--color-border);
  padding: 18px 24px 22px;
  background: var(--color-bg);
}

.modal-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.modal-total-label { font-size: 14.5px; color: var(--color-text-muted); }
.modal-total-amount {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
}

.modal-footer .btn { width: 100%; }

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label { color: var(--color-text-muted); }
.detail-row-value { font-weight: 600; text-align: right; }

@media (max-width: 860px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 22px 22px 0 0; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; }
  .modal-body { flex: 1; }
}

/* ==========================================================================
   Shared panel/widget styles (used by Overview and Business Pulse)
   ========================================================================== */

.panel-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
}

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

.panel-card-header h2 {
  font-size: 19px;
  color: var(--color-heading);
}

.top-items-list { margin-top: 4px; }
.top-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.top-item-row:last-child { border-bottom: none; }
.top-item-name { font-weight: 600; font-size: 14px; }
.top-item-sold { font-size: 12px; color: var(--color-text-muted); }
.top-item-amount { font-family: var(--font-heading); font-weight: 700; font-size: 15px; }
