/* ============================================================
   Tap2Order – Kitchen Display System (KDS) Stylesheet
   Large font sizes for readability at distance
   ============================================================ */

/* ----------------------------------------------------------
   1. CSS Custom Properties
   ---------------------------------------------------------- */
:root {
  --kds-new: #e74c3c;
  --kds-new-bg: #fdedec;
  --kds-preparing: #f39c12;
  --kds-preparing-bg: #fef9e7;
  --kds-ready: #27ae60;
  --kds-ready-bg: #eafaf1;
  --kds-served: #3498db;
  --kds-served-bg: #ebf5fb;
  --kds-bg: #1a1d23;
  --kds-surface: #23272e;
  --kds-card: #2c3038;
  --kds-text: #e8eaed;
  --kds-text-muted: #9aa0a6;
  --kds-border: #3c4049;
  --kds-danger: #ff4444;
  --kds-radius: 12px;
  --kds-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ----------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--kds-font);
  background: var(--kds-bg);
  color: var(--kds-text);
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
}

/* ----------------------------------------------------------
   3. KDS Layout
   ---------------------------------------------------------- */
.kds-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.kds-topbar {
  height: 60px;
  background: var(--kds-surface);
  border-bottom: 1px solid var(--kds-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.kds-topbar .kds-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--kds-text);
}

.kds-topbar .kds-logo span {
  color: #e74c3c;
}

.kds-topbar-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.kds-clock {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--kds-text);
}

.kds-order-count {
  font-size: 0.85rem;
  color: var(--kds-text-muted);
  background: var(--kds-card);
  padding: 4px 12px;
  border-radius: 8px;
}

.kds-order-count strong {
  color: var(--kds-text);
}

.kds-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kds-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--kds-border);
  background: var(--kds-card);
  color: var(--kds-text);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--kds-font);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.kds-btn-primary {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}

.kds-btn-primary:hover {
  background: #c0392b;
}

.kds-btn-success {
  background: #27ae60;
  border-color: #27ae60;
  color: #fff;
}

.kds-btn-success:hover {
  background: #219a52;
}

.kds-btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ----------------------------------------------------------
   4. Filter Bar
   ---------------------------------------------------------- */
.kds-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--kds-surface);
  border-bottom: 1px solid var(--kds-border);
  flex-shrink: 0;
  overflow-x: auto;
}

.kds-filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  padding: 8px 18px;
  border: 1px solid var(--kds-border);
  background: transparent;
  color: var(--kds-text-muted);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--kds-font);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--kds-text-muted);
  color: var(--kds-text);
}

.filter-btn.active {
  background: var(--kds-text);
  border-color: var(--kds-text);
  color: var(--kds-bg);
}

.filter-btn .filter-count {
  margin-left: 6px;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
}

.filter-btn.active .filter-count {
  background: rgba(0, 0, 0, 0.15);
}

/* ----------------------------------------------------------
   5. Orders Grid / Columns
   ---------------------------------------------------------- */
.kds-board {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  overflow-x: auto;
  overflow-y: hidden;
}

.kds-column {
  min-width: 320px;
  max-width: 380px;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: var(--kds-radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--kds-border);
  overflow: hidden;
}

.kds-column-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.kds-column-header .column-count {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.kds-column.col-new .kds-column-header {
  background: var(--kds-new);
  color: #fff;
}

.kds-column.col-preparing .kds-column-header {
  background: var(--kds-preparing);
  color: #fff;
}

.kds-column.col-ready .kds-column-header {
  background: var(--kds-ready);
  color: #fff;
}

.kds-column.col-served .kds-column-header {
  background: var(--kds-served);
  color: #fff;
}

.kds-column-body {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kds-column-body::-webkit-scrollbar {
  width: 4px;
}

.kds-column-body::-webkit-scrollbar-thumb {
  background: var(--kds-border);
  border-radius: 4px;
}

/* ----------------------------------------------------------
   6. Order Cards
   ---------------------------------------------------------- */
.kds-order-card {
  background: var(--kds-card);
  border-radius: var(--kds-radius);
  border: 1px solid var(--kds-border);
  overflow: hidden;
  transition: all 0.2s ease;
}

.kds-order-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.kds-order-card.overdue {
  border-color: var(--kds-danger);
  animation: overdueFlash 1.5s ease-in-out infinite;
}

@keyframes overdueFlash {
  0%, 100% {
    border-color: var(--kds-danger);
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
  }
  50% {
    border-color: var(--kds-danger);
    box-shadow: 0 0 12px 2px rgba(255, 68, 68, 0.3);
  }
}

.kds-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}

.kds-card-order-id {
  font-size: 1.1rem;
  font-weight: 700;
}

.kds-card-order-type {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kds-card-order-type.dine-in {
  background: #3498db22;
  color: #3498db;
}

.kds-card-order-type.takeaway {
  background: #f39c1222;
  color: #f39c12;
}

.kds-card-order-type.delivery {
  background: #27ae6022;
  color: #27ae60;
}

.kds-card-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 8px;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--kds-text);
}

.kds-card-timer i {
  font-size: 0.85rem;
  color: var(--kds-text-muted);
}

.kds-card-timer.timer-warning {
  color: var(--kds-preparing);
}

.kds-card-timer.timer-danger {
  color: var(--kds-danger);
}

/* ----------------------------------------------------------
   7. Order Item List
   ---------------------------------------------------------- */
.kds-card-items {
  padding: 0 14px 10px;
}

.kds-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.kds-item:last-child {
  border-bottom: none;
}

.kds-item-qty {
  min-width: 28px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--kds-text);
  flex-shrink: 0;
}

.kds-item-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--kds-text);
  line-height: 1.3;
}

.kds-item-variation {
  font-size: 0.8rem;
  color: var(--kds-text-muted);
}

.kds-item-addons {
  font-size: 0.78rem;
  color: var(--kds-text-muted);
  padding-left: 4px;
  font-style: italic;
}

.kds-item-note {
  font-size: 0.78rem;
  color: #f39c12;
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ----------------------------------------------------------
   8. Order Card Footer / Actions
   ---------------------------------------------------------- */
.kds-card-table {
  padding: 0 14px 10px;
  font-size: 0.85rem;
  color: var(--kds-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kds-card-table i {
  font-size: 0.8rem;
}

.kds-card-actions {
  display: flex;
  border-top: 1px solid var(--kds-border);
}

.kds-action-btn {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--kds-text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--kds-font);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.kds-action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.kds-action-btn + .kds-action-btn {
  border-left: 1px solid var(--kds-border);
}

.kds-action-btn.btn-start {
  color: var(--kds-preparing);
}

.kds-action-btn.btn-ready {
  color: var(--kds-ready);
}

.kds-action-btn.btn-serve {
  color: var(--kds-served);
}

.kds-action-btn.btn-bump {
  color: var(--kds-danger);
}

.kds-action-btn i {
  font-size: 1rem;
}

/* ----------------------------------------------------------
   9. Empty State
   ---------------------------------------------------------- */
.kds-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--kds-text-muted);
  text-align: center;
}

.kds-empty i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

.kds-empty p {
  font-size: 0.9rem;
}

/* ----------------------------------------------------------
   10. Fullscreen Mode
   ---------------------------------------------------------- */
.kds-fullscreen .kds-topbar {
  height: 50px;
}

.kds-fullscreen .kds-filter-bar {
  padding: 8px 16px;
}

.kds-fullscreen .kds-board {
  padding: 10px 12px;
  gap: 10px;
}

.kds-fullscreen .kds-column {
  min-width: 280px;
}

.kds-fullscreen .kds-order-card {
  border-radius: 8px;
}

.kds-fullscreen .kds-item-name {
  font-size: 1.1rem;
}

.kds-fullscreen .kds-item-qty {
  font-size: 0.95rem;
}

.kds-fullscreen .kds-card-order-id {
  font-size: 1.2rem;
}

.kds-fullscreen .kds-card-timer {
  font-size: 1.15rem;
}

.kds-fullscreen .kds-action-btn {
  padding: 14px 8px;
  font-size: 0.95rem;
}

:fullscreen .kds-wrapper {
  height: 100vh;
}

:-webkit-full-screen .kds-wrapper {
  height: 100vh;
}

/* ----------------------------------------------------------
   11. New Order Notification Banner
   ---------------------------------------------------------- */
.kds-new-order-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--kds-new);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-size: 1rem;
  font-weight: 700;
  z-index: 100;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.kds-new-order-banner.show {
  transform: translateY(0);
  animation: bannerPulse 2s ease-in-out;
}

@keyframes bannerPulse {
  0%, 100% { background: var(--kds-new); }
  50% { background: #c0392b; }
}

/* ----------------------------------------------------------
   12. Print Styles for Kitchen Tickets
   ---------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .kds-topbar,
  .kds-filter-bar,
  .kds-topbar-actions,
  .kds-column-header,
  .kds-card-actions,
  .kds-new-order-banner,
  .kds-btn {
    display: none !important;
  }

  .kds-board {
    display: block;
    padding: 0;
    overflow: visible;
  }

  .kds-column {
    min-width: 100%;
    max-width: 100%;
    border: none;
    background: none;
    margin-bottom: 20px;
    page-break-inside: avoid;
  }

  .kds-column-body {
    overflow: visible;
  }

  .kds-order-card {
    background: #fff;
    border: 2px solid #000;
    border-radius: 4px;
    margin-bottom: 16px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .kds-card-top {
    border-bottom: 1px dashed #999;
  }

  .kds-card-order-id {
    font-size: 14pt;
    font-weight: 900;
  }

  .kds-card-timer {
    font-size: 10pt;
    color: #666;
  }

  .kds-item-name {
    font-size: 11pt;
    color: #000;
  }

  .kds-item-qty {
    background: #eee;
    color: #000;
    font-weight: 900;
  }

  .kds-item-note {
    color: #666;
  }
}

/* ----------------------------------------------------------
   13. Responsive
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .kds-column {
    min-width: 280px;
  }

  .kds-topbar {
    padding: 0 12px;
  }

  .kds-board {
    padding: 10px;
  }

  .kds-clock {
    font-size: 1.2rem;
  }
}

/* ----------------------------------------------------------
   14. Scrollbar (global for KDS)
   ---------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--kds-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--kds-text-muted);
}
