/* ─── VHAM ID - Call Sign Verification ─── */
/* American aesthetic: Clean, confident, Navy/Red/White */

:root {
  --primary: #1a3a5c;
  --primary-light: #2c5a8c;
  --accent: #c62828;
  --accent-light: #ef5350;
  --success: #2e7d32;
  --warning: #e65100;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #212121;
  --text-secondary: #616161;
  --border: #e0e0e0;
  --border-focus: #1a3a5c;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

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

/* ─── Base ─── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Container ─── */
.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ─── Header ─── */
.header {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 16px;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.header-top .lang-switch {
  margin-top: 0;
  flex-shrink: 0;
}

.logo-area {
  flex: 1;
  display: flex;
  justify-content: center;
}

.logo-placeholder {
  width: 200px;
  height: 200px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 4px;
}

.logo-placeholder img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  line-height: 1.4;
}

.lang-switch {
  margin-top: 0;
}

.lang-switch select {
  font-family: inherit;
  font-size: 0.82rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ─── Form ─── */
.form {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-section {
  margin-bottom: 20px;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}

.required {
  color: var(--accent);
}

.field input[type="text"],
.field input[type="email"] {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition);
  background: var(--surface);
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}

.field input.error {
  border-color: var(--accent);
}

.hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.info-text {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: -12px;
  margin-bottom: 16px;
}

.error {
  display: block;
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 4px;
  min-height: 0;
}

.error:empty {
  display: none;
}

/* ─── Duplicate Warning ─── */
.userid-warning {
  background: #fff3e0;
  border: 1px solid #ffb74d;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #e65100;
  margin-top: 4px;
  display: none;
}

.userid-warning.show {
  display: block;
}

/* ─── Input with inline add button ─── */
.input-with-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-with-btn input {
  flex: 1;
  min-width: 0;
}

/* ─── Inline Add Device Button (+) ─── */
.btn-add-inline {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-add-inline:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: rgba(26,58,92,0.04);
}

.btn-add-inline:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ─── Add Device Button (full-width, unused but kept) ─── */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 2px dashed var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  transition: all var(--transition);
  margin-top: 8px;
  width: 100%;
  justify-content: center;
}

.btn-add:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: rgba(26,58,92,0.04);
}

.btn-add:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Remove Device Button ─── */
.btn-remove-device {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 2px 6px;
  font-family: inherit;
}

.btn-remove-device:hover {
  text-decoration: underline;
}

/* ─── Upload Area ─── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: #fafafa;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary-light);
  background: rgba(26,58,92,0.04);
}

.upload-icon {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  margin: 0 auto 8px;
}

.upload-content p {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 4px;
}

.upload-content small {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ─── File Preview ─── */
.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f0f7f0;
  border: 1px solid #a5d6a7;
  border-radius: var(--radius);
  margin-top: 8px;
}

.file-info {
  display: flex;
  flex-direction: column;
}

.file-info span:first-child {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

.file-info span:last-child {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
}

.btn-remove:hover {
  text-decoration: underline;
}

/* ─── Captcha ─── */
.captcha-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.captcha-group input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition);
}

.captcha-group input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}

.captcha-image {
  height: 50px;
  min-width: 120px;
  background: #f0f0f0;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.captcha-image svg {
  display: block;
}

.btn-refresh {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.btn-refresh:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

/* ─── Submit Button ─── */
.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.btn-submit:hover {
  background: var(--primary-light);
}

.btn-submit:active {
  transform: translateY(1px);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ─── Loading Spinner ─── */
.btn-submit.loading {
  position: relative;
  color: transparent;
}

.btn-submit.loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  top: 50%;
  left: 50%;
  margin: -11px 0 0 -11px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Footer ─── */
.footer {
  text-align: center;
  margin-top: 32px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.footer p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

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

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.modal-icon.success {
  background: #e8f5e9;
  color: var(--success);
}

.modal-icon.error {
  background: #ffebee;
  color: var(--accent);
}

.modal-content h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ─── Responsive ─── */
/* Small phones (2.4" ~ 320px) */
@media (max-width: 360px) {
  html {
    font-size: 14px;
  }

  .container {
    padding: 12px 10px 24px;
  }

  .form {
    padding: 16px;
  }

  .logo-placeholder {
    width: 120px;
    height: 120px;
    font-size: 24px;
  }

  .title {
    font-size: 1.1rem;
  }

  .header-top {
    gap: 4px;
  }

  .captcha-group {
    flex-wrap: wrap;
  }

  .captcha-image {
    width: 100%;
    min-width: unset;
  }
}

/* Regular phones */
@media (min-width: 361px) and (max-width: 480px) {
  .logo-placeholder {
    width: 150px;
    height: 150px;
  }
}

/* Tablets */
@media (min-width: 768px) {
  .container {
    padding: 40px 24px;
  }

  .form {
    padding: 32px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .container {
    padding: 60px 24px;
  }
}

/* ─── App embedded mode (webview) ─── */
@media (max-width: 280px) {
  html {
    font-size: 12px;
  }

  .logo-placeholder {
    width: 80px;
    height: 80px;
    font-size: 18px;
    border-radius: 8px;
  }

  .upload-area {
    padding: 12px;
  }

  .btn-submit {
    padding: 10px;
  }
}

/* ─── Print ─── */
@media print {
  .lang-switch, .btn-add, .btn-refresh, .btn-submit {
    display: none;
  }
}

/* ─── Captcha Feedback ─── */
.captcha-feedback {
  display: inline-block;
  margin-left: 8px;
  font-size: 1.1rem;
  min-width: 20px;
  font-weight: bold;
}
.captcha-feedback.valid {
  color: #10b981;
}
.captcha-feedback.invalid {
  color: #ef4444;
}
