/* ActiveBike Dashboard — Styles */

:root {
  --bg-primary: #2d2d2d;
  --bg-card: #1a1a1a;
  --bg-input: #2d2d2d;
  --accent-red: #d41920;
  --accent-red-hover: #b01518;
  --accent-green: #2ecc71;
  --accent-green-dim: rgba(46, 204, 113, 0.15);
  --accent-amber: #f39c12;
  --accent-amber-dim: rgba(243, 156, 18, 0.15);
  --accent-red-dim: rgba(212, 25, 32, 0.15);
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(212, 25, 32, 0.6);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-modal: 0 -4px 32px rgba(0, 0, 0, 0.6);
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── Top Bar ─── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--accent-red);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.topbar-brand span {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.topbar-clock {
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.staff-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  min-width: 120px;
}

.staff-select:focus {
  border-color: var(--border-focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-confirm {
  background: var(--accent-amber) !important;
  animation: confirmPulse 1s ease-in-out infinite;
}

@keyframes confirmPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-red);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-red-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn-ghost {
  background: none;
  color: var(--accent-red);
  padding: 8px 12px;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(212, 25, 32, 0.1);
}

/* ─── Offline Banner ─── */

.offline-banner {
  display: none;
  background: var(--accent-amber);
  color: #000;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  position: fixed;
  top: 68px;
  left: 0;
  right: 0;
  z-index: 99;
}

.offline-banner.show {
  display: block;
}

/* ─── Stats Row ─── */

.stats-row {
  display: flex;
  gap: 12px;
  padding: 16px 20px 8px;
  margin-top: 66px;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
  border: 2px solid transparent;
}

.stat-card:active {
  transform: scale(0.97);
}

.stat-card.stat-active {
  border-color: rgba(255, 255, 255, 0.3);
}

.stat-card.stat-dimmed {
  opacity: 0.4;
}

.stat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-dot.green { background: var(--accent-green); }
.stat-dot.red { background: var(--accent-red); }
.stat-dot.amber { background: var(--accent-amber); }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-count {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ─── Bike Grid ─── */

.grid-container {
  padding: 12px 20px 20px;
  overflow-y: auto;
  height: calc(100vh - 66px - 76px);
}

.bike-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
}

.bike-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: var(--shadow-card);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  -webkit-user-select: none;
  user-select: none;
}

.bike-card:active {
  transform: scale(0.97);
}

.bike-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.bike-card[data-status="Available"]::before { background: var(--accent-green); }
.bike-card[data-status="Rented"]::before { background: var(--accent-red); }
.bike-card[data-status="Needs Service"]::before { background: var(--accent-amber); }

.bike-card[data-status="Available"] { border: 1px solid rgba(46, 204, 113, 0.2); }
.bike-card[data-status="Rented"] { border: 1px solid rgba(212, 25, 32, 0.2); }
.bike-card[data-status="Needs Service"] { border: 1px solid rgba(243, 156, 18, 0.2); }

.bike-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.bike-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.bike-rate {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.bike-model {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.bike-status-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  align-self: flex-start;
}

.bike-card[data-status="Available"] .bike-status-badge {
  color: var(--accent-green);
  background: var(--accent-green-dim);
}

.bike-card[data-status="Rented"] .bike-status-badge {
  color: var(--accent-red);
  background: var(--accent-red-dim);
}

.bike-card[data-status="Needs Service"] .bike-status-badge {
  color: var(--accent-amber);
  background: var(--accent-amber-dim);
}

/* Rented card extra info */
.bike-rented-info {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bike-rented-info .customer-name {
  color: var(--text-primary);
  font-weight: 500;
}

.bike-rented-info .elapsed-time {
  font-variant-numeric: tabular-nums;
  color: var(--accent-red);
  font-weight: 600;
}

/* ─── Modal Overlay ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.show {
  display: flex;
}

.modal-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px 28px 36px;
  box-shadow: var(--shadow-modal);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-bike-info {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.modal-bike-number {
  font-size: 28px;
  font-weight: 700;
}

.modal-bike-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-bike-details span {
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-bike-details .rate {
  color: var(--accent-red);
  font-weight: 600;
}

/* Modal sections */
.modal-section {
  margin-bottom: 20px;
}

.modal-section-title {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* Input fields in modals */
.modal-input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 16px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

.modal-input:focus {
  border-color: var(--border-focus);
}

.modal-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Customer result card */
.customer-result {
  padding: 14px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  display: none;
}

.customer-result.show {
  display: block;
}

.customer-result .customer-name-display {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.customer-result .customer-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customer-not-found {
  color: var(--accent-amber);
  font-size: 14px;
  margin-top: 12px;
  display: none;
}

.customer-not-found.show {
  display: block;
}

/* Phone autocomplete dropdown */
.phone-autocomplete {
  position: relative;
}

.autocomplete-list {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 10;
  display: none;
}

.autocomplete-list.show {
  display: block;
}

.autocomplete-item {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 50px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.autocomplete-item .ac-name {
  font-size: 14px;
  font-weight: 500;
}

.autocomplete-item .ac-phone {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Return modal specifics */
.return-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.return-summary-item {
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

.return-summary-item .label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.return-summary-item .value {
  font-size: 18px;
  font-weight: 700;
}

.return-summary-item .value.amount {
  color: var(--accent-green);
}

.return-summary-item .value.time {
  font-variant-numeric: tabular-nums;
}

/* Payment method buttons */
.payment-methods {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.payment-btn {
  flex: 1;
  padding: 14px;
  background: var(--bg-primary);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.payment-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.payment-btn.selected {
  border-color: var(--accent-red);
  background: var(--accent-red-dim);
}

/* Condition select */
.condition-select {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}

.condition-select:focus {
  border-color: var(--border-focus);
}

/* ─── Toast ─── */

.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.25s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }

@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(40px); opacity: 0; }
}

/* ─── Loading ─── */

.spinner-inline {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

.grid-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-secondary);
  font-size: 14px;
  gap: 10px;
}

.grid-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-secondary);
  font-size: 14px;
  gap: 10px;
  text-align: center;
}

.grid-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--text-muted);
  font-size: 14px;
  grid-column: 1 / -1;
}

/* ─── Textarea ─── */

textarea.modal-input {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

/* ─── Scrollbar ─── */

.grid-container::-webkit-scrollbar {
  width: 6px;
}

.grid-container::-webkit-scrollbar-track {
  background: transparent;
}

.grid-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.modal-panel::-webkit-scrollbar {
  width: 4px;
}

.modal-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ─── Customer Lookup Modal ─── */

.rental-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.rental-history-item {
  padding: 10px 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 13px;
}

.rental-history-item .rh-label {
  color: var(--text-secondary);
}

.rental-history-item .rh-value {
  text-align: right;
  font-weight: 500;
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .topbar-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .stats-row {
    padding: 12px 16px 8px;
    margin-top: 110px;
    gap: 8px;
  }

  .stat-card {
    padding: 10px 12px;
  }

  .stat-count {
    font-size: 18px;
  }

  .grid-container {
    padding: 10px 16px 16px;
    height: calc(100vh - 110px - 64px);
  }

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

  .bike-card {
    padding: 12px;
    min-height: 100px;
  }

  .bike-number {
    font-size: 18px;
  }

  .modal-panel {
    padding: 28px 24px 32px;
    max-height: 75vh;
  }
}

@media (max-width: 480px) {
  .stats-row {
    flex-direction: column;
  }

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

  .return-summary {
    grid-template-columns: 1fr;
  }
}

/* ─── Needs Service Modal ─── */

.service-notes {
  padding: 14px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.service-notes.empty {
  font-style: italic;
  color: var(--text-muted);
}
