/**
 * Bazyaft Visual Design Library — Component Styles
 * Buttons, Cards, Forms, Tables, Navigation, Tags, Tabs, etc.
 */

/* ═══════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-family-fa);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  min-height: var(--touch-target-min);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  -webkit-appearance: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--color-primary-700);
  color: white;
  box-shadow: 0 1px 2px rgba(21,128,61,0.3);
}
.btn-primary:hover { background: var(--color-primary-800); box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--bg-surface-subtle); border-color: var(--color-neutral-400); }

.btn-danger {
  background: var(--color-danger-base);
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
}
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text-main); }

.btn-link {
  background: transparent; border: none; color: var(--color-primary-700);
  padding: 0; min-height: auto; font-weight: var(--font-weight-medium);
}
.btn-link:hover { text-decoration: underline; }

/* Size Variants */
.btn-sm { padding: 6px var(--space-3); font-size: var(--font-size-sm); min-height: 36px; }
.btn-lg { padding: 14px var(--space-8); font-size: var(--font-size-lg); min-height: 56px; }
.btn-xl { padding: 16px var(--space-10); font-size: var(--font-size-xl); min-height: 64px; } /* Driver UI */
.btn-icon { padding: var(--space-2); min-width: var(--touch-target-min); border-radius: var(--radius-md); }
.btn-icon-driver { padding: var(--space-3); min-width: var(--touch-target-driver); border-radius: var(--radius-lg); }
.btn-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-hover { transition: box-shadow var(--transition-fast), transform var(--transition-fast); cursor: pointer; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-3);
}
.card-header-title { font-weight: var(--font-weight-semibold); font-size: var(--font-size-base); }
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
}

/* Stat Card */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex; gap: var(--space-4); align-items: flex-start;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.stat-label { font-size: var(--font-size-sm); color: var(--text-muted); font-weight: var(--font-weight-medium); }
.stat-value { font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); color: var(--text-main); line-height: 1.2; margin-top: 2px; }
.stat-change { font-size: var(--font-size-xs); color: var(--text-subtle); margin-top: var(--space-1); }
.stat-change.positive { color: var(--color-success-base); }
.stat-change.negative { color: var(--color-danger-base); }

/* Mission Card (Driver) */
.mission-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-right: 4px solid var(--color-driver);
}
.mission-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.mission-card.urgent { border-right-color: var(--color-danger-base); }
.mission-card.completed { border-right-color: var(--color-success-base); opacity: 0.75; }

/* ═══════════════════════════════════════════════════════════
   FORMS
════════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold);
  color: var(--text-main);
}
.form-label .required { color: var(--color-danger-base); margin-inline-start: 2px; }
.form-hint { font-size: var(--font-size-xs); color: var(--text-muted); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px var(--space-4);
  font-family: var(--font-family-fa);
  font-size: var(--font-size-base);
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  min-height: var(--touch-target-min);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  direction: rtl;
}
.input::placeholder { color: var(--text-subtle); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary-700);
  box-shadow: 0 0 0 3px rgba(21,128,61,0.12);
}
.input.error { border-color: var(--color-danger-base); background: var(--color-danger-bg); }
.input.success { border-color: var(--color-success-base); }
.input-driver {
  min-height: var(--touch-target-driver);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  text-align: center;
  letter-spacing: 0.05em;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 40px;
}
.textarea { min-height: 100px; resize: vertical; padding: var(--space-3) var(--space-4); }

.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-danger-base);
  display: flex; align-items: center; gap: var(--space-1);
  margin-top: var(--space-1);
}

/* Radio & Checkbox */
.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: var(--space-3); }
.radio-label, .checkbox-label {
  display: flex; align-items: center; gap: var(--space-3);
  cursor: pointer; font-size: var(--font-size-base);
  min-height: var(--touch-target-min);
  padding: 0 var(--space-2);
}
input[type="radio"], input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--color-primary-700); cursor: pointer; flex-shrink: 0;
}

/* Switch / Toggle */
.switch-wrapper { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch {
  position: relative; width: 48px; height: 26px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--color-neutral-300);
  border-radius: 999px;
  transition: background var(--transition-fast);
}
.switch input:checked + .switch-track { background: var(--color-primary-700); }
.switch-thumb {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}
.switch input:checked ~ .switch-thumb { transform: translateX(-22px); }

/* ═══════════════════════════════════════════════════════════
   TABLES
════════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); }
.table {
  width: 100%; border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.table thead { background: var(--bg-surface-subtle); }
.table th {
  padding: var(--space-3) var(--space-4);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-align: start;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-surface-subtle); }

/* ═══════════════════════════════════════════════════════════
   TABS
════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-family-fa);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--color-primary-700);
  border-bottom-color: var(--color-primary-700);
  font-weight: var(--font-weight-semibold);
}
.tab-panel { display: none; padding-top: var(--space-4); }
.tab-panel.active { display: block; }

/* ═══════════════════════════════════════════════════════════
   PROGRESS & STEPS
════════════════════════════════════════════════════════════ */
.progress-bar {
  height: 8px; background: var(--color-neutral-200);
  border-radius: var(--radius-full); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--color-primary-700);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.stepper { display: flex; align-items: center; gap: 0; margin-bottom: var(--space-6); }
.step {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  flex: 1; position: relative;
}
.step::after {
  content: '';
  position: absolute; top: 16px; left: 0;
  width: 100%; height: 2px;
  background: var(--border-strong);
  z-index: 0;
}
.step:last-child::after { display: none; }
.step.done::after { background: var(--color-primary-700); }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-sm); font-weight: var(--font-weight-bold);
  background: var(--bg-surface-subtle); border: 2px solid var(--border-strong);
  color: var(--text-muted); position: relative; z-index: 1;
}
.step.active .step-dot { background: var(--color-primary-700); border-color: var(--color-primary-700); color: white; }
.step.done .step-dot { background: var(--color-success-base); border-color: var(--color-success-base); color: white; }
.step-label { font-size: var(--font-size-xs); color: var(--text-muted); text-align: center; }
.step.active .step-label { color: var(--color-primary-700); font-weight: var(--font-weight-semibold); }

/* ═══════════════════════════════════════════════════════════
   ITEM WEIGHT ROW (Driver Weighing Screen)
════════════════════════════════════════════════════════════ */
.weigh-item {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: border-color var(--transition-fast);
}
.weigh-item.accepted { border-color: var(--color-success-base); background: var(--color-success-bg); }
.weigh-item.rejected { border-color: var(--color-danger-base); background: var(--color-danger-bg); opacity: 0.8; }
.weigh-item-name { font-weight: var(--font-weight-semibold); font-size: var(--font-size-base); }
.weigh-item-price { color: var(--text-muted); font-size: var(--font-size-sm); }
.weigh-item-controls { display: flex; gap: var(--space-3); align-items: center; margin-top: var(--space-3); }

/* ═══════════════════════════════════════════════════════════
   WALLET DISPLAY
════════════════════════════════════════════════════════════ */
.wallet-card {
  background: linear-gradient(135deg, var(--color-primary-800) 0%, var(--color-primary-900) 100%);
  color: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
}
.wallet-card::before {
  content: '♻';
  position: absolute; top: -20px; right: -20px;
  font-size: 100px; opacity: 0.05;
  line-height: 1;
}
.wallet-label { font-size: var(--font-size-sm); opacity: 0.7; margin-bottom: var(--space-2); }
.wallet-amount { font-size: var(--font-size-3xl); font-weight: var(--font-weight-extrabold); direction: ltr; text-align: start; }
.wallet-currency { font-size: var(--font-size-base); opacity: 0.7; margin-inline-start: var(--space-1); }
.wallet-pending { font-size: var(--font-size-sm); opacity: 0.6; margin-top: var(--space-2); }
.wallet-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }
.wallet-action-btn {
  flex: 1; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
  color: white; border-radius: var(--radius-md); padding: var(--space-3);
  font-family: var(--font-family-fa); font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold); cursor: pointer; text-align: center;
  transition: background var(--transition-fast);
}
.wallet-action-btn:hover { background: rgba(255,255,255,0.25); }

/* ═══════════════════════════════════════════════════════════
   MAP PLACEHOLDER (Vector Domestic Map Representation)
════════════════════════════════════════════════════════════ */
.map-placeholder {
  background: #e8f5e9;
  border-radius: var(--radius-md);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-sm); color: var(--color-primary-700);
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  min-height: 200px;
}
.map-placeholder::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(0deg, rgba(21,128,61,0.05) 0px, rgba(21,128,61,0.05) 1px, transparent 1px, transparent 24px),
                    repeating-linear-gradient(90deg, rgba(21,128,61,0.05) 0px, rgba(21,128,61,0.05) 1px, transparent 1px, transparent 24px);
}
.map-label { background: white; border-radius: var(--radius-sm); padding: 6px 12px; box-shadow: var(--shadow-md); z-index: 1; }
.map-pin { font-size: 2rem; position: absolute; }

/* ═══════════════════════════════════════════════════════════
   TRANSACTION LEDGER ROW
════════════════════════════════════════════════════════════ */
.ledger-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.ledger-row:hover { background: var(--bg-surface-subtle); }
.ledger-icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.ledger-desc { flex: 1; font-size: var(--font-size-sm); color: var(--text-main); }
.ledger-time { font-size: var(--font-size-xs); color: var(--text-subtle); margin-top: 2px; }
.ledger-amount { font-weight: var(--font-weight-bold); font-size: var(--font-size-base); direction: ltr; }
.ledger-amount.credit { color: var(--color-success-text); }
.ledger-amount.debit  { color: var(--color-danger-base); }

/* ═══════════════════════════════════════════════════════════
   CHIPS / TAGS
════════════════════════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-surface-subtle); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full); font-size: var(--font-size-sm);
  color: var(--text-muted); cursor: default; white-space: nowrap;
}
.chip.active { background: var(--color-primary-100); color: var(--color-primary-800); border-color: var(--color-primary-300); }
.chip.clickable { cursor: pointer; transition: all var(--transition-fast); }
.chip.clickable:hover { background: var(--bg-surface-hover); color: var(--text-main); }

/* ═══════════════════════════════════════════════════════════
   AVATAR
════════════════════════════════════════════════════════════ */
.avatar {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--color-primary-100);
  color: var(--color-primary-800); font-weight: var(--font-weight-bold);
  flex-shrink: 0; overflow: hidden;
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }
.avatar-md { width: 40px; height: 40px; font-size: var(--font-size-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--font-size-lg); }
.avatar-xl { width: 72px; height: 72px; font-size: var(--font-size-xl); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ═══════════════════════════════════════════════════════════
   DIVIDER
════════════════════════════════════════════════════════════ */
.divider { border: none; border-top: 1px solid var(--border-subtle); margin-block: var(--space-4); }
.divider-label { display: flex; align-items: center; gap: var(--space-3); color: var(--text-subtle); font-size: var(--font-size-xs); margin-block: var(--space-4); }
.divider-label::before, .divider-label::after { content: ''; flex: 1; border-top: 1px solid var(--border-subtle); }

/* ═══════════════════════════════════════════════════════════
   ALERT / NOTICE BOX
════════════════════════════════════════════════════════════ */
.alert {
  display: flex; gap: var(--space-3); padding: var(--space-4);
  border-radius: var(--radius-md); border-width: 1px; border-style: solid;
  font-size: var(--font-size-sm); line-height: var(--line-height-normal);
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.alert-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text);  border-color: var(--color-danger-border); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info-text);    border-color: var(--color-info-border); }

/* ═══════════════════════════════════════════════════════════
   PAGINATION
════════════════════════════════════════════════════════════ */
.pagination { display: flex; gap: var(--space-1); align-items: center; justify-content: center; margin-top: var(--space-4); }
.page-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-family-fa); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium);
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  cursor: pointer; color: var(--text-muted); transition: all var(--transition-fast);
}
.page-btn:hover { background: var(--bg-surface-subtle); color: var(--text-main); }
.page-btn.active { background: var(--color-primary-700); color: white; border-color: var(--color-primary-700); }

/* ═══════════════════════════════════════════════════════════
   SEARCH BAR
════════════════════════════════════════════════════════════ */
.search-bar {
  position: relative;
  display: flex; align-items: center;
}
.search-bar .search-icon {
  position: absolute; right: var(--space-3);
  color: var(--text-subtle); pointer-events: none;
  font-size: 1rem;
}
.search-bar .input { padding-right: 2.5rem; }

/* ═══════════════════════════════════════════════════════════
   DRIVER APP — Large Action Buttons
════════════════════════════════════════════════════════════ */
.driver-action-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3);
}
.driver-big-btn {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-5);
  background: var(--bg-surface); border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg); cursor: pointer;
  transition: all var(--transition-fast); min-height: 100px;
  font-family: var(--font-family-fa); font-size: var(--font-size-base); font-weight: var(--font-weight-semibold);
  color: var(--text-main);
}
.driver-big-btn:hover { border-color: var(--color-primary-700); background: var(--color-primary-50); color: var(--color-primary-800); }
.driver-big-btn .icon { font-size: 2rem; }
.driver-big-btn.danger { border-color: var(--color-danger-border); }
.driver-big-btn.danger:hover { background: var(--color-danger-bg); border-color: var(--color-danger-base); color: var(--color-danger-text); }

/* ═══════════════════════════════════════════════════════════
   NAVBAR (Mobile Bottom Navigation)
════════════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-surface); border-top: 1px solid var(--border-subtle);
  display: flex; z-index: var(--z-sticky);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: var(--space-2) 0; cursor: pointer;
  color: var(--text-subtle); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium);
  border: none; background: none; font-family: var(--font-family-fa);
  transition: color var(--transition-fast);
  min-height: var(--touch-target-min);
}
.bottom-nav-item .nav-icon { font-size: 1.3rem; }
.bottom-nav-item.active { color: var(--color-primary-700); }
.bottom-nav-item.active .nav-icon { transform: scale(1.1); }

/* ═══════════════════════════════════════════════════════════
   TOP APP BAR
════════════════════════════════════════════════════════════ */
.app-bar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: var(--z-sticky);
  min-height: 60px;
}
.app-bar-title { font-weight: var(--font-weight-semibold); font-size: var(--font-size-base); flex: 1; }
.app-bar-back { font-size: 1.3rem; cursor: pointer; padding: var(--space-2); border-radius: var(--radius-sm); background: none; border: none; color: var(--text-main); }
