/* ═══════════════════════════════════════════════════════════════
   Hostel Hub — Student Self-Registration Portal
   Premium Mobile-First Design
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Variables ── */
:root {
  --bg:            #070b14;
  --bg2:           #0d1220;
  --surface:       rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border:        rgba(255,255,255,0.09);
  --border-focus:  rgba(99,102,241,0.6);

  --accent:        #6366f1;
  --accent-2:      #8b5cf6;
  --accent-glow:   rgba(99,102,241,0.25);
  --grad:          linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --success:       #10b981;
  --success-bg:    rgba(16,185,129,0.12);
  --error:         #f43f5e;
  --error-bg:      rgba(244,63,94,0.12);
  --warn:          #f59e0b;

  --text:          #f1f5f9;
  --text-2:        #94a3b8;
  --text-3:        #64748b;

  --radius:        16px;
  --radius-sm:     10px;
  --radius-xs:     8px;
  --shadow:        0 24px 64px rgba(0,0,0,0.5);
  --font:          'Inter', system-ui, sans-serif;
  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ── Background glow blobs ── */
.bg-scene {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.35;
  animation: float 12s ease-in-out infinite;
}
.blob-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  top: -120px; left: -120px;
  animation-delay: 0s;
}
.blob-2 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  bottom: -100px; right: -80px;
  animation-delay: -5s;
}
.blob-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, #06b6d4, transparent 70%);
  top: 50%; left: 60%;
  animation-delay: -9s;
  opacity: 0.15;
}
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(20px, -30px) scale(1.05); }
}

/* ── App container ── */
#app {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 0 40px;
}

/* ── Screens ── */
.screen { display: none; width: 100%; max-width: 520px; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ── Loading Screen ── */
#screen-loading {
  justify-content: center; align-items: center;
  min-height: 100vh; gap: 20px;
}
.loader-ring {
  width: 56px; height: 56px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { color: var(--text-2); font-size: 14px; }

/* ── Hostel Header ── */
.hostel-header {
  width: 100%;
  background: var(--grad);
  padding: 28px 24px 24px;
  display: flex; align-items: center; gap: 16px;
}
.hostel-icon-wrap {
  width: 52px; height: 52px;
  background: rgba(255,255,255,0.2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; flex-shrink: 0;
  backdrop-filter: blur(8px);
}
.hostel-info h1 {
  font-size: 20px; font-weight: 800;
  color: #fff; line-height: 1.2;
}
.hostel-info p {
  font-size: 12px; color: rgba(255,255,255,0.75);
  margin-top: 3px; font-weight: 500;
}

/* ── Progress bar ── */
.progress-wrap {
  width: 100%; background: var(--bg2);
  padding: 16px 24px 0;
}
.progress-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.progress-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.progress-count { font-size: 12px; color: var(--text-3); }
.progress-track {
  width: 100%; height: 4px;
  background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--grad);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}
.step-dots {
  display: flex; gap: 8px; justify-content: center;
  padding: 12px 0 4px;
}
.step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); border: 2px solid transparent;
  transition: all var(--transition);
}
.step-dot.active {
  background: var(--accent); border-color: rgba(99,102,241,0.4);
  transform: scale(1.3);
}
.step-dot.done { background: var(--success); border-color: rgba(16,185,129,0.3); }

/* ── Form card ── */
.form-card {
  width: 100%; background: var(--bg2);
  padding: 0 24px;
}

/* ── Steps ── */
.step-panel {
  display: none; flex-direction: column; gap: 20px;
  padding: 24px 0;
  animation: slideIn 0.3s cubic-bezier(0.4,0,0.2,1);
}
.step-panel.active { display: flex; }
.step-panel.slide-out { animation: slideOut 0.3s cubic-bezier(0.4,0,0.2,1); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-24px); }
}
.step-heading {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.step-icon {
  width: 36px; height: 36px;
  background: var(--accent-glow);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.step-heading h2 { font-size: 17px; font-weight: 700; }
.step-heading p { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px; font-weight: 600;
  color: var(--text-2); letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field label span.req { color: var(--error); margin-left: 2px; }

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-3); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  background: rgba(99,102,241,0.06);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field input.invalid,
.field select.invalid,
.field textarea.invalid {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 3px rgba(244,63,94,0.15);
}
.field select option { background: #1e293b; }
.field textarea { resize: vertical; min-height: 90px; }
.field-hint { font-size: 11px; color: var(--text-3); margin-top: -2px; }
.field-error { font-size: 11px; color: var(--error); display: none; }
.field input.invalid ~ .field-error { display: block; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Optional badge ── */
.optional-badge {
  font-size: 10px; font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 8px;
  color: var(--text-3);
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Navigation ── */
.form-nav {
  width: 100%; background: var(--bg2);
  padding: 16px 24px 24px;
  display: flex; gap: 12px;
}
.btn {
  flex: 1; padding: 14px 20px;
  border: none; border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-2);
  flex: 0 0 auto; padding: 14px 18px;
}
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(99,102,241,0.45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.6; cursor: not-allowed;
  transform: none; box-shadow: none;
}
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 20px rgba(16,185,129,0.35);
}

/* ── Spinner inside button ── */
.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.loading .btn-text { display: none; }
.btn.loading .btn-spinner { display: block; }

/* ═══════════════════════════════════
   SUCCESS / QR SCREEN
═══════════════════════════════════ */
#screen-success {
  padding: 0;
}

.success-hero {
  width: 100%;
  background: var(--grad);
  padding: 36px 24px 28px;
  text-align: center;
  position: relative; overflow: hidden;
}
.success-hero::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.checkmark-circle {
  width: 72px; height: 72px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  position: relative; z-index: 1;
  animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}
.checkmark-circle svg { width: 38px; height: 38px; }
.success-hero h2 {
  font-size: 22px; font-weight: 800; color: #fff;
  position: relative; z-index: 1;
}
.success-hero p {
  font-size: 13px; color: rgba(255,255,255,0.8);
  margin-top: 6px; position: relative; z-index: 1;
}

/* QR Section */
.qr-section {
  width: 100%; padding: 28px 24px 0;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.qr-card {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: slideUp 0.5s 0.2s cubic-bezier(0.4,0,0.2,1) both;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
#qr-canvas {
  border-radius: 8px;
  display: block;
}
.qr-label {
  font-size: 11px; font-weight: 700;
  color: #94a3b8; letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Student Badge */
.student-badge {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 14px;
  animation: slideUp 0.5s 0.35s cubic-bezier(0.4,0,0.2,1) both;
}
.badge-avatar {
  width: 48px; height: 48px;
  background: var(--grad);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.badge-info { flex: 1; min-width: 0; }
.badge-name {
  font-size: 16px; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-detail { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.badge-status {
  font-size: 11px; font-weight: 700;
  background: rgba(245,158,11,0.15);
  color: var(--warn);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 99px;
  padding: 4px 10px;
  white-space: nowrap;
  animation: pulse-warn 2s ease-in-out infinite;
}
@keyframes pulse-warn {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* QR Actions */
.qr-actions {
  width: 100%; display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  animation: slideUp 0.5s 0.45s cubic-bezier(0.4,0,0.2,1) both;
}
.qr-actions .btn { flex: 1; }

.btn-outline {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface-hover); border-color: var(--accent); color: var(--accent); }

/* Info notice */
.info-notice {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; gap: 10px; align-items: flex-start;
  animation: slideUp 0.5s 0.55s cubic-bezier(0.4,0,0.2,1) both;
}
.info-notice-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.info-notice-body { flex: 1; }
.info-notice-body h4 { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.info-notice-body p { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.info-notice.warn { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.06); }
.info-notice.success { border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.06); }

/* Reg ID row */
.reg-id-row {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  animation: slideUp 0.5s 0.6s cubic-bezier(0.4,0,0.2,1) both;
}
.reg-id-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.reg-id-value { font-size: 12px; font-weight: 700; color: var(--accent); font-family: monospace; flex: 1; }
.reg-id-copy {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 16px; padding: 2px 4px;
  border-radius: 4px; transition: color var(--transition);
}
.reg-id-copy:hover { color: var(--accent); }

/* ═══════════════════════════════════
   ERROR SCREEN
═══════════════════════════════════ */
#screen-error {
  justify-content: center; align-items: center;
  min-height: 100vh; padding: 24px; gap: 16px; text-align: center;
}
.error-icon { font-size: 56px; }
#screen-error h2 { font-size: 20px; font-weight: 700; }
#screen-error p { font-size: 14px; color: var(--text-2); line-height: 1.6; max-width: 300px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s;
  white-space: nowrap;
  opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { border-color: var(--error); background: #1c0b0f; color: var(--error); }
.toast.success { border-color: var(--success); background: #051911; color: var(--success); }

/* ── Responsive ── */
@media (min-width: 520px) {
  #app { padding-top: 32px; }
  .hostel-header { padding: 32px 32px 28px; }
  .progress-wrap,
  .form-card,
  .form-nav { padding-left: 32px; padding-right: 32px; }
  .qr-section { padding: 32px 32px 0; }
  .screen { border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow); overflow: hidden; }
}
