:root {
  --color-primary: #dc2626;
  --color-primary-dark: #b91c1c;
  --color-primary-light: #fef2f2;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-bg: #f9fafb;
  --color-white: #ffffff;
  --color-border: #e5e7eb;
  --color-success: #16a34a;
  --color-warning: #ca8a04;
  --color-mp-blue: #009ee3;
  --radius: 12px;
  --max-width: 640px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout */

.header {
  background: var(--color-primary);
  color: white;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);

  & .header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  & h1 {
    font-size: 1.4rem;
    font-weight: 700;
  }

  & .header-subtitle {
    opacity: .8;
    font-size: .85rem;
  }

  & .header-info {
    text-align: right;
    font-size: .8rem;
    opacity: .8;
    white-space: nowrap;
  }

  & .header-date {
    font-size: 1.1rem;
    font-weight: 700;
    opacity: 1;
  }

  & a {
    color: white;
    text-decoration: none;
  }

  & .header-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
  }

  & .header-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
  }
}

.banner {
  background: var(--color-primary-light);
  border-bottom: 1px solid #fecaca;
  padding: .75rem 1rem;
  text-align: center;
  font-size: .9rem;
  color: var(--color-primary-dark);
  font-weight: 500;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

footer {
  border-top: 1px solid var(--color-border);
  padding: 1rem;
  text-align: center;
  font-size: .75rem;
  color: var(--color-text-light);
  margin-top: 2rem;
}

/* Product Cards */

.products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;

  @media (min-width: 500px) {
    grid-template-columns: 1fr 1fr;
  }
}

.product-card {
  background: var(--color-white);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow: hidden;
  transition: box-shadow .2s;

  &:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
  }

  & .product-emoji {
    background: linear-gradient(135deg, #fef2f2, #fff7ed);
    padding: 0.5rem;
    text-align: center;
    font-size: 3.5rem;

    & .product-img {
      width: 100%;
      aspect-ratio: 1 / 1;
      object-fit: contain;
    }
  }

  & .product-info {
    padding: 1rem;
  }

  & h3 {
    font-size: 1.1rem;
    font-weight: 700;
  }

  & .product-desc {
    color: var(--color-text-light);
    font-size: .9rem;
    margin-top: .25rem;
  }

  & .product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
  }

  & .product-price {
    font-size: 1.5rem;
    font-weight: 700;
  }
}

.btn {
  display: inline-block;
  padding: .6rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background .2s;
}

.btn-primary {
  background: var(--color-primary);
  color: white;

  &:hover { background: var(--color-primary-dark); }
}

.btn-mp {
  background: var(--color-mp-blue);
  color: white;
  width: 100%;
  padding: .85rem;
  font-size: 1rem;

  &:hover { background: #007fb5; }
}

.btn-transfer {
  background: var(--color-success);
  color: white;
  width: 100%;
  padding: .85rem;
  font-size: 1rem;

  &:hover { background: #15803d; }
}

.payment-buttons {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Add-on Banner */

.addon-banner {
  margin-top: 1.5rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;

  & .addon-emoji { font-size: 2.5rem; }
  & strong { color: #92400e; }
  & p { color: #a16207; font-size: .9rem; }
}

/* Add-on Checkbox Option */

.addon-option {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: .5rem;

  &:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
  }

  &:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
  }

  & input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--color-primary);
    flex-shrink: 0;
  }

  & .addon-emoji-small { font-size: 1.5rem; }

  & .addon-detail {
    flex: 1;

    & strong { display: block; font-size: .95rem; }
    & small { color: var(--color-text-light); font-size: .85rem; }
  }

  & .addon-price {
    font-weight: 600;
    font-size: .95rem;
    white-space: nowrap;
  }
}

/* Card (generic) */

.card {
  background: var(--color-white);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* Order Form */

.product-summary {
  display: flex;
  align-items: center;
  gap: 1rem;

  & .summary-emoji {
    font-size: 2.5rem;

    & .summary-img {
      width: 60px;
      height: 60px;
      object-fit: contain;
      border-radius: 8px;
    }
  }
  & .summary-name { font-weight: 700; }
  & .summary-desc { color: var(--color-text-light); font-size: .9rem; }
  & .summary-price { font-size: 1.25rem; font-weight: 700; margin-left: auto; }
}

.form-group {
  margin-bottom: 1rem;

  & label {
    display: block;
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: .35rem;
    color: var(--color-text);
  }

  & input {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
    transition: border-color .2s;

    &:focus {
      outline: none;
      border-color: var(--color-primary);
      box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
    }
  }
}

.form-errors {
  background: var(--color-primary-light);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
  font-size: .9rem;

  & ul { padding-left: 1.25rem; }
}

.form-hint {
  text-align: center;
  color: var(--color-text-light);
  font-size: .8rem;
  margin-top: 1rem;
}

/* Order Status */

.status-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2rem;

  &.success { background: #dcfce7; }
  &.pending { background: #fef9c3; }
  &.delivered { background: #f3f4f6; }
}

.status-section {
  text-align: center;
  margin-bottom: 1.5rem;

  & h2 { font-size: 1.25rem; font-weight: 700; }
  & p { color: var(--color-text-light); font-size: .9rem; margin-top: .25rem; }
}

.qr-card {
  text-align: center;
  padding: 1.5rem;

  & svg { max-width: 200px; margin: 0 auto 1rem; }

  & .pickup-code {
    font-family: monospace;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: .2em;
  }
}

/* Order Details */

.order-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid #f3f4f6;

  &:last-child { border-bottom: none; }

  & .item-qty { color: var(--color-text-light); font-size: .85rem; }
  & .item-price { font-weight: 600; }
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: .75rem;
  margin-top: .5rem;
  border-top: 2px solid var(--color-border);
  font-weight: 700;

  & .total-amount { font-size: 1.2rem; }
}

/* Transfer Info */

.transfer-info {
  text-align: center;
}

.transfer-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.transfer-label {
  color: var(--color-text-light);
  font-size: .9rem;
}

.transfer-value {
  font-weight: 700;
  font-size: 1.1rem;
  font-family: monospace;
  letter-spacing: .05em;
}

.transfer-amount {
  font-size: 1.4rem;
  color: var(--color-success);
}

.transfer-qr {
  padding-top: 1rem;
  text-align: center;
}

.transfer-qr-img {
  max-width: 200px;
  margin: .75rem auto 0;
  border-radius: 8px;
}

.transfer-pickup-info {
  text-align: center;

  & .pickup-code {
    font-family: monospace;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: .2em;
    margin: .5rem 0;
  }
}

.transfer-hint {
  color: var(--color-text-light);
  font-size: .85rem;
  margin-top: .5rem;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 1.5rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;

  &:hover { text-decoration: underline; }
}

/* Section title */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ========== Admin ========== */

.admin-nav {
  background: #1f2937;
  color: white;
  padding: .75rem 1rem;

  & .admin-nav-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
  }

  & .admin-nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .9rem;
  }

  & a {
    color: #93c5fd;
    text-decoration: none;
    &:hover { color: white; }
  }

  & .admin-nav-user {
    color: #9ca3af;
    font-size: .85rem;
  }
}

.admin-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;

  & h1 { font-size: 1.5rem; }
}

/* Admin Table */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);

  & th {
    background: #f3f4f6;
    padding: .75rem 1rem;
    text-align: left;
    font-size: .85rem;
    font-weight: 600;
    color: var(--color-text-light);
  }

  & td {
    padding: .75rem 1rem;
    border-top: 1px solid var(--color-border);
    font-size: .9rem;
  }

  & tr.inactive { opacity: .5; }

  & .actions {
    display: flex;
    gap: .5rem;
    align-items: center;

    & a { color: var(--color-primary); text-decoration: none; font-size: .85rem; }
    & button {
      background: none;
      border: none;
      color: var(--color-text-light);
      font-size: .85rem;
      cursor: pointer;
      &:hover { color: var(--color-primary); }
    }
  }
}

/* Admin Form */

.admin-form {
  max-width: 500px;

  & small {
    display: block;
    color: var(--color-text-light);
    font-size: .8rem;
    margin-top: .25rem;
  }
}

.form-row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
}

/* Image Preview */

.image-preview {
  margin-bottom: .75rem;
}

.preview-img {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

/* Login */

.login-container {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--color-white);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);

  & h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
  }
}

/* Flash messages */

.flash-alert {
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: .75rem 1rem;
  text-align: center;
  font-size: .9rem;
}

.flash-notice {
  background: #dcfce7;
  color: #166534;
  padding: .75rem 1rem;
  text-align: center;
  font-size: .9rem;
}

/* Search Bar */

.search-bar {
  margin-bottom: 1.5rem;
}

.search-form {
  display: flex;
  gap: .5rem;

  & input[type="text"] {
    flex: 1;
    padding: .65rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;

    &:focus {
      outline: none;
      border-color: var(--color-primary);
    }
  }
}

/* Order Cards (cashier view) */

.orders-list {
  display: grid;
  gap: 1rem;
}

.order-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;

  &.delivered { opacity: .6; }
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  background: #f9fafb;
  border-bottom: 1px solid var(--color-border);
}

.order-code {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .1em;
}

.order-status-badge {
  font-size: .8rem;
  font-weight: 600;
  padding: .25rem .75rem;
  border-radius: 50px;

  &.paid { background: #dcfce7; color: #166534; }
  &.delivered { background: #f3f4f6; color: #6b7280; }
}

.order-card-body {
  padding: 1rem;

  & .order-customer { font-weight: 600; }
  & .order-items-summary { color: var(--color-text-light); font-size: .9rem; margin-top: .25rem; }
  & .order-total { font-weight: 700; font-size: 1.1rem; margin-top: .5rem; }
}

.order-card-actions {
  padding: .75rem 1rem;
  border-top: 1px solid var(--color-border);
}

.btn-success {
  background: var(--color-success);
  color: white;
  width: 100%;
  padding: .7rem;

  &:hover { background: #15803d; }
}

.order-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .5rem;

  & .order-date { color: var(--color-text-light); font-size: .85rem; }
  & .order-total { font-weight: 700; font-size: 1.1rem; }
}

/* QR Scanner */

.qr-scanner {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-scanner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;

  & video {
    width: min(90vw, 400px);
    border-radius: var(--radius);
  }

  & .btn { background: white; color: var(--color-text); }
}

/* Admin Tabs */

.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
}

.admin-tab {
  padding: .75rem 1.25rem;
  font-size: .95rem;
  font-weight: 500;
  color: var(--color-text-light);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .2s, border-color .2s;
  display: flex;
  align-items: center;
  gap: .5rem;

  &:hover { color: var(--color-text); }
  &.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
  }
}

.tab-badge {
  background: var(--color-primary);
  color: white;
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .5rem;
  border-radius: 50px;
  min-width: 1.3rem;
  text-align: center;
}

.btn-danger {
  background: #dc2626;
  color: white;
  width: 100%;
  padding: .7rem;

  &:hover { background: #b91c1c; }
}

.transfer-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.order-status-badge.pending_transfer {
  background: #fef9c3;
  color: #854d0e;
}

.empty-state {
  text-align: center;
  color: var(--color-text-light);
  padding: 3rem 1rem;
  font-size: 1rem;
}
