/**
 * Antigravity Auth & Shared System CSS
 * Thiết kế thuần CSS local, độc lập hoàn toàn với Internet, không dùng CDN.
 * Hỗ trợ Responsive ≥ 320px, Dark Mode, Glassmorphism, Accessibility & prefers-reduced-motion.
 */

:root {
  --bg-dark: #030712;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-input: rgba(15, 23, 42, 0.8);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-focus: #6366f1;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.35);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-border: rgba(16, 185, 129, 0.35);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-border: rgba(245, 158, 11, 0.35);
  --shadow-float: 0 20px 45px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

html {
  box-sizing: border-box;
}

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

html,
body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 10px;
  background:
    linear-gradient(rgba(3, 10, 22, 0.68), rgba(3, 10, 22, 0.68)),
    url('../assets/iot-bg.jpg') center / cover no-repeat fixed;
  background-color: var(--bg-dark);
}

/* Container bố cục */
.auth-wrapper {
  width: 100%;
  max-width: 400px;
  min-width: 0;
  margin: 0 auto;
}

/* Glassmorphism Card */
.auth-card {
  width: 100%;
  min-width: 0;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  box-shadow: var(--shadow-float);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (max-width: 360px) {
  body {
    padding: 10px 6px;
  }

  .auth-card {
    padding: 20px 12px;
    border-radius: var(--radius-md);
  }

  .auth-title {
    font-size: 1.15rem;
  }
}

/* Header thương hiệu */
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand-logo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 8px 16px rgba(79, 70, 229, 0.35));
}

.auth-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  box-shadow: 0 8px 16px -4px rgba(79, 70, 229, 0.4);
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Form controls */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #e5e7eb;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.95rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

.input-with-toggle {
  padding-right: 42px;
}

.btn-toggle-eye {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  user-select: none;
}

.btn-toggle-eye:hover {
  color: #ffffff;
}

/* Nút Submit */
.btn-primary {
  width: 100%;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

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

/* Hộp thông báo / Alert */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 20px;
  display: none;
}

.alert-error {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #fca5a5;
}

.alert-success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #6ee7b7;
}

.alert-warning {
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #fcd34d;
}

/* Policy helper box */
.policy-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.policy-card ul {
  list-style: none;
  margin-top: 6px;
}

.policy-card li {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.policy-card li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
}

/* Footer link */
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.auth-footer a {
  color: #818cf8;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Hỗ trợ accessibility: prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Đăng nhập / Đăng ký (web) ===== */
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: rgba(15, 23, 42, 0.55);
  padding: 4px;
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--primary, #4f46e5);
  color: #ffffff;
}

.auth-form.hidden {
  display: none;
}

.auth-switch {
  text-align: center;
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

.link-button {
  border: 0;
  background: transparent;
  color: #818cf8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.link-button:hover {
  text-decoration: underline;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 16px;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.45;
  cursor: pointer;
}

.checkbox-row input {
  margin-top: 3px;
  accent-color: var(--primary, #4f46e5);
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

/* ===== Dialog Modals ===== */
dialog.auth-dialog {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-main);
  padding: 24px 20px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-float);
  margin: auto;
}

dialog.auth-dialog::backdrop {
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.btn-close-dialog {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.btn-close-dialog:hover {
  color: #ffffff;
}
