/* ============================================================
   ApplyVault — stylesheet
   Mobile-first, no external framework
   ============================================================ */

/* ── Custom properties ───────────────────────────────────── */
:root {
  --color-bg:           #0f1117;
  --color-surface:      #1a1d27;
  --color-surface-alt:  #22263a;
  --color-border:       #2e3248;
  --color-border-light: #3a4060;

  --color-text:         #e8eaf0;
  --color-text-muted:   #8892a4;
  --color-text-subtle:  #5c6478;

  --color-accent:       #6c63ff;
  --color-accent-hover: #5a53e6;
  --color-accent-dim:   rgba(108, 99, 255, 0.15);

  /* Status colours */
  --color-applied:   #3b82f6;
  --color-interview: #f59e0b;
  --color-offer:     #22c55e;
  --color-rejected:  #ef4444;
  --color-withdrawn: #6b7280;

  /* Feedback */
  --color-error:   #ef4444;
  --color-success: #22c55e;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;

  /* Radii & spacing */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 600;
  color: var(--color-text);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

p {
  color: var(--color-text-muted);
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

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

.btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-border);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.btn-danger {
  background: transparent;
  color: var(--color-error);
  border-color: var(--color-error);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8125rem;
}

.btn-full { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.field input,
.field textarea,
.field select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.55rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--color-text-subtle);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-dim);
}

.field input:invalid:not(:placeholder-shown) {
  border-color: var(--color-error);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238892a4' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2rem;
}

.form-error {
  min-height: 1.25rem;
  font-size: 0.8125rem;
  color: var(--color-error);
  margin-bottom: 0.5rem;
}

.form-error:empty { margin-bottom: 0; }

.form-success {
  min-height: 1.25rem;
  font-size: 0.8125rem;
  color: var(--color-success);
  margin-bottom: 0.5rem;
}

.form-success:empty { margin-bottom: 0; }

/* ── Auth page ────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  justify-content: center;
}

.auth-logo {
  font-size: 1.75rem;
  color: var(--color-accent);
  line-height: 1;
}

.auth-brand-name {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 1rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.auth-tab:hover:not(.active) {
  color: var(--color-text);
}

.auth-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.auth-panel {
  padding: 1.75rem;
}

/* ── Status badges ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.badge-applied {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-applied);
}

.badge-interview {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-interview);
}

.badge-offer {
  background: rgba(34, 197, 94, 0.15);
  color: var(--color-offer);
}

.badge-rejected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-rejected);
}

.badge-withdrawn {
  background: rgba(107, 114, 128, 0.15);
  color: var(--color-withdrawn);
}

/* ── Stats bar ────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-card.stat-total .stat-value { color: var(--color-text); }
.stat-card.stat-applied .stat-value { color: var(--color-applied); }
.stat-card.stat-interview .stat-value { color: var(--color-interview); }
.stat-card.stat-offer .stat-value { color: var(--color-offer); }
.stat-card.stat-rejected .stat-value { color: var(--color-rejected); }
.stat-card.stat-withdrawn .stat-value { color: var(--color-withdrawn); }

/* ── Filter / search bar ──────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.filter-search {
  position: relative;
}

.filter-search input {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-search input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-dim);
}

.filter-search input::placeholder {
  color: var(--color-text-subtle);
}

.filter-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-subtle);
  pointer-events: none;
  font-size: 0.9rem;
}

.filter-status {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-pill {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.filter-pill:hover {
  border-color: var(--color-border-light);
  color: var(--color-text);
}

.filter-pill.active {
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ── Application cards ────────────────────────────────────── */
.app-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  transition: border-color 0.15s;
}

.app-card:hover {
  border-color: var(--color-border-light);
}

.app-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.app-card-company {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.app-card-role {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.app-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.app-card-date {
  font-size: 0.8125rem;
  color: var(--color-text-subtle);
  font-family: var(--font-mono);
}

.app-card-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.app-card-notes {
  margin-top: 0.625rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--color-border);
  padding-top: 0.625rem;
}

.app-card-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--color-accent);
  margin-top: 0.375rem;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--color-text-muted);
  margin-bottom: 0.375rem;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  font-size: 1.0625rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--color-text);
  background: var(--color-surface-alt);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* ── Dashboard layout ─────────────────────────────────────── */
.dashboard-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.topbar-brand-icon {
  color: var(--color-accent);
  font-size: 1.25rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.user-email {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  width: 100%;
}

.dashboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.dashboard-heading h1 {
  font-size: 1.375rem;
}

/* ── Toast notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--color-text);
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  max-width: 320px;
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

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

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

.toast-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.4;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(12px); }
}

.toast.leaving {
  animation: toastOut 0.2s ease forwards;
}

/* ── Loading states ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-alt) 25%,
    var(--color-border) 50%,
    var(--color-surface-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Responsive — 640 px breakpoint ──────────────────────── */
@media (min-width: 640px) {
  .stats-bar {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-bar {
    flex-direction: row;
    align-items: center;
  }

  .filter-search {
    flex: 1;
  }

  .filter-status {
    flex-wrap: nowrap;
  }

  .app-card-header {
    align-items: center;
  }
}

@media (min-width: 900px) {
  .stats-bar {
    grid-template-columns: repeat(6, 1fr);
  }
}
