/* CSS Variables & Design System */
:root {
  --bg-dark: #0a0c10;
  --panel-bg: rgba(22, 28, 38, 0.55);
  --panel-bg-solid: #161c26;
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-focus: rgba(102, 252, 241, 0.5);
  
  /* Palette */
  --accent-primary: #66fcf1;
  --accent-primary-rgb: 102, 252, 241;
  --accent-secondary: #45a29e;
  --accent-dark: #1f2833;
  --text-primary: #ffffff;
  --text-secondary: #c5c6c7;
  --text-muted: #8892b0;
  
  /* System States */
  --error: #ff3e4e;
  --error-bg: rgba(255, 62, 78, 0.1);
  --success: #00e676;
  --success-bg: rgba(0, 230, 118, 0.1);
  --warning: #ffb300;
  
  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-title: 'Outfit', sans-serif;
  
  /* Layout */
  --max-width: 1200px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}

/* Layout Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 10;
  overflow-x: hidden;
}

/* Header styling */
.app-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 1.5px;
  color: var(--text-primary);
}

.logo-text .highlight {
  color: var(--accent-primary);
}


/* Loading Screen */
.loading-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(102, 252, 241, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

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

.loading-container p {
  font-family: var(--font-title);
  color: var(--text-secondary);
  font-size: 15px;
  letter-spacing: 0.5px;
}

/* Global Panels & Cards */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  transition: var(--transition-smooth);
}

/* Main View Panels */
.view-panel {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 48px 0;
  animation: fade-in 0.4s ease-out forwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-decoration: none;
  border: none;
  gap: 10px;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: var(--bg-dark);
}

.btn-primary:hover {
  background-color: #55ebd8;
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-glow:hover {
  box-shadow: 0 0 20px rgba(102, 252, 241, 0.4);
}

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

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn-danger {
  background-color: rgba(255, 62, 78, 0.15);
  color: var(--error);
  border: 1px solid rgba(255, 62, 78, 0.25);
}

.btn-danger:hover {
  background-color: var(--error);
  color: #fff;
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

.btn-social {
  background-color: #ffffff;
  color: #1a1a1a;
  font-weight: 600;
  border: 1px solid #ffffff;
}

.btn-social:hover {
  background-color: #f1f1f1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.social-icon {
  width: 18px;
  height: 18px;
}


/* Auth Card and section */
.auth-section {
  display: flex;
  justify-content: center;
  margin-bottom: 72px;
}

.auth-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.auth-title {
  margin-bottom: 32px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--accent-primary);
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 700;
}

/* Forms */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.auth-form.active-form {
  display: flex;
}

.form-group {
  position: relative;
  display: flex;
  flex-direction: column;
}

.form-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 14px 16px;
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: var(--transition-smooth);
  width: 100%;
}

.form-input:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(102, 252, 241, 0.2);
  background: rgba(255, 255, 255, 0.12);
}

/* Specific styling for dropdowns to improve visibility and theme consistency */
select.form-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2366fcf1' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  padding-right: 44px;
  cursor: pointer;
  line-height: 1.2;
}

select.form-input option {
  background-color: var(--panel-bg-solid);
  color: var(--text-primary);
  padding: 12px;
}

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.form-input:focus::placeholder {
  color: transparent;
}

/* Toggle password visibility button */
.btn-toggle-password {
  position: absolute;
  right: 16px;
  top: 13px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  transition: var(--transition-smooth);
}

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

.eye-icon {
  width: 20px;
  height: 20px;
}

.btn-submit {
  margin-top: 8px;
}


/* DASHBOARD VIEW */
.dashboard-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  align-items: start;
  min-width: 0;
}

.dashboard-sidebar,
.dashboard-main {
  min-width: 0;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .page-header-panel,
  .phone-number-card {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header-actions {
    width: 100%;
  }

  .phone-number-form,
  .phone-edit-form {
    grid-template-columns: 1fr;
  }

  .form-group-wide {
    grid-column: auto;
  }

  .phone-number-form .btn,
  .phone-edit-form .btn {
    grid-column: auto;
  }

  .phone-display,
  .phone-card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .phone-link {
    white-space: normal;
    word-break: break-word;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 0 16px;
  }
  
  .hero-title {
    font-size: 36px;
  }
  
  .welcome-title {
    font-size: 26px;
  }

  .toast-container {
    top: 20px;
    right: 20px;
    left: 20px;
    width: auto;
    max-width: none;
  }
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 24px;
}

.avatar-container {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(102, 252, 241, 0.05);
  border: 2px solid rgba(102, 252, 241, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
  overflow: hidden;
}

.avatar-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#user-display-name {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.app-nav-link.active {
  background-color: rgba(102, 252, 241, 0.14);
  border-color: rgba(102, 252, 241, 0.38);
  color: var(--accent-primary);
}

/* Dashboard Main */
.flex-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.authenticated-page {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.authenticated-page.active-page {
  display: flex;
}

.main-welcome {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.welcome-title {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 800;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.welcome-text {
  font-size: 15px;
  color: var(--text-secondary);
}

.page-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.page-link-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
}

.page-link-card:hover {
  transform: translateY(-4px);
  border-color: rgba(102, 252, 241, 0.25);
}

.page-link-card:active {
  transform: scale(0.97);
}

.page-link-kicker,
.page-eyebrow {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.page-link-title {
  color: var(--accent-primary);
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
}

.page-link-desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.page-header-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-header-actions {
  display: flex;
  gap: 12px;
}

.data-status {
  color: var(--text-secondary);
  font-size: 14px;
}

.phone-number-form,
.phone-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.phone-display[hidden],
.phone-edit-form[hidden] {
  display: none;
}

.phone-number-form.collapsed {
  display: none;
}

.phone-number-form .btn,
.phone-edit-form .btn {
  align-self: stretch;
  grid-column: span 2;
}

.form-group-wide {
  grid-column: span 2;
}

.phone-number-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.phone-number-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.phone-display {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.phone-info {
  flex-grow: 1;
  min-width: 0;
}

.phone-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.phone-name {
  display: block;
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
}

.phone-meta {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.phone-details-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.phone-detail-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.phone-detail-item:last-child {
  border-bottom: none;
}

.phone-detail-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 90px;
  flex-shrink: 0;
  margin-top: 3px;
}

.phone-detail-value {
  color: var(--text-secondary);
  font-size: 13px;
  word-break: break-word;
}

.phone-link {
  color: var(--accent-primary);
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.phone-link[href]:hover {
  text-decoration: underline;
}

.phone-link[aria-disabled="true"] {
  color: var(--text-muted);
  pointer-events: none;
}

.btn-compact {
  padding: 8px 14px;
}

.text-accent {
  color: var(--accent-primary);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* App Footer */
.app-footer {
  text-align: center;
  padding: 48px 0;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 13px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 32px;
  right: 32px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  width: calc(100% - 64px);
  pointer-events: none;
  overflow: hidden; /* Constrain sliding toasts */
  clip-path: inset(-50px 0 -50px -50px); /* Clip right side to prevent viewport overflow while allowing other shadows */
}

.toast {
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border);
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: start;
  gap: 12px;
  transform: translateX(120%);
  animation: slide-in-toast 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  pointer-events: auto;
  will-change: transform;
}

@keyframes slide-in-toast {
  to { transform: translateX(0); }
}

.toast.fade-out {
  animation: fade-out-toast 0.3s ease-out forwards;
}

@keyframes fade-out-toast {
  to {
    transform: translateY(-10px);
    opacity: 0;
  }
}

.toast-icon {
  font-size: 18px;
  line-height: 1;
}

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.toast-msg {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-success {
  border-left: 3px solid var(--success);
}
.toast-success .toast-title {
  color: var(--success);
}

.toast-error {
  border-left: 3px solid var(--error);
}
.toast-error .toast-title {
  color: var(--error);
}

.toast-info {
  border-left: 3px solid var(--accent-primary);
}
.toast-info .toast-title {
  color: var(--accent-primary);
}

/* Simplified Auth-Only Landing View styles */
.auth-only-view {
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  min-height: calc(100vh - 120px);
  padding: 24px 0;
}

.auth-only-view .auth-section {
  margin-bottom: 0;
  width: 100%;
  animation: fade-in-up 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
