/* =============================================
   Auth Styles - Login page, Navbar, Credit badges
   ============================================= */

/* Hide all views by default, show when active */
.app-view {
  display: none !important;
}

.app-view.app-view-active {
  display: block !important;
}

/* Login uses flex for centering */
#view-login.app-view-active {
  display: flex !important;
}

/* ---- NAVBAR ---- */
#app-navbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary, #146356);
  text-decoration: none;
}

.nav-brand svg {
  width: 24px;
  height: 24px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
}

.nav-link:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.nav-link.active {
  background: var(--primary-light, #E3F1EE);
  color: var(--primary, #146356);
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-avatar-placeholder {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2BAE94, #0F4B41);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.82rem;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(43,174,148,0.35);
  flex-shrink: 0;
}

.nav-user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-credits-label {
  font-size: 0.8rem;
  color: #9ca3af;
  font-weight: 500;
}

.nav-role-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.nav-role-admin, .nav-role-super_admin { background: #FEF2F2; color: #B91C1C; }

.nav-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid #e5e7eb;
  background: white;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.nav-btn-logout {
  color: #B91C1C;
  border-color: #fecaca;
}

.nav-btn-logout:hover {
  background: #fef2f2;
  color: #B91C1C;
}

/* ---- CREDITS BADGE ---- */
.credits-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  background: #D7EAE6;
  color: #146356;
}

.credits-badge.credits-zero {
  background: #fee2e2;
  color: #B91C1C;
}

.search-credits {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #D7EAE6;
  color: #146356;
  margin-left: 8px;
}

.search-credits.credits-zero {
  background: #fee2e2;
  color: #B91C1C;
}

/* ---- LOGIN PAGE — SPLIT LAYOUT ---- */
#view-login {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #f8fafc;
  padding: 0;
}

.login-split {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* -- Left branding panel -- */
.login-brand-panel {
  flex: 0 0 45%;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 60px 56px;
  position: relative;
  overflow: hidden;
}

.login-brand-panel::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(43,174,148,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.login-brand-panel::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14,165,233,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.login-brand-content {
  position: relative;
  z-index: 1;
}

.login-brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
  border: 1px solid rgba(255,255,255,0.1);
}

.login-brand-logo svg {
  color: white;
}

.login-brand-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.login-brand-subtitle {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
  margin-bottom: 48px;
  max-width: 380px;
}

.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
}

.login-feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.06);
}

.login-feature-icon svg {
  color: rgba(255,255,255,0.8);
}

.login-brand-footer {
  position: relative;
  z-index: 1;
  padding-top: 32px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.35);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* -- Right form panel -- */
.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: white;
}

.login-form-wrapper {
  width: 100%;
  max-width: 380px;
}

.login-form-header {
  margin-bottom: 36px;
}

.login-form-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.login-form-header p {
  font-size: 0.92rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* Form overrides for login */
.login-form-panel .form-group {
  margin-bottom: 20px;
}

.login-form-panel .form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-form-panel .form-group input {
  padding: 13px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #0f172a;
  background: #f8fafc;
  transition: all 0.2s;
}

.login-form-panel .form-group input:focus {
  outline: none;
  border-color: #2BAE94;
  background: white;
  box-shadow: 0 0 0 4px rgba(43,174,148,0.08);
}

.login-form-panel .form-group input::placeholder {
  color: #cbd5e1;
}

.login-submit-btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: white;
  cursor: pointer;
  transition: all 0.25s;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
  font-family: inherit;
}

.login-submit-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  box-shadow: 0 4px 16px rgba(15,23,42,0.25);
  transform: translateY(-1px);
}

.login-submit-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(15,23,42,0.2);
}

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

.login-submit-btn svg {
  transition: transform 0.2s;
}

.login-submit-btn:hover:not(:disabled) svg {
  transform: translateX(3px);
}

.login-form-footer {
  margin-top: 32px;
  text-align: center;
}

.login-secure-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 500;
}

.login-secure-badge svg {
  color: #94a3b8;
}

/* -- Responsive: mobile stacks vertically -- */
@media (max-width: 900px) {
  .login-split {
    flex-direction: column;
  }
  .login-brand-panel {
    flex: none;
    padding: 40px 32px 32px;
    min-height: auto;
  }
  .login-brand-title {
    font-size: 1.5rem;
  }
  .login-brand-subtitle {
    margin-bottom: 28px;
    font-size: 0.9rem;
  }
  .login-brand-features {
    display: none;
  }
  .login-brand-footer {
    display: none;
  }
  .login-form-panel {
    padding: 32px 24px;
  }
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  background: white;
  border: 2px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  justify-content: center;
}

.google-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.google-btn svg {
  width: 20px;
  height: 20px;
}

/* ---- AUTH TABS (Google / Email) ---- */
.auth-tabs {
  display: flex;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: white;
  color: #1f2937;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.auth-tab:hover:not(.active) {
  color: #374151;
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
}

/* ---- EMAIL SUB-TABS ---- */
.email-sub-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid #e5e7eb;
}

.email-sub-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: #9ca3af;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.email-sub-tab.active {
  color: #146356;
  border-bottom-color: #146356;
  font-weight: 600;
}

.email-sub-tab:hover:not(.active) {
  color: #6b7280;
}

/* ---- EMAIL FORMS ---- */
.email-form {
  display: none;
}

.email-form.active {
  display: block;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

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

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #1f2937;
  transition: all 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: #146356;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-group input::placeholder {
  color: #9ca3af;
}

.email-submit-btn {
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  background: #146356;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.email-submit-btn:hover:not(:disabled) {
  background: #146356;
}

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

.auth-error {
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #B91C1C;
  margin-bottom: 12px;
  text-align: left;
}

.auth-success {
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #146356;
  margin-bottom: 12px;
  text-align: left;
}

/* ---- SEARCH VIEW ADJUSTMENTS ---- */
#view-search header {
  padding-top: 0;
}

#search-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- CREDIT CONFIRMATION ---- */
.credit-confirm-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.credit-confirm-label:hover {
  background: #fef3c7;
}

.credit-confirm-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: #146356;
  cursor: pointer;
  flex-shrink: 0;
}

/* Error state: red highlight when user tries to search without checking */
.credit-confirm-label.credit-confirm-error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #B91C1C;
}

.credit-confirm-label.credit-confirm-error input[type="checkbox"] {
  accent-color: #B91C1C;
}

/* Shake animation */
.credit-confirm-label.credit-confirm-shake {
  animation: confirmShake 0.5s ease;
}

@keyframes confirmShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}

/* ---- NO CREDITS BANNER ---- */
.no-credits-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #B91C1C;
  line-height: 1.4;
}

.no-credits-banner svg {
  flex-shrink: 0;
  color: #B91C1C;
}


/* ---- USER PROFILE DROPDOWN ---- */
#nav-user-section {
  position: relative;
}

.nav-user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.nav-user-trigger:hover {
  background: #f3f4f6;
}

.nav-chevron {
  color: #9ca3af;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.nav-user-dropdown.open + .nav-chevron,
.nav-user-trigger:has(+ .nav-user-dropdown.open) .nav-chevron {
  transform: rotate(180deg);
}

.nav-user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
  min-width: 280px;
  z-index: 200;
  overflow: hidden;
  animation: dropdownFadeIn 0.15s ease;
}

.nav-user-dropdown.open {
  display: block;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.nav-dropdown-avatar img,
.nav-dropdown-avatar-ph {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(43,174,148,0.2);
}

.nav-dropdown-avatar-ph {
  background: linear-gradient(135deg, #2BAE94, #0F4B41);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(43,174,148,0.3);
}

.nav-dropdown-info {
  flex: 1;
  min-width: 0;
}

.nav-dropdown-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-dropdown-email {
  font-size: 0.78rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-dropdown-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 0;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 0.85rem;
}

.nav-dropdown-item-label {
  color: #6b7280;
  font-weight: 500;
}

.nav-dropdown-item-value {
  font-weight: 600;
  color: #1f2937;
}

.nav-dropdown-item-value.credits-zero {
  color: #B91C1C;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  font-family: inherit;
}

.nav-dropdown-btn:hover {
  background: #f9fafb;
}

.nav-dropdown-btn svg {
  color: #9ca3af;
  flex-shrink: 0;
}

.nav-dropdown-logout {
  color: #B91C1C;
  border-top: 1px solid #f3f4f6;
}

.nav-dropdown-logout:hover {
  background: #fef2f2;
}

.nav-dropdown-logout svg {
  color: #B91C1C;
}

/* ---- DEVICES MODAL (from profile dropdown) ---- */
.nav-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: dropdownFadeIn 0.15s ease;
}

.nav-modal {
  background: white;
  border-radius: 12px;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.nav-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
}

.nav-modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.nav-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.nav-modal-close:hover {
  color: #374151;
}

.nav-modal-body {
  padding: 16px 20px;
}

.nav-devices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #f3f4f6;
}

.nav-device-item.nav-device-blocked {
  background: #fef2f2;
  border-color: #fecaca;
}

.nav-device-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1f2937;
}

.nav-device-meta {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 2px;
}

.nav-device-remove {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
}

.nav-device-remove:hover {
  color: #B91C1C;
  background: #fef2f2;
}

.nav-device-status {
  font-size: 0.75rem;
  color: #B91C1C;
  font-weight: 600;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  #app-navbar {
    padding: 0 12px;
    height: 48px;
  }
  .nav-links {
    gap: 2px;
  }
  .nav-link {
    padding: 4px 8px;
    font-size: 0.8rem;
  }
  .login-card {
    margin: 16px;
    padding: 32px 24px;
  }
  .nav-user-name {
    display: none;
  }
  .nav-user-dropdown {
    min-width: 240px;
  }
}

/* ── Crédits (navbar) ── */
.nav-credit-chip{display:inline-flex;align-items:center;padding:3px 9px;margin-right:8px;font-size:.78rem;font-weight:700;color:#065f46;background:#d1fae5;border-radius:9999px;white-space:nowrap;}
.nav-credit-chip-empty{color:#991b1b;background:#fee2e2;}
.nav-credit-badge{font-weight:700;color:#059669;}
