/* ==========================================================================
   QR-Hotel · Terminal Monitor de Pedidos (Cozinha, Bar/Piscina e Recepcao)
   Design System "Hotel Boutique Claro" · Legivel a 2m em tablet e monitor TV
   ========================================================================== */

.cozinha-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

/* --- Boot / Carregamento ------------------------------------------------- */
.boot-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px;
  text-align: center;
}

.boot-text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* --- Tela de Login (extensoes sobre theme.css) --------------------------- */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-footer {
  display: flex;
  justify-content: center;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.login-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.login-back-link:hover {
  color: var(--brand);
  background: var(--surface-alt);
  text-decoration: none;
}

/* --- Header Fixo do Terminal --------------------------------------------- */
.kds-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: max(10px, env(safe-area-inset-top, 10px))
           max(16px, env(safe-area-inset-right, 16px))
           10px
           max(16px, env(safe-area-inset-left, 16px));
}

.kds-header-inner {
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}

.kds-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 280px;
  flex-wrap: wrap;
}

.kds-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text);
  max-width: 100%;
}

.kds-user-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.kds-user-role {
  color: var(--text-muted);
  font-weight: 600;
  padding-left: 8px;
  border-left: 1px solid var(--border-strong);
  white-space: nowrap;
}

.kds-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kds-ctrl-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  font-size: 0.875rem;
}

.kds-ctrl-btn.is-active {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.kds-ctrl-btn.is-active:hover:not(:disabled) {
  background: #D8EEDF;
}

.kds-ctrl-btn.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.kds-ctrl-btn.is-warn:hover:not(:disabled) {
  background: #F9E6C7;
}

/* --- Barra de Abas Principais -------------------------------------------- */
.kds-nav-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 max(16px, env(safe-area-inset-right, 16px)) 0 max(16px, env(safe-area-inset-left, 16px));
}

.kds-nav-inner {
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kds-tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.kds-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9375rem;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.kds-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.kds-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.kds-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.kds-tab.active .kds-tab-count {
  background: var(--brand);
  color: var(--brand-contrast);
}

.kds-tab-count.has-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.kds-sync-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.kds-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kds-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.kds-live-dot.is-paused {
  background: var(--warn);
}

.kds-live-dot.is-error {
  background: var(--danger);
}

/* --- Container Principal ------------------------------------------------- */
.kds-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 16px
           max(16px, env(safe-area-inset-right, 16px))
           max(28px, env(safe-area-inset-bottom, 28px))
           max(16px, env(safe-area-inset-left, 16px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Banner de Novo Pedido (Flash Sutil) --------------------------------- */
.new-order-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--brand-contrast);
  border-left: 5px solid var(--accent);
  box-shadow: var(--shadow);
  animation: kdsBannerPulse 0.45s ease;
}

.new-order-banner-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.new-order-banner-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.new-order-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.new-order-banner-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.new-order-banner-sub {
  font-size: 0.875rem;
  opacity: 0.9;
}

.new-order-banner .btn-banner-close {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: var(--brand-contrast);
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.new-order-banner .btn-banner-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

@keyframes kdsBannerPulse {
  0% { transform: translateY(-6px); opacity: 0.6; }
  60% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

/* --- Barra de Filtros (Setor + Status) ----------------------------------- */
.kds-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.pill-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  margin-right: 2px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 700;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-pill:hover {
  background: var(--surface-alt);
}

.filter-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
}

.filter-pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(24, 32, 44, 0.09);
  color: var(--text);
}

.filter-pill.active .filter-pill-count {
  background: rgba(255, 255, 255, 0.22);
  color: var(--brand-contrast);
}

.status-segmented {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 700;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.status-pill:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.status-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

/* --- Faixa de Resumo Rapido da Fila -------------------------------------- */
.kds-summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.kds-summary-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.kds-metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--text);
}

.kds-metric-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.kds-metric-dot.dot-recebido { background: var(--info); }
.kds-metric-dot.dot-preparando { background: var(--warn); }
.kds-metric-dot.dot-atraso { background: var(--danger); }

/* --- Grade de Tickets (Alta Legibilidade a 2m) --------------------------- */
.tickets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr));
  gap: 18px;
  align-items: start;
}

.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 6px solid var(--ok);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.ticket-card.urgency-ok {
  border-top-color: var(--ok);
}

.ticket-card.urgency-warn {
  border-top-color: var(--warn);
}

.ticket-card.urgency-danger {
  border-top-color: var(--danger);
  border-color: var(--danger-border);
  box-shadow: 0 6px 20px rgba(185, 56, 56, 0.14);
}

.ticket-card.status-entregue {
  border-top-color: var(--ok);
}

.ticket-card.status-cancelado {
  border-top-color: var(--border-strong);
  opacity: 0.92;
}

.ticket-card.is-new-flash {
  box-shadow: 0 0 0 3px var(--accent), var(--shadow-lg);
  animation: kdsCardArrival 1.2s ease;
}

@keyframes kdsCardArrival {
  0% { transform: translateY(-4px); box-shadow: 0 0 0 5px var(--accent), var(--shadow-lg); }
  100% { transform: translateY(0); box-shadow: 0 0 0 3px var(--accent), var(--shadow-lg); }
}

/* Cabecalho do Ticket */
.ticket-head {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #FFFFFF 0%, #FAF8F4 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-head-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ticket-point-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ticket-point-title {
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.18;
  color: var(--brand);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.ticket-point-sub {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ticket-timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 1.0625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1.5px solid transparent;
}

.ticket-timer.timer-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-border);
}

.ticket-timer.timer-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-border);
}

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

.ticket-timer.timer-done {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: var(--border);
  font-size: 0.875rem;
}

.ticket-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-badges .badge {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 0.8125rem;
}

/* Corpo do Ticket (Lista de Itens) */
.ticket-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 0 auto;
}

.ticket-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ticket-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.ticket-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.ticket-item-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.ticket-qty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 36px;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: 1.1875rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  flex-shrink: 0;
}

.ticket-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
  padding-top: 2px;
}

.ticket-item-name {
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.28;
  color: var(--text);
  word-break: break-word;
}

.ticket-item-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-cortesia {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: #6E5120;
  border: 1px solid rgba(176, 138, 72, 0.45);
  font-size: 0.8125rem;
  font-weight: 800;
}

.ticket-item-obs {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 4px solid var(--warn);
  color: #5C3806;
  font-size: 0.96875rem;
  line-height: 1.38;
  word-break: break-word;
}

.ticket-item-obs-label {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 2px;
  color: #8A540E;
}

.ticket-cancel-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-left: 4px solid var(--danger);
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Rodape de Acoes do Ticket */
.ticket-actions {
  padding: 14px 18px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.ticket-action-btn {
  flex: 1 1 130px;
  min-height: 48px;
  font-size: 0.96875rem;
  font-weight: 700;
  padding: 0 14px;
}

.ticket-action-cancel {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 14px;
  font-size: 0.875rem;
}

.ticket-meta-foot {
  padding: 10px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* --- Aba Itens Esgotados ------------------------------------------------- */
.stock-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stock-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  display: flex;
  align-items: center;
}

.search-box-icon {
  position: absolute;
  left: 12px;
  color: var(--text-subtle);
  pointer-events: none;
  display: inline-flex;
}

.search-box .input {
  padding-left: 40px;
  padding-right: 44px;
}

.search-clear-btn {
  position: absolute;
  right: 2px;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.search-clear-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.stock-filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
}

.stock-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stock-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stock-group-title {
  font-size: 0.875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding-left: 4px;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 12px;
}

.stock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.stock-card.is-soldout {
  background: #FFF9F9;
  border-color: var(--danger-border);
  border-left: 5px solid var(--danger);
}

.stock-card-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.stock-item-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}

.stock-card.is-soldout .stock-item-name {
  color: var(--danger);
}

.stock-item-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.stock-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stock-toggle-btn {
  min-height: 46px;
  min-width: 138px;
  padding: 0 14px;
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Responsividade TV / Tablet / Mobile --------------------------------- */
@media (min-width: 1440px) {
  .tickets-grid {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
  }

  .ticket-point-title {
    font-size: 1.5rem;
  }

  .ticket-item-name {
    font-size: 1.25rem;
  }
}

@media (max-width: 720px) {
  .kds-header-inner {
    gap: 10px;
  }

  .kds-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .kds-ctrl-btn {
    flex: 1 1 auto;
  }

  .kds-nav-inner {
    gap: 6px;
  }

  .kds-tabs {
    width: 100%;
  }

  .kds-tab {
    flex: 1;
    justify-content: center;
    padding: 0 10px;
    font-size: 0.875rem;
  }

  .kds-sync-bar {
    width: 100%;
    justify-content: space-between;
  }

  .ticket-point-title {
    font-size: 1.25rem;
  }

  .ticket-actions {
    flex-direction: column;
  }

  .ticket-action-btn,
  .ticket-action-cancel {
    width: 100%;
    flex: 1 1 auto;
  }

  .stock-card {
    flex-direction: column;
    align-items: stretch;
  }

  .stock-toggle-btn {
    width: 100%;
  }
}
