/* =====================================================
   PaceCraft – style.css
   Warna utama: #FC4C02 (orange Strava/running)
   ===================================================== */

/* ---------- CUSTOM PROPERTIES ---------- */
:root {
  --orange: #FC4C02;
  --orange-light: #FFF0EB;
  --orange-dark: #d93e00;

  --bg: #F5F5F5;
  --bg-card: #FFFFFF;
  --bg-card2: #FAFAFA;
  --border: #E8E8E8;
  --border-focus: #FC4C02;

  --text: #1A1A1A;
  --text-muted: #6B7280;
  --text-hint: #9CA3AF;

  --input-bg: #FFFFFF;
  --input-border: #D1D5DB;

  --shadow: 0 1px 4px rgba(0,0,0,.07), 0 2px 12px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);

  --map-bg: #E8EAE8;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-card: #1E1E1E;
  --bg-card2: #252525;
  --border: #2E2E2E;

  --text: #F0F0F0;
  --text-muted: #9CA3AF;
  --text-hint: #6B7280;

  --input-bg: #2A2A2A;
  --input-border: #3A3A3A;

  --shadow: 0 1px 4px rgba(0,0,0,.3), 0 2px 12px rgba(0,0,0,.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);

  --map-bg: #2A2D2A;
  --orange-light: #2A1500;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  color-scheme: light;
  scroll-behavior: smooth;
}
[data-theme="dark"] html, html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- HEADER ---------- */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.logo-sep {
  color: var(--border);
  font-weight: 300;
}
.logo-sub {
  font-size: .85rem;
  color: var(--text-muted);
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ---------- LAYOUT ---------- */
.main-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .main-layout { grid-template-columns: 1fr; }
  .col-right { order: -1; }
}

/* ---------- CARDS ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 0;
}

.card + .card, .col-left .card + .card, .col-right .card + .card {
  /* handled by gap in col flex */
}

.col-left, .col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--orange);
}
.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ---------- DROP ZONE ---------- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg-card2);
  margin-bottom: 12px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--orange);
  background: var(--orange-light);
}
.drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
  color: var(--text-muted);
}
.drop-title { font-weight: 600; font-size: 1rem; color: var(--text); }
.drop-sub { font-size: .85rem; }

.gpx-info {
  background: var(--orange-light);
  border: 1px solid rgba(252,76,2,.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 4px;
}
.gpx-file-row {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
  margin-bottom: 8px;
}
.gpx-file-name {
  display: flex; align-items: center; gap: 6px;
  font-size: .9rem; font-weight: 500; color: var(--text);
}
.gpx-status { display: flex; align-items: center; gap: 10px; }
.badge { padding: 2px 8px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-ok { background: #DCFCE7; color: #16A34A; }
[data-theme="dark"] .badge-ok { background: #14532D; color: #86EFAC; }
.gpx-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--text-muted); }

/* ---------- FORM ---------- */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(252,76,2,.12);
}
textarea { resize: vertical; min-height: 56px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-col { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }
}

.input-icon-wrap { position: relative; }
.input-icon {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--text-hint);
}
.input-icon-wrap input { padding-right: 36px; }

.input-time-wrap { display: flex; align-items: center; gap: 8px; }
.input-time-wrap .input-icon-wrap { flex: 1; }
.tz-badge {
  background: var(--orange);
  color: white;
  font-size: .75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.input-unit-wrap { display: flex; align-items: center; gap: 0; }
.input-unit-wrap input { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
.unit {
  background: var(--bg-card2);
  border: 1px solid var(--input-border);
  border-left: none;
  padding: 9px 10px;
  font-size: .82rem;
  color: var(--text-muted);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  white-space: nowrap;
}

.form-hint { font-size: .78rem; color: var(--text-hint); margin-top: 4px; }

/* ---------- DEVICE SELECTOR ---------- */
.device-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.device-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .15s;
  background: var(--bg-card2);
}
.device-option input[type="radio"] { display: none; }
.device-option.active, .device-option:has(input:checked) {
  border-color: var(--orange);
  background: var(--orange-light);
  color: var(--orange);
}
.device-option:hover { border-color: var(--orange); }

/* ---------- PACE INPUT ---------- */
.pace-input-row { display: flex; align-items: center; gap: 10px; }
.pace-input-box {
  display: flex; align-items: center; gap: 2px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--input-bg);
}
.pace-input-box:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(252,76,2,.12);
}
.pace-num {
  width: 56px !important;
  border: none !important;
  border-radius: 0 !important;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: none !important;
  padding: 9px 4px !important;
}
.pace-num:focus { outline: none; box-shadow: none !important; }
.pace-sep { font-size: 1.2rem; font-weight: 700; color: var(--text-muted); padding: 0 2px; }
.pace-unit { font-size: .9rem; color: var(--text-muted); font-weight: 500; }

/* ---------- SLIDER ---------- */
.slider-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slider-val { font-weight: 700; color: var(--orange); font-size: .9rem; }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--orange) 0%, var(--orange) 27%, var(--border) 27%, var(--border) 100%);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 1px 4px rgba(252,76,2,.4);
  border: 3px solid white;
  cursor: pointer;
  transition: transform .1s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--orange);
  border: 3px solid white;
  cursor: pointer;
}

.slider-hint { font-size: .78rem; color: var(--text-hint); margin-top: 4px; }
.slider-hint-row {
  display: flex; justify-content: space-between;
  font-size: .75rem; color: var(--text-hint);
  margin-top: 4px;
}

/* ---------- LINK BUTTON ---------- */
.btn-link {
  background: none; border: none;
  color: var(--orange); cursor: pointer;
  font-size: .85rem; font-weight: 600;
  text-decoration: none;
  display: flex; align-items: center; gap: 4px;
}
.btn-link:hover { opacity: .75; }

/* ---------- MAP ---------- */
.map-container {
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 100px;
}
.map-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  min-height: 200px;
  color: var(--text-muted);
  font-size: .9rem;
  background: var(--bg-card2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
}

/* ---------- SUMMARY ---------- */
.summary-empty {
  color: var(--text-muted);
  font-size: .9rem;
  padding: 8px 0;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.summary-stat {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.stat-icon { font-size: 1.2rem; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.summary-row-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.sum-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.sum-row:last-child { border-bottom: none; }
.sum-val { font-weight: 600; color: var(--text); }

.split-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--orange-light);
  border: 1px solid rgba(252,76,2,.25);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: .85rem;
  color: var(--orange);
  font-weight: 600;
  margin-bottom: 16px;
}
.split-badge span:last-child { font-weight: 400; color: var(--text-muted); }

/* ---------- CHARTS ---------- */
.chart-section { margin-bottom: 16px; }
.chart-label { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

/* ---------- SPLIT TABLE ---------- */
.split-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 6px;
  -webkit-overflow-scrolling: touch;
}
.split-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.split-table th {
  background: var(--bg-card2);
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.split-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.split-table tbody tr:last-child td { border-bottom: none; }
.split-table tbody tr:hover { background: var(--bg-card2); }

/* ---------- ACTION CARD ---------- */
.action-card { display: flex; flex-direction: column; gap: 10px; }
.action-hint { font-size: .78rem; color: var(--text-hint); text-align: center; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 11px;
  background: transparent;
  color: var(--orange);
  border: 2px solid var(--orange);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-secondary:hover:not(:disabled) { background: var(--orange-light); }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- VALIDATION ---------- */
.validation-msg {
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: .82rem;
  margin-top: 8px;
}
.validation-msg.error { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
[data-theme="dark"] .validation-msg.error { background: #2D1515; color: #F87171; border-color: #7F1D1D; }
.validation-msg.warn { background: #FFFBEB; color: #D97706; border: 1px solid #FDE68A; }
[data-theme="dark"] .validation-msg.warn { background: #1C1600; color: #FCD34D; border-color: #78350F; }

/* ---------- LEAFLET OVERRIDES ---------- */
.leaflet-container { font-family: inherit; }
[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.8) invert(1) contrast(1.2) hue-rotate(200deg) saturate(.4) brightness(.7) invert(1); }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* ---------- FOCUS VISIBLE ---------- */
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ---------- SELECTION ---------- */
::selection { background: rgba(252,76,2,.2); }

/* ---------- PRINT ---------- */
@media print {
  .header { position: static; }
  .btn-primary, .btn-secondary, .btn-icon { display: none; }
}
