/* ============================================================
   CUSTOMER ORDERS — customer_orders.css
   Shared across all CustomerOrders pages
   ============================================================ */

/* ── Page wrapper ── */
.co-page {
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  box-sizing: border-box;
}

.co-page.narrow {
  max-width: 860px;
}

/* ── Page header ── */
.co-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.co-page-title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin: 0;
}

.co-page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================================
   STATUS PILLS
   ============================================================ */

.co-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.co-status.awaiting  { background: var(--info-light, #eff6ff);   color: #3b82f6; }
.co-status.ordered   { background: var(--accent-light, #fdf3e0); color: var(--accent-dark, #c4831a); }
.co-status.called    { background: #f3e8ff;                       color: #7c3aed; }
.co-status.completed { background: #dcfce7;                       color: #15803d; }

/* ============================================================
   FILTER ROW
   ============================================================ */

.co-filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: nowrap;
}

/* Hide any hidden inputs that Django might render visibly */
.co-filter-row input[type="hidden"] {
  display: none !important;
}

.co-filter-row select,
.co-filter-row input[type="search"],
.co-filter-row input[type="text"] {
  padding: 0.4375rem 0.875rem;
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  height: 36px;
  box-sizing: border-box;
}

.co-filter-row select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ba3b5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-color: var(--surface);
  padding-right: 2rem;
  cursor: pointer;
}

.co-filter-row select:focus,
.co-filter-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,160,32,0.12);
}

.co-filter-row input[type="search"] {
  flex: 1;
  min-width: 0;
}

.co-filter-row input::placeholder { color: var(--text-muted); }

/* ============================================================
   TABLE — desktop
   ============================================================ */

.co-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: auto;
  width: 100%;
}

.co-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.co-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.co-table thead tr {
  background: var(--surface-2);
  border-bottom: 1.5px solid var(--border);
}

.co-table th {
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: left;
}

.co-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s ease;
}

.co-table tbody tr:last-child { border-bottom: none; }
.co-table tbody tr:hover { background: var(--surface-2); }

.co-table td {
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  vertical-align: middle;
}

.co-table td.muted { color: var(--text-muted); }
.co-table td.mono  { font-family: var(--font-data); font-size: 0.75rem; }

.co-page-header-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.co-page-header-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.co-page-header--mb { margin-bottom: 1rem; }
.co-order-comments {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin: 0;
  white-space: pre-wrap;
}
.co-search-result--static { cursor: default; }
.co-search-result-icon--blue   { background: #e8f0fe; color: #3b5bdb; }
.co-search-result-icon--purple { background: #f3e8ff; color: #7c3aed; }
.co-search-result-icon--green  { background: #dcfce7; color: #15803d; }
.co-search-result-icon--orange { background: #fff3e0; color: #e8700a; }
.co-search-result-icon--sky    { background: #e0f2fe; color: #0284c7; }
.co-search-result-icon--pink   { background: #fce4ec; color: #c2255c; }

/* ── Icon action button ── */
.co-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.12s ease;
  cursor: pointer;
}

.co-icon-btn:hover { background: var(--surface-2); color: var(--text-primary); border-color: #c8cdd8; }
.co-icon-btn .material-symbols-outlined { font-size: 16px; }

/* ── Pagination ── */
.co-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.8125rem;
}

.co-pager a {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.12s ease;
}

.co-pager a:hover { background: var(--surface-2); color: var(--text-primary); }
.co-pager-info { color: var(--text-muted); padding: 0 0.5rem; }

/* ============================================================
   MOBILE ORDER CARDS
   Shown instead of the table on small screens.
   ============================================================ */

.co-order-cards {
  display: none; /* hidden on desktop — shown via media query */
  flex-direction: column;
  gap: 0.625rem;
}

/* The entire card is one tappable block */
a.co-order-card,
.co-order-card {
  background: #ffffff !important;
  border: 1px solid #e4e6ea !important;
  border-radius: 16px !important;
  box-shadow: 0 1px 3px rgba(15,22,35,0.06) !important;
  padding: 0.875rem 1rem !important;
  text-decoration: none !important;
  color: #0f1623 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.5rem !important;
  overflow: hidden !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

a.co-order-card:active,
a.co-order-card:hover,
.co-order-card:active {
  background: #f8f9fb !important;
  color: #0f1623 !important;
  text-decoration: none !important;
}

/* Top row: customer name (left) | status + edit (right) */
.co-order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  /* Do NOT let this be a separate box — it's just a flex row inside the card */
}

.co-order-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.co-order-card-header-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* Item + brand line */
.co-order-card-item {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.co-order-card-item-brand {
  color: var(--text-muted);
  font-weight: 400;
}

/* Meta row: store · date · phone */
.co-order-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.875rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.co-order-card-meta-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
}

.co-order-card-meta-item .material-symbols-outlined {
  font-size: 12px;
  opacity: 0.55;
}

/* ============================================================
   DETAIL / FORM CARDS
   ============================================================ */

.co-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1rem;
}

.co-card-header {
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-2);
}

.co-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.co-card-body {
  padding: 1.25rem 1.5rem;
}

/* ── Field grid ── */
.co-field-grid {
  display: grid;
  gap: 1.25rem;
}

.co-field-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.co-field-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.co-field-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── View field (label + value) ── */
.co-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.co-field-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.co-field-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

.co-field-value.empty { color: var(--text-muted); font-style: italic; }

/* ── Form field (label + input) ── */
.co-form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.co-form-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.co-form-label .required { color: var(--danger, #dc2626); margin-left: 2px; }

.co-form-field input,
.co-form-field select,
.co-form-field textarea {
  width: 100%;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.co-form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ba3b5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-color: var(--surface-2);
  padding-right: 2.25rem;
  cursor: pointer;
}

.co-form-field input:focus,
.co-form-field select:focus,
.co-form-field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(232,160,32,0.12);
}

.co-form-field input.error,
.co-form-field select.error,
.co-form-field textarea.error {
  border-color: var(--danger, #dc2626);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.08);
}

.co-form-field input::placeholder,
.co-form-field textarea::placeholder { color: var(--text-muted); }
.co-form-field textarea { resize: vertical; min-height: 80px; }

.co-field-error {
  font-size: 0.6875rem;
  color: var(--danger, #dc2626);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.co-field-error .material-symbols-outlined { font-size: 14px; }

/* ── Form error banner ── */
.co-error-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.8125rem;
  color: var(--danger, #dc2626);
}

.co-error-banner .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }

/* ── Form footer ── */
.co-form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.co-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-ui);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.co-btn .material-symbols-outlined { font-size: 16px; }

.co-btn-primary {
  background: var(--text-primary);
  color: #ffffff;
  border-color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.co-btn-primary:hover { background: #1e2d45; border-color: #1e2d45; }

.co-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.co-btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }

/* Smaller variant used on the Customer Orders table action column */
.co-btn--xs {
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  border-radius: var(--radius-sm);
}

/* Full-width variant used inside the mobile card footer */
.co-btn--full {
  width: 100%;
  justify-content: center;
}

/* Wrapper for the mobile card's "advance status" button */
.co-order-card-action {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.co-login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: var(--bg, #f4f5f7);
  font-family: var(--font-ui);
}

.co-login-left {
  width: 480px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 3.5rem;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}

.co-login-logo {
  width: 220px;
  height: auto;
  margin-bottom: 2rem;
}

.co-login-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0 0 0.375rem;
}

.co-login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 2rem;
}

.co-login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.co-login-form input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.co-login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,160,32,0.12);
  background: var(--surface);
}

.co-login-form input::placeholder { color: var(--text-muted); }

.co-login-submit {
  width: 100%;
  padding: 0.625rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-ui);
  color: #ffffff;
  background: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}

.co-login-submit:hover { background: #1e2d45; }

.co-login-messages {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.co-login-messages li {
  font-size: 0.8125rem;
  color: var(--danger, #dc2626);
  padding: 0.5rem 0.75rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.co-login-right {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.co-login-right img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ============================================================
   GLOBAL SEARCH RESULTS
   ============================================================ */

.co-search-page {
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  box-sizing: border-box;
}

.co-search-query {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.co-search-query strong { color: var(--text-primary); }

.co-search-quicklinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.co-search-quicklink {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  transition: all 0.12s ease;
  box-shadow: var(--shadow-sm);
}

.co-search-quicklink:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: #c8cdd8;
}

.co-search-quicklink .material-symbols-outlined { font-size: 14px; }

.co-search-section { margin-bottom: 1.5rem; }

.co-search-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.co-search-result {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.12s ease;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.co-search-result:hover {
  background: var(--surface-2);
  border-color: #c8cdd8;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.co-search-result-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.co-search-result-icon .material-symbols-outlined { font-size: 18px; }

.co-search-result-icon.order    { background: #e8f0fe; color: #3b5bdb; }
.co-search-result-icon.invoice  { background: #fff3e0; color: #e8700a; }
.co-search-result-icon.supplier { background: #dcfce7; color: #15803d; }
.co-search-result-icon.store    { background: #f3e8ff; color: #7c3aed; }

.co-search-result-body {
  flex: 1;
  min-width: 0;
}

.co-search-result-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.co-search-result-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
  display: block;
}

.co-search-result-badge { flex-shrink: 0; }

.co-search-empty {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 1.5rem 0;
  text-align: center;
}

/* ============================================================
   RESPONSIVE — tablet (≤ 768px)
   ============================================================ */

@media (max-width: 768px) {
  .co-page          { padding: 1rem; }
  .co-page.narrow   { padding: 1rem; }
  .co-search-page   { padding: 1rem; }

  /* Page header: stack title + actions */
  .co-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }
  .co-page-actions { width: 100%; justify-content: flex-end; }

  /* Filter row: two selects on row 1, search full-width on row 2 */
  .co-filter-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .co-filter-row select {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
    max-width: calc(50% - 0.25rem);
  }
  .co-filter-row input[type="search"] {
    flex: 1 1 100%;
    width: 100%;
    order: 3;
  }
  .co-filter-row input[type="hidden"] {
    display: none !important;
  }
  .co-filter-row .co-btn {
    order: 4;
    flex: 0 0 auto;
  }

  /* Hide desktop table, show card list */
  .co-table-wrapper { display: none; }
  .co-order-cards   { display: flex; }

  /* Field grids: 2-col for tablets */
  .co-field-grid.cols-3,
  .co-field-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }

  /* Cards: slightly less padding */
  .co-card-body   { padding: 1rem 1.25rem; }
  .co-card-header { padding: 0.75rem 1.25rem; }

  /* Form footer: full width buttons */
  .co-form-footer {
    flex-direction: row;
    justify-content: stretch;
  }
  .co-form-footer .co-btn {
    flex: 1;
    justify-content: center;
  }

  /* Login */
  .co-login-left  { width: 100%; padding: 2rem 1.5rem; }
  .co-login-right { display: none; }
}

/* ============================================================
   RESPONSIVE — mobile (≤ 480px)
   ============================================================ */

@media (max-width: 480px) {
  /* All grids go single column */
  .co-field-grid.cols-2,
  .co-field-grid.cols-3,
  .co-field-grid.cols-4 { grid-template-columns: 1fr; }

  /* Filter selects each take half width */
  .co-filter-row select { min-width: calc(50% - 0.25rem); }

  /* Tighter card padding */
  .co-card-body   { padding: 0.875rem 1rem; }
  .co-card-header { padding: 0.625rem 1rem; }

  /* Pager: fewer items */
  .co-pager { flex-wrap: wrap; gap: 0.375rem; }

  /* Search quicklinks: 2 per row */
  .co-search-quicklink { font-size: 0.6875rem; }
}