/* Autopaikka Lite – Web styles */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f2f4f7;
  color: #222;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  background: #fff;
  padding: 16px 24px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.header h1 { font-size: 22px; font-weight: 700; color: #1a1a2e; }
.stats { display: flex; gap: 16px; font-size: 13px; align-items: center; }
.stat-free     { color: #2e7d32; font-weight: 600; }
.stat-reserved { color: #c62828; font-weight: 600; }
.stat-pending  { color: #1565c0; font-weight: 600; }
.stat-total    { color: #555; }

/* ── Section ─────────────────────────────────────────────────────────────── */
.section { background: #fff; margin: 16px; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-header h2 { font-size: 16px; font-weight: 600; color: #333; }
.queue-badge { background: #e3f2fd; color: #1565c0; border-radius: 12px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.btn-queue-join { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer; transition: background .15s; }
.btn-queue-join:hover { background: #c8e6c9; }
.btn-queue-view { background: #fff3e0; color: #e65100; border: 1px solid #ffb74d; border-radius: 6px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-queue-view:hover { background: #ffe0b2; }
.qview-count { font-size: 15px; color: #444; margin: 4px 0 14px; }
.qview-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.qview-entry { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #f0f0f0; font-size: 14px; color: #333; }
.qview-entry:last-child { border-bottom: none; }
.qview-pos { font-weight: 700; color: #e65100; min-width: 24px; }

/* ── Spot grid ───────────────────────────────────────────────────────────── */
.spot-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.spot {
  width: 80px;
  height: 70px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.spot small { font-size: 11px; font-weight: 400; }
.spot:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.spot:active:not(:disabled) { transform: translateY(0); }

.spot.free         { background: #43a047; }
.spot.reserved     { background: #e53935; cursor: default; }
.spot.pending-free { background: #1e88e5; }
.spot.kaksoispaikka { background: #1e88e5; }
.spot.kaksoispaikka:disabled { cursor: default; }
.spot.kaksoispaikka small { font-size: 9px; letter-spacing: -0.3px; }
.spot:disabled     { opacity: 1; }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

/* ── Modal header ────────────────────────────────────────────────────────── */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}
.modal-title-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-title-group h2 { font-size: 20px; font-weight: 700; }

.badge { border-radius: 20px; padding: 3px 12px; font-size: 13px; font-weight: 600; }
.badge-price { background: #fff3e0; color: #e65100; }
.badge-type  { background: #e3f2fd; color: #1565c0; }

.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #888; padding: 4px 8px; border-radius: 4px; }
.btn-close:hover { background: #f5f5f5; color: #333; }

/* ── Notice ──────────────────────────────────────────────────────────────── */
.notice-pending {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #e65100;
}

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-title { font-size: 14px; font-weight: 700; color: #1565c0; margin-bottom: 14px; letter-spacing: .5px; }

.form-row { display: flex; flex-direction: column; margin-bottom: 12px; }
.form-row label { font-size: 13px; color: #555; margin-bottom: 4px; }
.form-row input, .form-row select {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  color: #222;
  transition: border-color .15s;
  background: #fff;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: #1565c0; box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.form-row input::placeholder { color: #aaa; }
.form-row select { cursor: pointer; }

.rules-row { margin-top: 8px; margin-bottom: 4px; }
.rules-checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #333; cursor: pointer; }
.rules-checkbox input[type="checkbox"] { width: 18px; height: 18px; accent-color: #1a237e; cursor: pointer; }
.rules-checkbox a { color: #1565c0; text-decoration: underline; }

.form-error { color: #c62828; font-size: 13px; margin-top: 4px; padding: 8px 12px; background: #ffebee; border-radius: 6px; }
.resident-warning { color: #e65100; font-size: 13px; margin-top: 4px; padding: 8px 12px; background: #fff3e0; border-radius: 6px; }
.hidden { display: none !important; }

.form-actions { display: flex; justify-content: space-between; margin-top: 18px; gap: 12px; }
.btn-cancel  { flex: 1; padding: 10px; border: 1px solid #ccc; background: #fff; color: #555; border-radius: 8px; font-size: 15px; cursor: pointer; }
.btn-cancel:hover { background: #f5f5f5; }
.btn-confirm { flex: 2; padding: 10px; background: #1a237e; color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-confirm:hover { background: #283593; }
.btn-confirm:disabled { opacity: .6; cursor: default; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-container { text-align: center; padding: 30px 0; }
.progress-label { font-size: 16px; color: #555; margin-bottom: 20px; }
.progress-track { background: #e0e0e0; border-radius: 8px; height: 18px; overflow: hidden; margin: 0 auto 10px; max-width: 340px; }
.progress-fill  { height: 100%; background: linear-gradient(90deg, #1565c0, #42a5f5); border-radius: 8px; width: 0%; transition: width .2s; }
.progress-pct   { font-size: 22px; font-weight: 700; color: #1565c0; }

/* ── Result panels ───────────────────────────────────────────────────────── */
.result { text-align: center; padding: 30px 0; }
.result-icon { font-size: 52px; margin-bottom: 16px; }
.result h3 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.result p  { font-size: 15px; color: #555; margin-bottom: 24px; }
.result.success h3 { color: #2e7d32; }
.result.failed  h3 { color: #c62828; }
.btn-ok { padding: 11px 30px; background: #1a237e; color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
.btn-ok:hover { background: #283593; }
.failed-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.failed-actions .btn-cancel, .failed-actions .btn-confirm { flex: none; min-width: 160px; }

/* ── Coop list (home page) ───────────────────────────────────────────────── */
.coop-list { max-width: 480px; margin: 40px auto; padding: 0 16px; }
.coop-card {
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 18px 24px;
  margin-bottom: 12px;
  text-decoration: none;
  color: #1a1a2e;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition: box-shadow .15s, transform .1s;
}
.coop-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.15); transform: translateY(-2px); }
.subtitle { color: #777; font-size: 14px; margin-top: 4px; }
.empty { color: #aaa; font-size: 15px; text-align: center; margin-top: 40px; }

/* ── Action buttons (header) ──────────────────────────────────────────────── */
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-action {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: background .15s;
}
.btn-action-cancel {
  background: #fff3e0; color: #bf360c; border-color: #ffcc80;
}
.btn-action-cancel:hover { background: #ffe0b2; }
.btn-action-change {
  background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7;
}
.btn-action-change:hover { background: #c8e6c9; }
.btn-view-toggle {
  background: #f3f4f6; color: #374151; border-color: #d1d5db;
}
.btn-view-toggle:hover { background: #e5e7eb; }
.btn-view-toggle.active { background: #1e40af; color: #fff; border-color: #1e3a8a; }

/* ── Cancel / Change modal ────────────────────────────────────────────────── */
.modal-subtitle { font-size: 14px; color: #555; margin-bottom: 18px; }
.spot-select-list { max-height: 220px; overflow-y: auto; margin: 10px 0 16px; }
.spot-select-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid #e0e0e0; border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; transition: background .1s;
}
.spot-select-item:hover { background: #f5f5f5; }
.spot-select-item.selected { background: #e3f2fd; border-color: #1565c0; }
.spot-select-item input[type=radio] { accent-color: #1565c0; }
.spot-select-label { font-size: 15px; font-weight: 600; }
.spot-select-section { font-size: 12px; color: #777; }

/* ── Action pages (cancel/change standalone) ──────────────────────────────── */
.action-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.action-card {
  background: #fff; border-radius: 14px; padding: 36px 32px; max-width: 440px; width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.12); text-align: center;
}
.action-card .result-icon { font-size: 52px; margin-bottom: 16px; }
.action-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 16px; color: #1a1a2e; }
.action-info { font-size: 15px; color: #444; margin-bottom: 10px; }
.action-warning { font-size: 13px; color: #c62828; background: #ffebee; padding: 10px 14px; border-radius: 6px; margin: 16px 0; }
.info-table { width: 100%; text-align: left; border-collapse: collapse; margin-bottom: 16px; }
.info-table td { padding: 7px 10px; font-size: 14px; border-bottom: 1px solid #f0f0f0; }
.info-table td:first-child { color: #777; width: 40%; }
.btn-danger {
  width: 100%; padding: 13px; background: #c62828; color: #fff; border: none;
  border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-danger:hover { background: #b71c1c; }
.btn-confirm-action {
  width: 100%; padding: 13px; background: #1a237e; color: #fff; border: none;
  border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-confirm-action:hover { background: #283593; }

/* ── Verify phase ────────────────────────────────────────────────────────── */
.verify-container { text-align: center; padding: 24px 0; }
.verify-icon { font-size: 52px; margin-bottom: 12px; }
.verify-container h3 { font-size: 20px; font-weight: 700; color: #1565c0; margin-bottom: 8px; }
.verify-desc { font-size: 14px; color: #555; margin-bottom: 4px; }
.verify-email { font-size: 16px; font-weight: 600; color: #1a237e; margin: 8px 0 16px; }
.verify-countdown-track { background: #e0e0e0; border-radius: 8px; height: 12px; overflow: hidden; margin: 16px auto 8px; max-width: 300px; }
.verify-countdown-fill { height: 100%; background: linear-gradient(90deg, #1565c0, #42a5f5); border-radius: 8px; width: 100%; transition: width 1s linear; }
.verify-countdown-text { font-size: 28px; font-weight: 700; color: #1565c0; display: block; margin: 8px 0 20px; }
.verify-cancel-btn { display: inline-block; margin-top: 8px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .spot { width: 65px; height: 60px; font-size: 13px; }
  .header { padding: 12px 16px; }
  .section { margin: 10px; padding: 14px; }
  .modal { padding: 18px; }
  .stats { gap: 10px; font-size: 12px; }
}
