/* ===== COS-inspired Minimal Design System =====
 * Adapted from one.oocard.com for multi.oocard.com dashboard
 * Sharp edges, thin borders, generous whitespace,
 * monochrome palette, large typography, no visual noise.
 */

:root {
  --pico-font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pico-border-radius: 0px;
  --pico-primary: #000;
  --pico-primary-hover: #333;
  --pico-primary-focus: rgba(0, 0, 0, 0.05);
  --pico-primary-inverse: #fff;
  --pico-color: #1a1a1a;
  --pico-muted-color: #767676;
  --pico-muted-border-color: #e0e0e0;
  --border: 1px solid #e0e0e0;
  --space-xs: 0.375rem;
  --space-sm: 0.625rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html { scroll-behavior: smooth; overscroll-behavior-y: none; }
body { padding: 0; margin: 0; overflow-x: hidden; background: #fff; color: var(--pico-color); font-family: var(--pico-font-family); font-size: 0.875rem; line-height: 1.5; }

/* Force 16px inputs on mobile to prevent zoom */
input, select, textarea { font-size: 16px !important; font-family: var(--pico-font-family); }
input::placeholder { color: #888; font-weight: 400; }
select { color: #888; }
select.filled { color: var(--pico-color); }

/* ===== Auth Pages ===== */
.auth-container {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-xl) var(--space-lg);
}
.auth-box {
  width: 100%; max-width: 380px;
}
.auth-box h1 {
  font-size: 1.25rem; font-weight: 500;
  letter-spacing: 0.05em; text-transform: uppercase;
  text-align: center; margin-bottom: var(--space-xs);
}
.auth-box .auth-subtitle {
  font-size: 0.8125rem; color: var(--pico-muted-color);
  text-align: center; margin-bottom: var(--space-xl);
  font-weight: 300;
}
.auth-view { display: none; }
.auth-view:first-child { display: block; }

.auth-form .form-group {
  margin-bottom: var(--space-sm);
}
.auth-form input {
  width: 100%; padding: 0.75rem 0.875rem;
  border: var(--border); border-radius: 0; background: #fff;
  text-transform: none;
}
.auth-form input:focus {
  border-color: #000; outline: none; box-shadow: none;
}
.auth-form input::placeholder { text-transform: none; }
.auth-links {
  text-align: center; margin-top: var(--space-md);
  font-size: 0.8125rem;
}
.auth-links a {
  color: var(--pico-muted-color); text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer;
}
.auth-links a:hover { color: #000; }

.verify-message {
  text-align: center; padding: var(--space-xl) 0;
}
.verify-message p { font-size: 0.875rem; line-height: 1.6; margin-bottom: var(--space-md); }
.verify-email { font-weight: 500; }

/* ===== Buttons ===== */
.btn-primary {
  width: 100%; background: #000; color: #fff;
  border: none; border-radius: 0;
  padding: 0.875rem; font-size: 0.8125rem;
  font-weight: 400; letter-spacing: 0.1em;
  text-transform: uppercase; cursor: pointer;
  transition: background 0.2s; touch-action: manipulation;
}
.btn-primary:hover { background: #333; }
.btn-primary:active { background: #000; }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-secondary {
  width: 100%; background: #fff; color: #000;
  border: var(--border); border-radius: 0;
  padding: 0.75rem; font-size: 0.8125rem;
  font-weight: 400; letter-spacing: 0.05em;
  text-transform: uppercase; cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #f5f5f5; }

.btn-small {
  padding: 0.5rem 0.75rem; font-size: 0.75rem;
  width: auto; display: inline-block;
}

.btn-danger {
  background: #fff; color: #c00; border: 1px solid #c00;
}
.btn-danger:hover { background: #fef5f5; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 0.375rem; color: #999; font-size: 1rem;
  transition: color 0.15s; display: inline-flex;
  align-items: center; justify-content: center;
}
.btn-icon:hover { color: #000; }
.btn-icon.btn-icon-danger:hover { color: #c00; }

/* ===== Dashboard Layout ===== */
.dashboard-nav {
  display: flex; align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: var(--border);
  background: #fff;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: #000; text-decoration: none;
  margin-right: auto;
}
.nav-user {
  font-size: 0.75rem; color: var(--pico-muted-color);
  display: flex; align-items: center; gap: var(--space-sm);
}
.nav-user a { color: var(--pico-muted-color); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: 0.75rem; }
.nav-user a:hover { color: #000; }

.dashboard-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 45px);
}

/* ===== Sidebar (People Panel) ===== */
.sidebar {
  border-right: var(--border);
  background: #fafafa;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md);
  border-bottom: var(--border);
}
.sidebar-header h2 {
  font-size: 0.6875rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0;
}
.sidebar-list { flex: 1; overflow-y: auto; }

.contact-item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0.75rem var(--space-md);
  border-bottom: var(--border);
  cursor: pointer; transition: background 0.1s;
}
.contact-item:hover { background: #f0f0f0; }
.contact-item.contact-active { background: #fff; border-left: 2px solid #000; }
.contact-avatar {
  width: 32px; height: 32px;
  background: #e0e0e0; color: #767676;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 500;
  text-transform: uppercase; flex-shrink: 0;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-size: 0.8125rem; font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contact-meta {
  font-size: 0.6875rem; color: var(--pico-muted-color); font-weight: 300;
}
.contact-cards-count {
  font-size: 0.6875rem; color: var(--pico-muted-color);
  background: #e0e0e0; padding: 2px 6px; flex-shrink: 0;
}

/* ===== Main Content (Cards Panel) ===== */
.main-content {
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.content-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md);
  border-bottom: var(--border);
}
.content-header h2 {
  font-size: 0.875rem; font-weight: 400;
  margin: 0;
}
.content-body {
  flex: 1; padding: var(--space-md);
  overflow-y: auto;
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.card-tile {
  border: var(--border);
  background: #fff;
  transition: border-color 0.15s;
  position: relative;
}
.card-tile:hover { border-color: #000; }
.card-tile-img {
  width: 100%; aspect-ratio: 86/54;
  object-fit: cover; display: block;
  border-bottom: var(--border);
}
.card-tile-body { padding: var(--space-sm); }
.card-tile-name {
  font-size: 0.75rem; font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 2px;
}
.card-tile-sku {
  font-size: 0.6875rem; color: var(--pico-muted-color); font-weight: 300;
}
.card-tile-status {
  font-size: 0.5625rem; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 2px 6px;
  display: inline-block; margin-top: var(--space-xs);
}
.card-tile-status.status-draft { background: #f5f5f5; color: #767676; }
.card-tile-status.status-active { background: #e8f5e9; color: #2e7d32; }
.card-tile-actions {
  display: flex; gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  border-top: var(--border);
}
.card-tile-actions button { flex: 1; }

.card-add-tile {
  border: 1px dashed #ccc;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 160px; cursor: pointer;
  transition: border-color 0.15s;
  color: #999;
}
.card-add-tile:hover { border-color: #000; color: #000; }
.card-add-tile svg { width: 32px; height: 32px; margin-bottom: var(--space-xs); stroke: currentColor; }
.card-add-tile span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== Product Picker ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
  padding: var(--space-md) 0;
}
.product-pick {
  border: var(--border); padding: var(--space-sm);
  text-align: center; cursor: pointer;
  transition: border-color 0.15s;
}
.product-pick:hover { border-color: #000; }
.product-pick.product-selected { border-color: #000; background: #fafafa; }
.product-pick-img { width: 100%; height: 80px; object-fit: contain; margin-bottom: var(--space-xs); }
.product-pick-name { font-size: 0.6875rem; font-weight: 400; line-height: 1.3; }
.product-pick-price { font-size: 0.6875rem; color: var(--pico-muted-color); font-weight: 300; }

/* ===== Order Panel ===== */
.order-panel {
  border-top: var(--border);
  background: #fafafa;
  padding: var(--space-md);
}
.order-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-md);
}
.order-panel-header h3 {
  font-size: 0.6875rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0;
}

.order-items-list { margin-bottom: var(--space-md); }
.order-item-row {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: var(--border);
  font-size: 0.8125rem;
}
.order-item-row:last-child { border-bottom: none; }
.order-item-thumb {
  width: 48px; height: 30px;
  object-fit: cover; border: var(--border); flex-shrink: 0;
}
.order-item-info { flex: 1; min-width: 0; }
.order-item-name {
  font-weight: 400; font-size: 0.75rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.order-item-person {
  font-size: 0.6875rem; color: var(--pico-muted-color); font-weight: 300;
}
.order-item-price {
  font-weight: 400; font-size: 0.8125rem;
  color: var(--pico-muted-color); white-space: nowrap; flex-shrink: 0;
}

.order-totals {
  padding-top: var(--space-md);
  border-top: var(--border);
}
.order-total-row {
  display: flex; justify-content: space-between;
  padding: var(--space-xs) 0;
  font-size: 0.8125rem; font-weight: 300;
}
.order-total-row.order-total-final {
  font-weight: 500; font-size: 1rem;
  padding-top: var(--space-sm);
  border-top: var(--border);
  margin-top: var(--space-xs);
}
.order-discount-row { color: #2e7d32; }
.order-discount-badge {
  font-size: 0.5625rem; background: #e8f5e9; color: #2e7d32;
  padding: 2px 6px; text-transform: uppercase; letter-spacing: 0.03em;
  display: inline-block; margin-left: var(--space-xs);
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 9999;
}
.modal-box {
  width: 100%; max-width: 520px;
  max-height: 92vh;
  background: #fff;
  display: flex; flex-direction: column;
  position: relative;
  overscroll-behavior: contain;
  border-radius: 12px 12px 0 0;
  animation: sheetSlideUp 0.3s ease-out;
}
@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-box::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: #ddd; border-radius: 2px;
  margin: 8px auto 0;
  flex-shrink: 0;
}
@media (min-width: 521px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 0; max-height: 85vh; animation: modalFadeIn 0.2s ease-out; }
  .modal-box::before { display: none; }
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute; right: 0.5rem; top: 0.75rem; z-index: 10;
  border: none; cursor: pointer;
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.05); color: #000;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(0,0,0,0.1); }
.modal-header {
  padding: 0.75rem var(--space-md);
  padding-right: 3rem;
  border-bottom: var(--border); flex-shrink: 0;
}
.modal-header h2 {
  font-size: 0.875rem; font-weight: 500; margin: 0;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.modal-body {
  flex: 1; overflow-y: auto; padding: var(--space-md);
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: var(--space-sm) var(--space-md);
  padding-bottom: max(var(--space-lg), env(safe-area-inset-bottom));
  border-top: var(--border); flex-shrink: 0;
  background: #fff;
  display: flex; gap: var(--space-sm);
}
.modal-footer .btn-primary { flex: 1; }
.modal-footer .btn-secondary { flex: 1; }

/* ===== Form Elements (shared) ===== */
.form-group { position: relative; margin-bottom: var(--space-sm); }
.form-group label {
  font-size: 0.6875rem; color: #1a1a1a;
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; margin-bottom: 0.25rem; display: block;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
select {
  border: var(--border) !important;
  border-radius: 0 !important;
  padding: 0.75rem 0.875rem;
  background: #fff;
  width: 100%; box-sizing: border-box;
  color: var(--pico-color); font-weight: 400;
  transition: border-color 0.2s;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  border-color: #000 !important;
  outline: none; box-shadow: none;
}
input[type="checkbox"], input[type="radio"] {
  accent-color: #000;
  width: 18px; height: 18px; cursor: pointer;
}

.form-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-sm); margin-bottom: var(--space-sm);
}
.form-row .form-group { margin-bottom: 0; }

/* Date pickers */
.date-picker-group { margin-bottom: var(--space-sm); }
.date-picker-row {
  display: grid; grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.375rem;
}
.date-picker-row select {
  text-align: center; min-height: 44px; margin-bottom: 0;
  appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 5 5-5' stroke='%23999' stroke-width='1' fill='none'/%3E%3C/svg%3E") right 0.5rem center no-repeat;
  padding-right: 1.5rem; cursor: pointer;
}

/* Validation */
.field-error { border-color: #c00 !important; background-color: #fef5f5 !important; animation: shake 0.4s ease; }
input.filled, select.filled { border-color: #4a7c59 !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-3px); }
  30% { transform: translateX(3px); }
  45% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
}

/* Searchable select */
.searchable-select-wrapper { position: relative; margin-bottom: var(--space-sm); }
.searchable-trigger {
  display: block; width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 0.875rem;
  border: var(--border);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 5 5-5' stroke='%23999' stroke-width='1' fill='none'/%3E%3C/svg%3E") right 0.875rem center no-repeat;
  color: #888; font-size: 16px !important; line-height: 1.4;
  text-transform: uppercase; font-weight: 400;
  cursor: pointer; user-select: none;
  outline: none; transition: border-color 0.15s;
}
.searchable-trigger:focus { border-color: #000; }
.searchable-trigger.filled { color: var(--pico-color); }
.searchable-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: var(--border); border-top: none;
  max-height: 240px; overflow-y: auto;
  z-index: 100; display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.searchable-dropdown.open { display: block; }
.searchable-dropdown-search {
  position: sticky; top: 0; background: #fff;
  padding: var(--space-xs); border-bottom: var(--border);
}
.searchable-dropdown-search input {
  width: 100%; margin: 0;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8125rem !important; text-transform: none; font-weight: 300;
}
.searchable-dropdown-option {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer; text-transform: uppercase;
  font-size: 0.8125rem; font-weight: 300;
  transition: background 0.1s;
}
.searchable-dropdown-option:hover { background: #f5f5f5; }
.searchable-dropdown-option.hidden { display: none; }

/* Photo upload */
.photo-upload {
  border: 1px dashed #ccc; padding: var(--space-xl);
  text-align: center; cursor: pointer;
  transition: border-color 0.2s;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 150px;
}
.photo-upload:hover { border-color: #000; }
.photo-upload input[type="file"] { display: none; }
.photo-upload img { max-width: 100%; max-height: 180px; margin: 0 auto; display: block; }
.photo-upload .placeholder { color: #999; font-size: 0.75rem; }
.photo-upload.field-error { border-color: #c00 !important; background: #fef5f5 !important; }

/* Signature pad */
.signature-pad {
  border: 1px dashed #ccc;
  touch-action: none; cursor: crosshair;
  overflow: hidden; position: relative;
}
.signature-pad canvas { width: 100%; height: 150px; display: block; }
.signature-actions { display: flex; gap: var(--space-xs); margin-top: var(--space-xs); }
.signature-actions button {
  flex: 1; padding: 0.5rem; font-size: 0.75rem;
  background: #f5f5f5; border: var(--border); color: #000;
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.03em;
}
.signature-actions button:hover { background: #eee; }

/* Card preview */
.card-preview-img {
  overflow: hidden; position: relative;
  aspect-ratio: 86/54; border-radius: 8px;
  margin-bottom: var(--space-md);
}
.card-preview-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===== Confirm Dialog ===== */
.confirm-overlay .confirm-box {
  background: #fff; padding: var(--space-lg);
  padding-bottom: max(var(--space-lg), env(safe-area-inset-bottom));
  max-width: 400px; width: 100%; text-align: center;
}
.confirm-box p { font-size: 0.875rem; margin: 0 0 var(--space-lg); line-height: 1.5; font-weight: 300; }
.confirm-actions { display: flex; gap: var(--space-sm); }
.confirm-actions button { flex: 1; padding: 0.75rem; font-size: 0.8125rem; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: -60px; left: 50%; transform: translateX(-50%);
  background: #000; color: #fff;
  padding: 0.75rem 1.5rem;
  font-size: 0.8125rem; font-weight: 400;
  z-index: 100000; white-space: nowrap;
  transition: top 0.3s ease;
  max-width: 90vw;
}
.toast-visible { top: 1rem; }
.toast-error { background: #c00; }
.toast-success { background: #2e7d32; }

/* ===== Loading & Empty States ===== */
.loading-state, .empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-xl);
  color: var(--pico-muted-color);
  text-align: center;
}
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid #e0e0e0; border-top-color: #000;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin-bottom: var(--space-md);
}
.empty-state p { font-size: 0.875rem; margin-bottom: var(--space-md); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Spinner (inline) ===== */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

/* ===== Mobile Layout ===== */
.mobile-tabs {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-tabs-inner {
  display: flex;
}
.mobile-tab {
  flex: 1; padding: 0.625rem;
  text-align: center; cursor: pointer;
  font-size: 0.5625rem; font-weight: 400;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  border: none; background: none;
  transition: color 0.15s;
}
.mobile-tab-active { color: #000; font-weight: 500; }
.mobile-tab svg { display: block; margin: 0 auto 2px; width: 20px; height: 20px; }

@media (max-width: 768px) {
  .dashboard-body {
    grid-template-columns: 1fr;
  }
  .sidebar { display: none; border-right: none; }
  .dashboard-panel { display: none; }
  .dashboard-panel.panel-active { display: flex; flex-direction: column; }
  .sidebar.panel-active { display: flex; }
  .mobile-tabs { display: block; }
  .main-content { padding-bottom: 60px; }
  .order-panel { padding-bottom: 80px; }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* ===== Utility ===== */
.text-muted { color: var(--pico-muted-color); }
.text-small { font-size: 0.75rem; }
.text-center { text-align: center; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.gap-sm { gap: var(--space-sm); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
