/**
 * Farm Hub Driver App – mobile-first delivery UI.
 * Loaded only on driver app page. Does NOT affect admin.
 */

.farm-hub-driver-app-root {
  --fh-driver-accent: #2d6a4f;
  --fh-driver-accent-hover: #1b4332;
  --fh-driver-surface: #f6f7f7;
  --fh-driver-border: rgba(17, 17, 17, 0.12);
  --fh-driver-radius: 12px;
  --fh-driver-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 100%;
  min-height: 100vh;
  background: var(--fh-driver-surface);
}

/* Routes list */
.fh-driver-routes-list {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.fh-driver-routes-list h1 {
  margin: 0 0 20px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #111;
}

.fh-driver-route-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fff;
  border-radius: var(--fh-driver-radius);
  box-shadow: var(--fh-driver-shadow);
  border: 1px solid var(--fh-driver-border);
  flex-wrap: wrap;
}

.fh-driver-route-info {
  flex: 1;
  min-width: 0;
}

.fh-driver-route-title {
  font-weight: 600;
  font-size: 1rem;
  color: #111;
  margin: 0 0 4px;
}

.fh-driver-route-meta {
  font-size: 0.875rem;
  color: #666;
  margin: 0;
}

.fh-driver-route-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.fh-driver-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.fh-driver-btn-primary:hover {
  background: var(--fh-driver-accent-hover);
}

.fh-driver-btn-secondary {
  background: #fff;
  color: var(--fh-driver-accent);
  border: 2px solid var(--fh-driver-accent);
}

.fh-driver-btn-secondary:hover {
  background: rgba(45, 106, 79, 0.08);
}

.fh-driver-btn-ghost {
  background: transparent;
  color: #666;
}

.fh-driver-btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* View layout: addresses + map */
.fh-driver-view-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
}

@media (min-width: 768px) {
  .fh-driver-view-layout {
    flex-direction: row;
  }
}

.fh-driver-map-container {
  flex: 1;
  min-height: 300px;
  position: relative;
}

@media (min-width: 768px) {
  .fh-driver-map-container {
    min-height: 0;
  }
}

/* Full-width map on mobile – break out of container padding */
@media (max-width: 767px) {
  .farm-hub-driver-app-root {
    overflow-x: hidden;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .fh-driver-nav-layout {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
  }
  .fh-driver-map-fullwidth {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }
}

.fh-driver-addresses-panel {
  width: 100%;
  max-height: 40vh;
  overflow-y: auto;
  background: #fff;
  border-top: 1px solid var(--fh-driver-border);
  padding: 16px;
}

@media (min-width: 768px) {
  .fh-driver-addresses-panel {
    width: 320px;
    max-width: 320px;
    max-height: none;
    border-top: none;
    border-right: 1px solid var(--fh-driver-border);
  }
}

.fh-driver-addresses-panel h4 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.fh-driver-address-card {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--fh-driver-surface);
  border-radius: 8px;
  border: 1px solid var(--fh-driver-border);
}

.fh-driver-address-card.current {
  border-color: var(--fh-driver-accent);
  background: rgba(45, 106, 79, 0.06);
}

.fh-driver-address-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.fh-driver-address-text {
  font-size: 0.8rem;
  color: #666;
  margin-top: 4px;
}

/* Nav mode: current stop + map */
.fh-driver-nav-header {
  padding: 48px 16px 16px 80px;
  background: #fff;
  border-bottom: 1px solid var(--fh-driver-border);
  flex-shrink: 0;
}

.fh-driver-nav-eta {
  font-size: 0.85rem;
  color: var(--fh-driver-accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.fh-driver-nav-address {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 6px;
}

.fh-driver-nav-instruction {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 12px;
  line-height: 1.4;
}

.fh-driver-nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Delivery modal – overlay is appended to body, so it must define its own CSS variables
   (it does not inherit from .farm-hub-driver-app-root which is a sibling, not an ancestor) */
.fh-driver-modal-overlay {
  --fh-driver-accent: #2d6a4f;
  --fh-driver-accent-hover: #1b4332;
  --fh-driver-border: rgba(17, 17, 17, 0.12);
  --fh-driver-radius: 12px;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  z-index: 1000;
  padding: 0;
}

@media (min-width: 480px) {
  .fh-driver-modal-overlay {
    justify-content: center;
    padding: 24px;
  }
}

.fh-driver-modal-overlay .fh-driver-modal {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}

.fh-driver-modal-overlay .fh-driver-modal-footer-sticky {
  flex-shrink: 0;
}

@media (min-width: 480px) {
  .fh-driver-modal-overlay .fh-driver-modal {
    flex: 0 1 auto;
    margin-bottom: 0;
  }
}

.fh-driver-modal {
  background: #fff;
  border-radius: var(--fh-driver-radius) var(--fh-driver-radius) 0 0;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
}

@media (min-width: 480px) {
  .fh-driver-modal {
    border-radius: var(--fh-driver-radius);
    max-height: 85vh;
  }
}

.fh-driver-modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--fh-driver-border);
  font-weight: 600;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.fh-driver-modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.fh-driver-modal-footer,
.fh-driver-modal-footer-sticky {
  padding: 16px;
  border-top: 1px solid var(--fh-driver-border);
  flex-shrink: 0;
  background: #fff;
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
}

.fh-driver-modal-footer-sticky {
  border-radius: 0 0 var(--fh-driver-radius) var(--fh-driver-radius);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

@media (min-width: 480px) {
  .fh-driver-modal-overlay .fh-driver-modal,
  .fh-driver-modal-overlay .fh-driver-modal-footer-sticky {
    flex: 0 0 auto;
  }
}

.fh-driver-form-group {
  margin-bottom: 16px;
}

.fh-driver-form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: #333;
}

.fh-driver-form-group input,
.fh-driver-form-group textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--fh-driver-border);
  border-radius: 8px;
  box-sizing: border-box;
}

.fh-driver-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.fh-driver-pod-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 8px;
  object-fit: contain;
}

.fh-driver-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.fh-driver-modal-footer .fh-driver-btn,
.fh-driver-modal-footer-sticky .fh-driver-btn {
  margin: 0;
}

.fh-driver-btn-block {
  width: 100%;
}

.fh-driver-btn-danger {
  background: #dc2626;
  color: #fff;
}

.fh-driver-btn-danger:hover {
  background: #b91c1c;
}

/* Arrived (checkmark) and Failed (x) buttons */
.fh-driver-arrived-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fh-driver-failed-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #fff;
  border: none;
  cursor: pointer;
}

.fh-driver-failed-btn:hover {
  background: #b91c1c;
}

.fh-driver-pod-camera-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--fh-driver-accent);
  background: #fff;
  color: var(--fh-driver-accent);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
}

.fh-driver-pod-camera-btn:hover {
  background: rgba(45, 106, 79, 0.08);
}

.fh-driver-pod-camera-wrap {
  position: relative;
  display: inline-block;
}

.fh-driver-pod-input-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font-size: 0;
}

/* Loading / empty states */
.fh-driver-loading,
.fh-driver-empty {
  padding: 32px 16px;
  text-align: center;
  color: #666;
}

.fh-driver-loading p {
  margin: 12px 0 0;
}

.fh-driver-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 3px solid var(--fh-driver-border);
  border-top-color: var(--fh-driver-accent);
  border-radius: 50%;
  animation: fh-driver-spin 0.8s linear infinite;
}

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

.fh-driver-empty {
  background: #fff;
  border-radius: var(--fh-driver-radius);
  margin: 16px;
}

/* Nav overlay buttons */
.fh-driver-nav-btn {
  position: absolute !important;
  top: 12px;
  left: 12px;
  z-index: 10;
}

.fh-driver-audio-toggle {
  position: absolute !important;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.25rem;
  border-radius: 50%;
}
