/* ============================================================
   ProvaNova — Component Styles
   File: styles/components.css

   Reusable UI components used across all screens.
   Loaded once in index.html — all screens inherit automatically.
   Never put screen-specific styles here.
   Never redeclare :root variables — use what core.css defines.
   ============================================================ */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 52px;
  padding: 0 var(--space-6);
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast),
              opacity var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  min-width: 48px;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.48;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  color: var(--text-on-primary);
  box-shadow: 0 2px 12px rgba(0, 87, 255, 0.28);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(0, 87, 255, 0.38);
}

/* Secondary */
.btn-secondary {
  background: var(--secondary);
  color: var(--text-on-primary);
  box-shadow: 0 2px 10px rgba(0, 105, 92, 0.22);
}
.btn-secondary:hover {
  background: var(--secondary-dark);
}

/* Ghost (outlined) */
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-ghost:hover {
  background: var(--primary-light);
}

/* Danger */
.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover {
  background: #b71c1c;
}

/* Neutral */
.btn-neutral {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-neutral:hover {
  background: var(--border-light);
}

/* Full width */
.btn-full {
  width: 100%;
}

/* Small */
.btn-sm {
  height: 40px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

/* Icon only */
.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

/* Loading state */
.btn.loading {
  pointer-events: none;
}
.btn.loading .btn-label { visibility: hidden; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-ghost.loading::after,
.btn-neutral.loading::after {
  border-color: rgba(0,87,255,0.25);
  border-top-color: var(--primary);
}

[data-theme="dark"] .btn-neutral {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* ============================================================
   INPUTS & FORM FIELDS
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
}

.field-label span.required {
  color: var(--error);
  margin-left: 2px;
}

.input {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-base);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.12);
}

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

.input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.10);
}

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

.input-wrap .input {
  padding-right: 48px;
}

.input-wrap .input-icon {
  position: absolute;
  right: 0;
  top: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 16px;
  transition: color var(--transition-fast);
}

.input-wrap .input-icon:hover {
  color: var(--text);
}

.textarea {
  width: 100%;
  min-height: 100px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-base);
  font-size: var(--text-base);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.12);
}

.select {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-10) 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-base);
  font-size: var(--text-base);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.12);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.field-error {
  font-size: var(--text-xs);
  color: var(--error);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

[data-theme="dark"] .input,
[data-theme="dark"] .textarea,
[data-theme="dark"] .select {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .input::placeholder {
  color: var(--text-disabled);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  transition: box-shadow var(--transition-fast),
              transform var(--transition-fast);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .card {
  background: var(--surface);
  border-color: var(--border);
}

/* ============================================================
   NAVBAR (bottom)
   ============================================================ */

.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.navbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-base);
  font-size: 10px;
  font-weight: var(--weight-medium);
  padding: 0;
  text-decoration: none;
  transition: color var(--transition-fast);
  min-width: 48px;
}

.navbar-item i {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.navbar-item.active {
  color: var(--primary);
}

.navbar-item.active i {
  transform: scale(1.1);
}

.navbar-item:active i {
  transform: scale(0.92);
}

[data-theme="dark"] .navbar {
  background: var(--surface);
  border-top-color: var(--border);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.35);
}

/* ============================================================
   HEADER (screen top)
   ============================================================ */

.screen-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding-inline: var(--space-2);
  z-index: 50;
  gap: var(--space-2);
}

.header-back {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text);
  font-size: 18px;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.header-back:hover {
  background: var(--surface-2);
}

.header-title {
  flex: 1;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.header-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 17px;
  transition: background var(--transition-fast),
              color var(--transition-fast);
}

.header-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

[data-theme="dark"] .screen-header {
  background: var(--surface);
  border-bottom-color: var(--border);
}

/* ============================================================
   BOTTOM SHEET
   ============================================================ */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--transition-base);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sheet-overlay.visible {
  opacity: 1;
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-2) var(--space-6) calc(var(--space-6) + var(--safe-bottom));
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--transition-base);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
}

.sheet.visible {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto var(--space-5);
}

.sheet-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-4);
}

.sheet-content {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

.sheet-content p + p {
  margin-top: var(--space-3);
}

.sheet-content strong {
  color: var(--text);
  font-weight: var(--weight-semibold);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

[data-theme="dark"] .sheet {
  background: var(--surface);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.55);
}

[data-theme="dark"] .sheet-overlay {
  background: rgba(0,0,0,0.65);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  top: calc(var(--space-4) + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
  width: calc(100% - var(--space-8));
  max-width: 480px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: fadeInDown 220ms ease forwards;
  pointer-events: auto;
  width: 100%;
  line-height: var(--leading-snug);
}

.toast.hiding {
  animation: fadeOutUp 220ms ease forwards;
}

.toast i {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-success { background: var(--secondary); }
.toast-error   { background: var(--error); }
.toast-info    { background: var(--primary); }
.toast-warning { background: var(--warning); }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOutUp {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ============================================================
   SKELETON LOADERS
   ============================================================ */

.skeleton {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.55) 50%,
    transparent 100%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 50%,
    transparent 100%
  );
  background-size: 400px 100%;
}

.skeleton-text {
  height: 16px;
  border-radius: var(--radius-xs);
  margin-bottom: var(--space-2);
}

.skeleton-text.short { width: 55%; }
.skeleton-text.medium { width: 75%; }
.skeleton-text.full { width: 100%; }

.skeleton-title {
  height: 22px;
  width: 60%;
  border-radius: var(--radius-xs);
  margin-bottom: var(--space-3);
}

.skeleton-card {
  height: 80px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* ============================================================
   FULL-SCREEN SPINNER
   ============================================================ */

.spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.spinner-ring {
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
}

/* ============================================================
   BADGES & CHIPS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}
.badge-secondary {
  background: var(--secondary-light);
  color: var(--secondary);
}
.badge-accent {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.badge-error {
  background: var(--error-light);
  color: var(--error);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
}

.chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.chip:active {
  transform: scale(0.95);
}

[data-theme="dark"] .chip {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================================
   CREDITS PILL (accent display)
   ============================================================ */

.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--accent-light);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--accent-dark);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.credits-pill i {
  font-size: 14px;
  color: var(--accent);
}

.credits-pill:hover {
  background: #ffe082;
}

[data-theme="dark"] .credits-pill {
  background: var(--accent-light);
  color: #ffd54f;
}

/* ============================================================
   DIVIDER
   ============================================================ */

.divider {
  height: 1px;
  background: var(--border-light);
  border: none;
  margin: var(--space-4) 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  gap: var(--space-3);
}

.empty-state-icon {
  font-size: 48px;
  color: var(--text-disabled);
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.empty-state-text {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 280px;
}

/* ============================================================
   SCREEN LAYOUT HELPERS
   Used inside every screen that has header + navbar.
   ============================================================ */

.screen-body {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--navbar-height) + var(--space-4));
  min-height: 100dvh;
  min-height: 100vh;
}

.screen-body.no-header {
  padding-top: 0;
}

.screen-body.no-navbar {
  padding-bottom: var(--space-6);
}

.screen-content {
  padding: var(--space-5) var(--space-4);
  max-width: var(--max-width);
  margin-inline: auto;
}

@media (min-width: 768px) {
  .screen-content {
    padding: var(--space-6) var(--space-8);
  }
}

@media (min-width: 1025px) {
  .screen-content {
    padding: var(--space-8) var(--space-10);
  }
}

/* ============================================================
   PROGRESS BAR (onboarding steps)
   ============================================================ */

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ============================================================
   GOOGLE SIGN-IN BUTTON (consistent style)
   ============================================================ */

.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  gap: var(--space-3);
}

.btn-google:hover {
  background: var(--surface-2);
  border-color: var(--text-disabled);
}

.btn-google img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

[data-theme="dark"] .btn-google {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* ============================================================
   OFFLINE NOTICE
   ============================================================ */

.offline-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  min-height: 100vh;
  text-align: center;
  padding: var(--space-8);
  gap: var(--space-4);
}

.offline-icon {
  font-size: 56px;
  color: var(--text-disabled);
}

.offline-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text);
}

.offline-text {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 300px;
  line-height: var(--leading-relaxed);
}
