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

:root {
  /* Surfaces */
  --bg:          #F2F2F7;
  --surface:     #FFFFFF;
  --surface2:    #F2F2F7;

  /* Text */
  --label:       #1C1C1E;
  --label2:      #3C3C43;
  --label3:      #6B6B72;
  --label4:      #AEAEB2;

  /* Separators */
  --sep:         #C6C6C8;
  --sep-light:   #E5E5EA;

  /* Brand */
  --blue:        #007AFF;
  --blue-bg:     rgba(0,122,255,0.08);
  --green:       #34C759;
  --green-bg:    #E8FAF0;

  /* Type pill colors */
  --hiwi-bg:     rgba(255,149,0,0.12);
  --hiwi-text:   #A85C00;
  --werk-bg:     rgba(0,122,255,0.10);
  --werk-text:   #0051A8;
  --mini-bg:     rgba(255,59,48,0.10);
  --mini-text:   #C0001E;
  --prak-bg:     rgba(175,82,222,0.10);
  --prak-text:   #6B00B8;

  /* Spacing & shape */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout */
  --max-w: 680px;
  --bar-h: 56px;   /* app bar top row */
  --search-h: 44px;
  --filter-h: 82px; /* chips + row2 */
  --nav-h: 60px;
}

/* ════════════════════════════════════════════════
   Base
   ════════════════════════════════════════════════ */
html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  /* Prevent ANY element from making the page scroll sideways */
  overflow-x: hidden;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  min-height: 100dvh;
  width: 100%;
  overflow-x: hidden;
  /* push content above fixed bottom nav */
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* ════════════════════════════════════════════════
   App bar (sticky header)
   ════════════════════════════════════════════════ */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  /* Must be explicit so sticky doesn't expand past the viewport */
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--sep-light);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.app-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.app-logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.logo-job    { color: #FF6B00; }
.logo-hubble { color: #1C1C1E; }
.logo-aachen { color: var(--blue); }

.count-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--label3);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--sep-light);
}

/* Search bar */
.app-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 8px;
}
.search-icon {
  position: absolute;
  left: 10px;
  width: 18px;
  height: 18px;
  color: var(--label4);
  pointer-events: none;
  flex-shrink: 0;
}
#search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: 10px;
  border: 1.5px solid var(--sep-light);
  background: var(--surface2);
  font-size: 15px;
  font-family: var(--font);
  color: var(--label);
  outline: none;
  /* Remove browser-native search styling */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
}
#search-input:focus {
  border-color: var(--blue);
  background: var(--surface);
}
#search-input::placeholder { color: var(--label4); }

/* Header filters (chips + sort) — lives inside the app bar */
.header-filters {
  margin-top: 8px;
}

/* ════════════════════════════════════════════════
   Screens & routing
   ════════════════════════════════════════════════ */
.screen { display: none; }
.screen.active { display: block; }

/* ════════════════════════════════════════════════
   Filter chips + sort (now inside .app-bar, no
   separate sticky element needed)
   ════════════════════════════════════════════════ */

/* Source chip row — sits above the type chips, visually lighter */
.chip-row--source {
  margin-bottom: 2px;
}
.chip--source {
  background: transparent;
  border: 1.5px solid var(--sep);
  color: var(--label3);
  font-size: 12px;
  font-weight: 500;
}
.chip--source.active {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue);
}

/* Type chip row */
.chip-row {
  display: flex;
  gap: 7px;
  /* Chips scroll within this row — must not widen the parent */
  overflow-x: auto;
  overflow-y: visible;
  /* Constrain to parent width so chips can't push past the viewport */
  max-width: 100%;
  min-width: 0;
  scrollbar-width: none;
  padding-bottom: 2px;
  /* Smooth momentum scroll on iOS */
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  height: 32px;
  padding: 0 13px;
  border-radius: 20px;
  border: 1.5px solid var(--sep);
  background: var(--surface);
  color: var(--label2);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chip.active {
  background: var(--label);
  color: #fff;
  border-color: var(--label);
}
.chip-count {
  font-size: 12px;
  opacity: 0.55;
  font-weight: 600;
}

/* Secondary row */
.filter-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 7px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--label3);
  cursor: pointer;
}
.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--label3);
  position: relative;
}
.sort-wrap svg { flex-shrink: 0; }
#sort-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  color: var(--label3);
  cursor: pointer;
  outline: none;
  padding-right: 2px;
}

/* ════════════════════════════════════════════════
   Results label
   ════════════════════════════════════════════════ */
.results-row {
  padding: 10px 16px 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--label4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  max-width: var(--max-w);
  margin: 0 auto;
}

/* ════════════════════════════════════════════════
   Job list
   ════════════════════════════════════════════════ */
.job-list {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 8px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* ════════════════════════════════════════════════
   Job card
   ════════════════════════════════════════════════ */
.job-card {
  display: block;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 14px 14px;
  border: 1px solid var(--sep-light);
  box-shadow: 0 1px 4px rgba(0,0,0,0.055), 0 0 0 0 transparent;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}
.job-card:active {
  transform: scale(0.975);
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
@media (hover: hover) {
  .job-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-1px);
  }
}

/* Card inner layout */
.card-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* Company avatar */
.card-avatar-wrap {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}
.card-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: hsl(var(--avatar-hue, 220), 52%, 46%);
  color: rgba(255,255,255,0.95);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.card-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  object-fit: contain;
  background: #f5f5f5;
  padding: 5px;
  display: block;
  border: 1px solid var(--sep-light);
}

/* Card text area */
.card-content {
  flex: 1;
  min-width: 0;
}
.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: space-between;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.1px;
  /* Break long words (e.g. email addresses in job titles) */
  overflow-wrap: break-word;
  word-break: break-word;
}
.card-company {
  margin-top: 3px;
  font-size: 13px;
  color: var(--label3);
  /* Use truncation instead of nowrap so it never overflows */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.card-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.card-source {
  font-size: 11px;
  color: var(--label4);
  font-weight: 500;
}
.card-time {
  font-size: 11px;
  color: var(--label4);
}
.card-time::before { content: "· "; }
.card-desc {
  margin-top: 7px;
  font-size: 13px;
  color: var(--label3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Type pills */
.type-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: 0.1px;
}
.pill-HiWi       { background: var(--hiwi-bg); color: var(--hiwi-text); }
.pill-Werkstudent{ background: var(--werk-bg);  color: var(--werk-text); }
.pill-Minijob    { background: var(--mini-bg);  color: var(--mini-text); }
.pill-Praktikum  { background: var(--prak-bg);  color: var(--prak-text); }

/* "Neu" badge */
.badge-new {
  font-size: 10px;
  font-weight: 700;
  color: #1A7F3C;
  background: var(--green-bg);
  padding: 1px 6px;
  border-radius: 6px;
  letter-spacing: 0.2px;
}

/* ════════════════════════════════════════════════
   Loading & empty states
   ════════════════════════════════════════════════ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 20px;
  gap: 14px;
  color: var(--label3);
  font-size: 15px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--sep-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 72px 20px 40px;
  color: var(--label3);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 18px; font-weight: 600; margin-bottom: 6px; color: var(--label2); }
.empty-state small { font-size: 14px; }

.hidden { display: none !important; }

/* ════════════════════════════════════════════════
   Pagination
   ════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 16px 12px;
  max-width: var(--max-w);
  margin: 0 auto;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--sep-light);
  background: var(--surface);
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover { background: var(--blue-bg); border-color: var(--blue); }
.page-btn.current {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  cursor: default;
}
.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}
.page-btn:disabled:hover { background: var(--surface); border-color: var(--sep-light); }
.page-ellipsis {
  font-size: 14px;
  color: var(--label4);
  padding: 0 2px;
  line-height: 38px;
}

/* ════════════════════════════════════════════════
   Alerts screen
   ════════════════════════════════════════════════ */
.alerts-screen {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.alerts-hero {
  text-align: center;
}
.alerts-icon { font-size: 52px; margin-bottom: 12px; }
.alerts-hero h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.5px; }
.alerts-hero p { font-size: 15px; color: var(--label3); line-height: 1.55; max-width: 320px; margin: 0 auto; }

.alerts-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 22px;
  border: 1px solid var(--sep-light);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--label2);
  margin-bottom: 8px;
}
#alert-email {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--sep-light);
  font-size: 16px;
  font-family: var(--font);
  color: var(--label);
  outline: none;
  background: var(--surface2);
  transition: border-color 0.15s;
  margin-bottom: 12px;
}
#alert-email:focus {
  border-color: var(--blue);
  background: var(--surface);
}
.btn-primary {
  width: 100%;
  height: 46px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.85; }

.alert-success {
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: #1A7F3C;
  margin-top: 4px;
  line-height: 1.5;
}

/* Sources list */
.alerts-sources {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 20px 22px;
  border: 1px solid var(--sep-light);
}
.alerts-sources h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--label);
}
.alerts-sources ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.alerts-sources li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--label2);
}
.src-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sources-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--label4);
}

/* ════════════════════════════════════════════════
   Bottom navigation
   ════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: flex;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-top: 0.5px solid var(--sep-light);
  /* safe area for iPhone X+ notch */
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--label4);
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font);
  letter-spacing: 0.2px;
  transition: color 0.15s;
  padding-bottom: 2px;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.8;
}
.nav-item.active { color: var(--blue); }
.nav-item.active svg { stroke-width: 2.2; }

/* ════════════════════════════════════════════════
   Desktop tweaks (≥ 600px)
   ════════════════════════════════════════════════ */
@media (min-width: 600px) {
  /* App bar spans full viewport width naturally — no centering transforms */
  .app-bar {
    padding-left: max(24px, calc((100vw - var(--max-w)) / 2));
    padding-right: max(24px, calc((100vw - var(--max-w)) / 2));
  }
  .job-list { padding: 10px 16px 6px; }
  .card-avatar-wrap { width: 48px; height: 48px; }
  .card-avatar { width: 48px; height: 48px; font-size: 17px; border-radius: var(--r-md); }
  .card-logo   { width: 48px; height: 48px; border-radius: var(--r-md); }
  .card-title { font-size: 15.5px; }
}
