/*
 * Ice Cream Shop Order Management System styles
 * Pastel themed light UI.
 */

/* CSS Variables for pastel colour palette */
:root {
  --color-background: #fffdf9;
  /* Primary palette switched to a bold red and yellow theme */
  --color-primary: #d32f2f; /* primary red */
  --color-secondary: #fdd835; /* secondary yellow */
  --color-accent: #fde047; /* accent light yellow */
  --color-success: #d1fae5; /* pastel green */
  --color-danger: #f8d7da; /* pastel red */
  --color-text: #3a3a3a;
  --color-muted: #8a8a8a;
  --color-card: #ffffff;
  --color-border: #e2e8f0;
  --border-radius: 8px;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
}


/* --- Prevent iOS Safari from auto-zooming inputs on focus (keep >=16px) --- */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: 16px;
  }
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--color-background);
  color: var(--color-text);
  overflow-x: hidden;
}

/* Secure input fields: use text-security to mask characters without triggering password managers */
.secure-input {
  -webkit-text-security: disc;
  text-security: disc;
}

/* Header / banner */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background-color: var(--color-primary);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

header .logo {
  display: flex;
  align-items: center;
  font-weight: bold;
  font-size: 24px;
  cursor: pointer;
}

/* Logo wrapper holds either image or fallback text */
header .logo-wrapper {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}
header .logo-wrapper img {
  height: 32px;
  width: auto;
}

header .nav-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

header button {
  background-color: var(--color-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

header button:hover {
  background-color: var(--color-accent);
}

/* Responsive navigation: wrap buttons on small screens */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  header .logo-wrapper {
    margin-bottom: 8px;
  }
  header .nav-buttons {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }
  header .nav-buttons button {
    flex: 1 1 calc(50% - 8px);
    padding: 6px 8px;
    font-size: 13px;
  }
  header .total-earning {
    width: 100%;
    margin-top: 8px;
    text-align: center;
    margin-left: 0;
  }
}

header .total-earning {
  padding: 6px 12px;
  background-color: var(--color-success);
  border-radius: var(--border-radius);
  font-weight: bold;
  font-size: 14px;
  margin-left: 16px;
}


/* Earnings banner indicator */
header .total-earning.earn-indicator {
  font-weight: 600;
  letter-spacing: 0.2px;
}

header .total-earning .amt {
  padding: 0 2px;
}

header .total-earning .free-text {
  color: #b91c1c; /* red for Free amount */
  font-weight: 700;
}

header .total-earning .total.negative {
  color: #b91c1c; /* red when total is negative */
  font-weight: 700;
}

/* Main content area */
#content {
  padding: 16px;
}

/* Page sections */
.page {
  display: none;
}

.page.active {
  display: block;
}

/* Cards */
.card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 12px;
  box-shadow: var(--shadow);
  margin: 8px 0;
}

.card h3 {
  margin: 0;
  margin-bottom: 8px;
}

.card .actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* List of items in cards grid */
/* Items grid for New Order page.  Use smaller minimum width to fit more cards on mobile. */
.items-grid {
  display: grid;
  /* Cards will be at least 140px wide allowing up to 8 items visible on small screens */
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

/* Item card inside new order */
/* Individual menu item card */
.item-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: auto;
  min-height: 130px;
}

/* Category badge inside item cards */
.item-card .cat-badge{
  align-self: flex-start;
  display: inline-block;
  margin-top: 2px;
  margin-bottom: 6px;
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-secondary, #6B7280);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px){
  .item-card .cat-badge{ white-space: normal; }
}



.item-card .name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  margin-bottom: 4px;
}

.item-card .price {
  color: var(--color-muted);
  margin-bottom: 6px;
}

.item-card .qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.item-card button {
  border: none;
  background-color: var(--color-secondary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.item-card button:hover {
  background-color: var(--color-accent);
}

.item-card .qty {
  min-width: 20px;
  text-align: center;
}

/* Buttons */
.btn {
  background-color: var(--color-secondary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

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

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

.btn-success {
  background-color: var(--color-success);
}

/* Floating place order button */
#placeOrderBtn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--color-accent);
  color: var(--color-text);
  padding: 12px 24px;
  border-radius: 30px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 10;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(0,0,0,0.4);
  z-index: 20;
}

.modal.active {
  display: flex;
}

.modal .modal-content {
  background-color: var(--color-card);
  border-radius: var(--border-radius);
  padding: 20px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-top: 0;
}

.modal input[type="text"],
.modal input[type="password"],
.modal input[type="number"],
.modal input[type="date"],
.modal input[type="file"] {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-sizing: border-box;
}

.modal .modal-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Reports preview */
.report-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

.report-card {
  flex: 1 1 200px;
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.report-card h4 {
  margin: 0;
  margin-bottom: 4px;
}

/* Tables for order history */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

th, td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--color-border);
}

th {
  background-color: var(--color-secondary);
}

/* Hide file input actual button */
input[type="file"] {
  display: none;
}

.file-label {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  background-color: var(--color-secondary);
  cursor: pointer;
}

.file-label:hover {
  background-color: var(--color-accent);
}

/* Date picker in Order History */
.date-picker {
  margin-bottom: 12px;
}

/* Setting options grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.settings-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s;
}

.settings-card:hover {
  transform: translateY(-3px);
}

/* Hiding elements */
.hidden {
  display: none !important;
}

/* Selected category indicator */
.cat-indicator{
  display: none;
  margin: 6px 0 10px 0;
  font-size: 13px;
  color: var(--text-secondary, #4B5563);
}
.cat-indicator .chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  background: var(--color-card);
}
.cat-indicator .chip .label{
  font-weight: 600;
}
.cat-indicator .chip .sep{
  opacity: 0.6;
}
.cat-indicator .chip .reset{
  text-decoration: underline;
  cursor: pointer;
}
.cat-indicator .chip .reset:hover{
  opacity: 0.8;
}


/* Payment method radio group */
.radio-group{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.radio-group label{display:flex;align-items:center;gap:6px}

/* Split amounts row inputs: ensure they align nicely and fill available width */
#splitAmountsRow input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
}

.modal-actions .back-btn { margin-right: auto; }


/* Allow banner text to wrap neatly on small screens */
header .total-earning {
  white-space: normal;
  line-height: 1.25;
}


/* Responsive Order History: horizontal scroll on small screens */
#orderHistoryList {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#orderHistoryList .order-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px; /* ensure all columns fit; enable scroll if viewport narrower */
}

#orderHistoryList .order-table th,
#orderHistoryList .order-table td {
  padding: 8px 10px;
  white-space: nowrap; /* keep columns tidy */
}

/* Slightly smaller font on narrow screens for better fit */
@media (max-width: 600px) {
  #orderHistoryList .order-table {
    font-size: 13px;
    min-width: 680px;
  }
  #orderHistoryList .order-table th,
  #orderHistoryList .order-table td {
    padding: 6px 8px;
  }
}

/* Optional: keep Order No. & Items columns visible when scrolling */
@media (max-width: 900px) {
  #orderHistoryList .order-table th:first-child,
  #orderHistoryList .order-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--color-card);
    z-index: 1;
  }
}


/* Make the 'Items' column readable without horizontal scroll */
#orderHistoryList .order-table th:nth-child(2),
#orderHistoryList .order-table td:nth-child(2) {
  /* allow wrapping of long item lists without breaking every character */
  white-space: normal;
  word-wrap: break-word;
  word-break: normal;
  max-width: 360px;
}

@media (max-width: 600px) {
  #orderHistoryList .order-table th:nth-child(2),
  #orderHistoryList .order-table td:nth-child(2) {
    max-width: 240px;       /* tighten on narrow screens */
  }
}


/* === Cloudy badge colors for category keywords === */
.badge-cloud-green { background: #16a34a; color: #ffffff; border-color: #15803d; }
.badge-cloud-blue  { background: #2563eb; color: #ffffff; border-color: #1d4ed8; }
.badge-cloud-red   { background: #dc2626; color: #ffffff; border-color: #b91c1c; }

/* Category list view (shown when pressing Category button on New Order) */
#categorySelectContainer.category-list{
  display: block;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-card);
  max-height: 45vh;
  overflow: auto;
}
#categorySelectContainer.category-list .btn{
  display: block;
  width: 100%;
  text-align: left;
  margin: 6px 0;
  padding: 10px 12px;
}

/* Override: make category badge allow up to 2 lines for full visibility */
.item-card .cat-badge{
  white-space: normal;            /* allow wrapping */
  display: -webkit-box;           /* enable line clamp on WebKit */
  -webkit-line-clamp: 2;          /* clamp to 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
  padding: 4px 8px;               /* slightly larger padding for multiple lines */
  font-weight: 600;               /* crisper text on solid color */
}


/* === Cloudy badge colors for category keywords === */
.badge-cloud-green { background: #bbf7d0; color: #065f46; border-color: #34d399; }
.badge-cloud-blue  { background: #bfdbfe; color: #1e3a8a; border-color: #60a5fa; }
.badge-cloud-red   { background: #fecaca; color: #991b1b; border-color: #f87171; }

/* Category list view (shown when pressing Category button on New Order) */
#categorySelectContainer.category-list{
  display: block;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-card);
  max-height: 45vh;
  overflow: auto;
}
#categorySelectContainer.category-list .btn{
  display: block;
  width: 100%;
  text-align: left;
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: var(--border-radius);
}

/* Apply cloudy colors to category list buttons too */
#categorySelectContainer.category-list .btn.tiny-joy { background: #bbf7d0; color: #065f46; border: 1px solid #34d399; }
#categorySelectContainer.category-list .btn.happy-scoop { background: #bfdbfe; color: #1e3a8a; border: 1px solid #60a5fa; }
#categorySelectContainer.category-list .btn.big-bliss { background: #fecaca; color: #991b1b; border: 1px solid #f87171; }



/* Pastel highlight for date-wise earning indicator on Order History */
#historyEarning {
  background: var(--color-primary);
  color: var(--color-text);
  padding: 8px 10px;
  border-radius: var(--border-radius);
  display: inline-block;
}

/* ====================================
 * Kitchen dashboard styles
 *
 * The kitchen dashboard uses a columnar list of order cards.  Each card
 * displays the order number with a colour-coded status, the items and
 * quantities, and an action button when appropriate.  The colours for
 * statuses are defined on the .orderno classes below.
 */
.kitchen-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kitchen-order {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kitchen-order .order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.kitchen-order .order-items {
  font-size: 14px;
}

.kitchen-order .order-actions {
  margin-top: 8px;
}

/* Status highlight classes for order numbers */
.orderno.placed {
  color: #d32f2f;
  font-weight: 700;
}
.orderno.ready {
  color: #2e7d32;
  font-weight: 700;
}
.orderno.completed {
  color: inherit;
  font-weight: 600;
}
