/* ==========================================================================
   DESIGN SYSTEM & GLOBAL STYLES (VANILLA MODERN GLASSMORPHISM)
   ========================================================================== */

:root {
  --bg-primary: #090d16;
  --card-bg: rgba(13, 20, 38, 0.45);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-blue: #3b82f6;
  --accent-pink: #d946ef;
  
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  --font-family: 'Outfit', sans-serif;
  --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  padding: 20px;
}

/* Background Glowing Orbs */
.glowing-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.35;
  pointer-events: none;
  animation: pulse-orb 15s infinite alternate ease-in-out;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--accent-indigo) 0%, var(--accent-blue) 100%);
  top: -10%;
  left: -10%;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-pink) 0%, var(--accent-cyan) 100%);
  bottom: -15%;
  right: -10%;
  animation-delay: -5s;
}

@keyframes pulse-orb {
  0% { transform: scale(1) translate(0, 0); opacity: 0.3; }
  100% { transform: scale(1.2) translate(50px, 30px); opacity: 0.45; }
}

/* ==========================================================================
   APP MAIN CONTAINERS
   ========================================================================== */

.app-container {
  width: 100%;
  max-width: 460px;
  z-index: 1;
  position: relative;
}

/* Glassmorphism Card Style */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 40px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 
              inset 0 1px 1px rgba(255, 255, 255, 0.05);
  display: none; /* JS toggles active class */
  transform: translateY(20px);
  opacity: 0;
  transition: var(--transition-smooth);
}

.glass-card.active {
  display: block;
  transform: translateY(0);
  opacity: 1;
}

.glass-card.max-width-large {
  max-width: 800px;
}

.app-container:has(#admin-card.active) {
  max-width: 780px;
}

/* Animations */
.animate-fade-in {
  animation: fadeIn 0.5s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   BRAND HEADERS & LOGOS
   ========================================================================== */

.brand-header {
  text-align: center;
  margin-bottom: 36px;
}

.brand-header.compact {
  margin-bottom: 24px;
}

.logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
  border: 1.5px solid rgba(99, 102, 241, 0.25);
  border-radius: 22px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 32px;
  color: var(--accent-cyan);
  margin-bottom: 18px;
  box-shadow: 0 10px 25px -5px rgba(6, 182, 212, 0.2);
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.brand-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.brand-header p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* ==========================================================================
   HEADER ACTIONS (IN-APP)
   ========================================================================== */

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 28px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-small {
  width: 44px;
  height: 44px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  color: var(--accent-indigo);
}

.logo-small.admin-color {
  background: rgba(217, 70, 239, 0.1);
  border-color: rgba(217, 70, 239, 0.25);
  color: var(--accent-pink);
}

.main-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-success i {
  font-size: 6px;
  animation: pulse-green 1.5s infinite alternate;
}

@keyframes pulse-green {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

#logout-btn, #close-admin-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  transition: var(--transition-fast);
}

#logout-btn:hover, #close-admin-btn:hover {
  background: rgba(239, 68, 110, 0.1);
  color: var(--error);
  border-color: rgba(239, 68, 110, 0.2);
}

/* ==========================================================================
   INPUTS & FORM CONTROLS
   ========================================================================== */

.form-group {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font-family);
  outline: none;
  transition: var(--transition-fast);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="text"]::placeholder {
  color: var(--text-muted);
}

input:focus {
  border-color: var(--card-border-focus);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

/* Auto-complete custom styling */
.autocomplete-container {
  position: relative;
}

/* Input PIN riêng */
.pin-input-group {
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
}

.pin-input-group input {
  text-align: center;
  font-size: 20px;
  letter-spacing: 4px;
}

.pin-fields {
  flex-grow: 1;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 15px;
  border-radius: 14px;
  padding: 14px 24px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  outline: none;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-gradient {
  background: linear-gradient(135deg, var(--accent-indigo) 0%, var(--accent-blue) 100%);
  color: #ffffff;
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.4);
  position: relative;
  overflow: hidden;
}

.btn-gradient::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: 0.5s;
}

.btn-gradient:hover:not(:disabled)::before {
  left: 100%;
}

.btn-gradient:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -4px rgba(99, 102, 241, 0.55);
}

.btn-gradient:active:not(:disabled) {
  transform: translateY(0);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.35);
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 12px 24px -4px rgba(16, 185, 129, 0.5);
}

/* Nút bị vô hiệu hóa (Khi cooldown đang bật) */
.btn:disabled {
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--text-muted) !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
  box-shadow: none !important;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--accent-cyan);
}

/* ==========================================================================
   MAIN APP BODY SPECIFIC STYLES
   ========================================================================== */

.description {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 26px;
}

#fetch-otp-btn {
  width: 100%;
  margin-bottom: 20px;
}

/* Loading Spinners */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.hidden {
  display: none !important;
}

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

/* ==========================================================================
   RESULT CARD (OTP CODES DISPLAY)
   ========================================================================== */

.otp-result-container {
  background: rgba(255, 255, 255, 0.02);
  border: 1.5px solid rgba(99, 102, 241, 0.15);
  border-radius: 20px;
  padding: 24px;
  margin-top: 10px;
  animation: slideUp 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.15) forwards;
  box-shadow: 0 15px 30px -10px rgba(99, 102, 241, 0.15),
              inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.otp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-cyan);
  margin-bottom: 12px;
}

#otp-timestamp {
  font-weight: 500;
  color: var(--text-muted);
}

.otp-display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.otp-code-value {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #ffffff;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
  font-family: monospace;
}

/* Glow hiệu ứng khi có OTP thực */
.otp-result-container.active-otp {
  border-color: rgba(6, 182, 212, 0.35);
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
}

.otp-result-container.active-otp .otp-code-value {
  color: var(--accent-cyan);
  text-shadow: 0 0 20px rgba(6, 182, 212, 0.55);
}

.otp-notice {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ==========================================================================
   STATUS BOX (ERROR & WARNINGS)
   ========================================================================== */

.status-box {
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: shake 0.4s ease-in-out;
}

.status-box.error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.status-box.success {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ==========================================================================
   FOOTER SECTION
   ========================================================================== */

.app-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-footer p {
  font-size: 11.5px;
  color: var(--text-muted);
}

.admin-link {
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.admin-link:hover {
  color: var(--accent-pink);
  text-shadow: 0 0 8px rgba(217, 70, 239, 0.3);
}

/* ==========================================================================
   ADMIN PANEL STYLING
   ========================================================================== */

.admin-tabs {
  display: flex;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  font-family: var(--font-family);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-pink);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1.5px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-pink);
  box-shadow: 0 -2px 10px rgba(217, 70, 239, 0.8);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-subcard {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 22px;
}

.admin-subcard h4 {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 8px;
}

.add-account-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: start;
}

@media (max-width: 768px) {
  .add-account-form {
    grid-template-columns: 1fr;
  }
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
}

.add-account-form .btn {
  height: 50px;
}

/* Tables Styles */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.max-height-logs {
  max-height: 380px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.admin-table th, .admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.admin-table th {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: var(--text-secondary);
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.01);
}

.admin-table td {
  color: var(--text-primary);
}

.btn-danger-small {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-family);
  font-weight: 500;
  transition: var(--transition-fast);
}

.btn-danger-small:hover {
  background: var(--error);
  color: white;
}

/* Logs specific styles */
.logs-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.logs-header-row h4 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.btn-icon-small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  cursor: pointer;
}

.btn-icon-small:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-pink);
}

.status-badge {
  font-size: 10px;
  padding: 1.5px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.status-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

/* ==========================================================================
   TOAST ELEMENT
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 24px;
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 10;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
