/* ==============================
   Hotelia Pasaport — Style v2 (bitti'den)
   ============================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

:root {
  --primary: #4B2EA8;
  --primary-dark: #3a2285;
  --primary-light: #7B5CE5;
  --accent: #F59E0B;
  --success: #059669;
  --success-bg: #ECFDF5;
  --success-border: #6EE7B7;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --bg: #F0EEF8;
  --surface: #FFFFFF;
  --surface2: #F8F7FC;
  --border: #E4E1F5;
  --text: #1A1636;
  --text-muted: #6B6A8A;
  --text-light: #9B99B5;
  --shadow: 0 1px 3px rgba(75,46,168,0.08), 0 4px 16px rgba(75,46,168,0.06);
  --shadow-lg: 0 8px 32px rgba(75,46,168,0.15);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.screen { min-height: 100vh; }
.screen.hidden { display: none !important; }
.hidden { display: none !important; }

/* ======================== LOGIN ======================== */
#screen-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(160deg, #3a2285 0%, #6B3FA0 50%, #4B2EA8 100%);
}

.login-hero, .login-logo { margin-bottom: 28px; text-align: center; }
.login-hero .login-logo {
  width: 88px; height: 88px; border-radius: 18px;
  background: rgba(255,255,255,0.12); padding: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  object-fit: contain; display: block; margin: 0 auto 12px;
}
.login-title { font-size: 1.45rem; font-weight: 700; color: #fff; letter-spacing: -0.3px; margin: 0 0 4px; }
.login-subtitle { font-size: 13px; color: rgba(255,255,255,0.6); margin: 0; }

#form-login {
  background: #fff;
  border-radius: 20px;
  padding: 26px 22px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.form-group { margin-bottom: 14px; }
.form-group-checkbox label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; }
.form-group-checkbox input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

.form-group label {
  display: block;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 5px;
}

.form-group input {
  width: 100%; padding: 12px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--surface2);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-group input:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(75,46,168,0.12);
}

.form-group input::placeholder { color: var(--text-light); }

.login-proxy-toggle { margin-top: 8px; }
#login-msg { font-size: 13px; color: var(--danger); text-align: center; margin-top: 8px; min-height: 18px; }

/* ======================== BUTTONS ======================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  font-family: var(--font); font-size: 15px; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  -webkit-appearance: none;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--primary); color: #fff;
  width: 100%; padding: 15px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(75,46,168,0.35);
  margin-top: 6px;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  padding: 9px 14px; font-size: 14px; font-weight: 500; border: none;
}

.btn-ghost:hover { color: var(--text); background: rgba(0,0,0,0.05); }

/* ======================== RACK ======================== */
#screen-rack { padding: 0; background: var(--bg); }

.rack-header {
  background: var(--primary);
  padding: 16px 20px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}

.rack-header h1 { font-size: 1.1rem; font-weight: 700; color: #fff; }

.rack-header-actions { display: flex; align-items: center; gap: 8px; }

.btn-header-icon {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  border: none; border-radius: 8px;
  padding: 8px 12px; font-size: 15px;
  cursor: pointer; transition: background 0.15s;
  font-family: var(--font); font-weight: 600;
}

.btn-header-icon:hover { background: rgba(255,255,255,0.25); }

#screen-room-choice { padding: 0; background: var(--bg); }
.room-choice-body { padding: 24px 20px; }
.room-choice-hint { margin-bottom: 20px; color: var(--text-muted); font-size: 14px; }
.room-choice-body .btn { display: block; width: 100%; margin-bottom: 12px; }
.room-choice-body .btn:last-of-type { margin-bottom: 0; }
.room-choice-edit-list { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.room-choice-edit-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.btn-room-choice-visitor {
  display: block; width: 100%;
  padding: 14px 16px; margin-bottom: 8px;
  font-family: var(--font); font-size: 15px; font-weight: 500;
  text-align: left; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
}
.btn-room-choice-visitor:hover { background: var(--border); }

.rack-legend {
  display: flex; gap: 16px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
}

.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-dot.empty { background: #10B981; }
.legend-dot.full { background: #3B82F6; }

.rack-body { padding: 14px; }
.rack-hint { font-size: 13px; color: var(--text-muted); padding: 8px 20px; margin: 0; }

.rack-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 0; color: var(--text-muted); font-size: 14px;
  gap: 12px;
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-bottom: 12px;
}

.rack-error {
  background: var(--danger-bg);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--danger);
  margin: 0 14px 12px;
}

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

.room-btn {
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  font-family: var(--font); font-size: 1rem; font-weight: 700;
  border-radius: 12px; border: 2px solid transparent;
  cursor: pointer; transition: all 0.15s ease;
  box-shadow: var(--shadow);
}

.room-btn:active { transform: scale(0.92); }

.room-btn .room-num { font-size: 1rem; line-height: 1; }
.room-btn .room-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
.room-btn .room-count {
  font-size: 0.7rem; font-weight: 600;
  opacity: 0.85;
}

.room-btn.room-empty {
  border-color: #A7F3D0;
  background: linear-gradient(145deg, #ECFDF5, #D1FAE5);
  color: #065F46;
}

.room-btn.room-full {
  border-color: #BFDBFE;
  background: linear-gradient(145deg, #EFF6FF, #DBEAFE);
  color: #1E40AF;
}

.room-btn.room-empty .room-status-dot { background: #10B981; }
.room-btn.room-full .room-status-dot { background: #3B82F6; }

#screen-room-selected { padding: 0; background: var(--bg); }

/* room-selected */
.room-selected-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.room-selected-room { font-size: 1.25rem; font-weight: 700; color: var(--primary); margin: 0 0 20px; }
.room-selected-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 20px; }

/* ======================== SCAN ======================== */
#screen-scan {
  background: #0A0916;
  color: #fff;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.scan-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.scan-room-badge {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  padding: 6px 14px;
  border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.15);
}

.btn-ghost.scan-cancel {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 8px 14px;
}

.scan-instruction {
  font-size: 12px; color: rgba(255,255,255,0.5);
  text-align: center; padding: 6px 20px 10px;
  line-height: 1.5;
}

.video-wrap {
  position: relative;
  width: 100%; background: #000;
  overflow: hidden;
  flex-shrink: 0;
  max-height: 55vh;
}

#video { width: 100%; height: 100%; object-fit: cover; display: block; }
#canvas { display: none; }

.mrz-frame-overlay {
  position: absolute; left: 8%; right: 8%; bottom: 8%;
  height: 22%;
  border: 2px solid rgba(123, 92, 229, 0.8);
  border-radius: 6px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.25);
}

.mrz-corner {
  position: absolute;
  width: 18px; height: 18px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}

.mrz-corner-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.mrz-corner-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.mrz-corner-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.mrz-corner-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

.mrz-reader-block {
  margin: 12px 16px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,0.2);
}
.mrz-reader-label { font-size: 12px; color: rgba(255,255,255,0.6); margin: 0 0 6px; }
.input-mrz-reader {
  width: 100%; padding: 10px 12px;
  font-size: 14px; font-family: var(--font-mono);
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
}
.input-mrz-reader::placeholder { color: rgba(255,255,255,0.5); }

.scan-actions { display: flex; gap: 10px; padding: 14px 16px; }
.scan-actions-split { display: flex; gap: 10px; flex: 1; }
.scan-actions-split .btn { flex: 1; }

.btn-scan-primary {
  flex: 1;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 15px;
  font-family: var(--font); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all 0.18s;
  box-shadow: 0 4px 16px rgba(75,46,168,0.45);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.btn-scan-primary:active { transform: scale(0.97); }
.btn-scan-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-scan-gallery {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

.btn-scan-gallery:hover { background: rgba(255,255,255,0.14); }
.btn-icon { font-size: 18px; line-height: 1; }

.scan-status {
  font-size: 13px; color: rgba(255,255,255,0.5);
  text-align: center; padding: 0 16px 14px;
}

.msg { margin: 12px 0; font-size: 14px; }
.msg.error { color: var(--danger); }

.input-file-hidden { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

/* ======================== CONFIRM ======================== */
#screen-confirm { background: var(--bg); }

.confirm-header {
  background: var(--primary);
  padding: 16px 20px 18px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between;
}

.confirm-header .btn-ghost {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
}

.confirm-card {
  background: #fff;
  border-radius: var(--radius);
  margin: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.confirm-scan-block {
  margin-bottom: 20px; padding: 16px;
  background: #0A0916;
  border-radius: var(--radius-sm);
  color: #fff;
}
.confirm-scan-title { font-size: 1rem; margin: 0 0 6px; color: #fff; }
.confirm-scan-hint { font-size: 13px; color: rgba(255,255,255,0.6); margin: 0 0 10px; }
.confirm-video-wrap { max-height: 200px; }

.confirm-title { font-size: 1.05rem; margin: 0 0 12px; font-weight: 700; color: var(--text); }

.confirm-read-summary {
  font-size: 14px; line-height: 1.5; color: var(--text);
  margin: 0 0 12px; padding: 12px 14px;
  background: var(--success-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--success-border);
}

.confirm-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }

.confirm-card label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px; margin-top: 12px;
}
.confirm-card label:first-of-type { margin-top: 0; }

.confirm-card input, .confirm-card select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--surface2);
  -webkit-appearance: none; appearance: none;
}

.confirm-card select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B6A8A' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.confirm-card input:focus, .confirm-card select:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(75,46,168,0.1);
}

.field-hint { font-size: 10.5px; color: var(--text-light); margin-top: 3px; }

#btn-save-to-room {
  width: 100%; margin-top: 20px; padding: 16px;
  font-size: 16px; font-weight: 700;
}

/* ======================== RESULT ======================== */
#screen-result {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 28px 20px;
  background: var(--bg);
}

.result-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  width: 100%;
  animation: fadeIn 0.35s ease;
}

.result-text { font-size: 1rem; color: var(--text); line-height: 1.6; margin: 0 0 20px; }

/* ======================== UTILS ======================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 380px) {
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}
