/* ═══ DASH-EMS App Styles ═══ */
:root {
  --blue: #1B3A5C;
  --accent: #2E86C1;
  --accent-light: #85C1E9;
  --dark: #1C1C1C;
  --white: #FFFFFF;
  --grey: #7F8C8D;
  --light: #F4F6F8;
  --border: #E0E5EA;
  --green: #27AE60;
  --orange: #E67E22;
  --red: #C0392B;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--light);
  color: var(--dark);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ─── TOP BAR ─── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px;
  background: var(--blue);
  color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#topbar h1 { font-size: 18px; font-weight: 600; }
.icon-btn {
  background: none; border: none; color: var(--white);
  font-size: 22px; padding: 8px 12px; cursor: pointer;
  border-radius: 8px;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }

/* ─── SIDE MENU ─── */
#menu-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
}
#side-menu {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 300;
  background: var(--white);
  box-shadow: 4px 0 16px rgba(0,0,0,0.1);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
#side-menu.open { transform: translateX(0); }
.menu-header {
  background: var(--blue); color: var(--white);
  padding: 32px 20px 20px;
}
.menu-logo { font-size: 22px; font-weight: 700; }
.menu-sub { font-size: 13px; opacity: 0.7; margin-top: 4px; }
#side-menu a {
  display: block; padding: 14px 20px; font-size: 15px;
  color: var(--dark); text-decoration: none; cursor: pointer;
  transition: background 0.15s;
}
#side-menu a:active { background: var(--light); }
.menu-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ─── PAGES ─── */
main { padding-top: 56px; min-height: 100vh; }
.page { display: none; padding: 16px; max-width: 600px; margin: 0 auto; }
.page.active { display: block; }

/* ─── DASHBOARD ─── */
.dash-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-card.accent { background: var(--accent); color: var(--white); }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--grey); margin-top: 4px; }
.stat-card.accent .stat-label { color: rgba(255,255,255,0.8); }

.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }

/* ─── CARDS ─── */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform 0.1s;
}
.card:active { transform: scale(0.98); }
.card-title { font-weight: 600; font-size: 15px; }
.card-sub { font-size: 13px; color: var(--grey); margin-top: 4px; }
.card-badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; margin-top: 6px;
}
.badge-ok { background: #D5F5E3; color: var(--green); }
.badge-action { background: #FDEBD0; color: var(--orange); }
.badge-exceed { background: #FADBD8; color: var(--red); }
.badge-draft { background: #E8ECEF; color: var(--grey); }
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--grey); font-size: 14px;
}

/* ─── BUTTONS ─── */
.btn-primary {
  background: var(--accent); color: var(--white); border: none;
  padding: 10px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.btn-primary:active { background: #2471A3; }
.btn-primary:disabled { background: #BDC3C7; cursor: not-allowed; }
.btn-outline {
  background: none; color: var(--accent); border: 2px solid var(--accent);
  padding: 10px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer;
}
.btn-outline:active { background: rgba(46,134,193,0.1); }
.btn-danger {
  background: var(--red); color: var(--white); border: none;
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.btn-small {
  padding: 6px 12px; font-size: 12px;
}

/* ─── FORMS ─── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--grey); margin-bottom: 5px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 2px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit;
  background: var(--white); transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #CCC; border-radius: 26px;
  cursor: pointer; transition: background 0.2s;
}
.slider::before {
  content: ''; position: absolute; width: 20px; height: 20px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(22px); }

/* ─── WIZARD ─── */
.wizard-progress { margin-bottom: 20px; }
.progress-steps {
  display: flex; justify-content: space-between;
  margin-bottom: 8px;
}
.step {
  font-size: 11px; font-weight: 600; color: var(--grey);
  padding: 4px 0; position: relative;
}
.step.active { color: var(--accent); }
.step.done { color: var(--green); }
.progress-bar {
  height: 4px; background: var(--border); border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 4px;
  transition: width 0.3s ease;
}
.wizard-step { display: none; }
.wizard-step.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.wizard-nav {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 24px; padding: 16px 0 32px;
}
.wizard-nav .btn-primary { flex: 1; }
.wizard-nav .btn-outline { flex: 1; }

/* ─── MEASUREMENT CARD ─── */
.measurement-card {
  background: var(--white); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow); border-left: 4px solid var(--border);
}
.measurement-card.ok { border-left-color: var(--green); }
.measurement-card.action { border-left-color: var(--orange); }
.measurement-card.exceed { border-left-color: var(--red); }
.measurement-card .mc-header {
  display: flex; justify-content: space-between; align-items: center;
}
.measurement-card .mc-area { font-weight: 600; font-size: 15px; }
.measurement-card .mc-reading {
  font-size: 20px; font-weight: 700;
  padding: 2px 10px; border-radius: 6px;
}
.mc-reading.ok { background: #D5F5E3; color: var(--green); }
.mc-reading.action { background: #FDEBD0; color: var(--orange); }
.mc-reading.exceed { background: #FADBD8; color: var(--red); }
.measurement-card .mc-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin-top: 8px; font-size: 13px; color: var(--grey);
}
.measurement-card .mc-actions {
  display: flex; gap: 8px; margin-top: 8px;
}

/* ─── EQUIPMENT CARD ─── */
.equip-card {
  background: var(--white); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
}
.equip-card .eq-info { flex: 1; }
.equip-card .eq-type { font-weight: 600; font-size: 14px; }
.equip-card .eq-detail { font-size: 13px; color: var(--grey); margin-top: 2px; }

/* ─── PHOTO UPLOAD ─── */
.photo-upload {
  position: relative; border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 30px;
  text-align: center; cursor: pointer;
  transition: border-color 0.15s;
}
.photo-upload:active { border-color: var(--accent); }
.photo-upload input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-placeholder { color: var(--grey); font-size: 14px; }
.photo-upload img {
  max-width: 100%; max-height: 200px; border-radius: 6px;
}

.photo-card {
  background: var(--white); border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px; box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center;
}
.photo-card img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; }
.photo-card .pc-info { flex: 1; }

/* ─── REVIEW ─── */
.review-section {
  background: var(--white); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.review-section h3 {
  font-size: 14px; color: var(--accent); margin-bottom: 8px;
}
.review-row {
  display: flex; justify-content: space-between;
  font-size: 14px; padding: 4px 0;
}
.review-row .label { color: var(--grey); }
.review-row .value { font-weight: 600; }

/* ─── INFO BOX ─── */
.info-box {
  background: #E8F4FD; border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0; padding: 12px 14px;
  font-size: 13px; color: var(--blue);
}

/* ─── SURVEY TYPE BUTTONS ─── */
.survey-type-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; background: var(--white);
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; text-align: left; font-size: 15px;
  transition: all 0.2s;
}
.survey-type-btn:active { border-color: var(--accent); background: var(--light); }
.survey-type-btn.disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── ADDRESS SUGGESTIONS ─── */
.suggestions-list {
  background: var(--white); border: 2px solid var(--accent); border-top: none;
  border-radius: 0 0 8px 8px; max-height: 200px; overflow-y: auto;
}
.suggestions-list .suggestion {
  padding: 10px 12px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.suggestions-list .suggestion:active { background: var(--light); }

/* ─── MEASUREMENT AREA CARD ─── */
.area-card {
  background: var(--white); border-radius: var(--radius);
  margin-bottom: 12px; box-shadow: var(--shadow);
  border-left: 4px solid var(--border); overflow: hidden;
}
.area-card.ok { border-left-color: var(--green); }
.area-card.action { border-left-color: var(--orange); }
.area-card.exceed { border-left-color: var(--red); }
.area-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--light);
}
.area-header input {
  border: none; font-weight: 600; font-size: 15px;
  background: transparent; width: 55%;
}
.area-avg {
  font-size: 18px; font-weight: 700; padding: 2px 10px; border-radius: 6px;
}
.area-avg.ok { background: #D5F5E3; color: var(--green); }
.area-avg.action { background: #FDEBD0; color: var(--orange); }
.area-avg.exceed { background: #FADBD8; color: var(--red); }
.area-avg.none { background: var(--light); color: var(--grey); }
.area-readings { padding: 8px 14px; }
.reading-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; font-size: 14px;
}
.reading-row input[type="number"] {
  width: 90px; padding: 6px 8px; border: 2px solid var(--border);
  border-radius: 6px; font-size: 14px; text-align: center;
}
.reading-row .reading-num { color: var(--grey); font-size: 12px; width: 20px; }
.reading-row .reading-del { color: var(--red); cursor: pointer; font-size: 16px; padding: 4px; }
.area-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px; border-top: 1px solid var(--border);
}
.area-footer label { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.area-add-reading {
  color: var(--accent); font-size: 13px; font-weight: 600;
  cursor: pointer; background: none; border: none;
}

/* ─── TOAST ─── */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--dark); color: var(--white);
  padding: 12px 24px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 999; transition: opacity 0.3s;
}
#toast.hidden { opacity: 0; pointer-events: none; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--white); border-radius: 12px;
  padding: 24px; max-width: 400px; width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal h3 { margin-bottom: 16px; }
.modal-actions {
  display: flex; gap: 10px; margin-top: 20px;
  justify-content: flex-end;
}

.hidden { display: none !important; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
