/* ============================================
   css/candidates.css
   Candidates page — Mobile First
   Matches project design system (global.css)
   ============================================ */

/* ---------- Page Layout ---------- */
.candidates-page {
  padding: var(--gap-md);
  max-width: 1280px;
  margin: 0 auto;
}

@media (min-width: 577px) {
  .candidates-page {
    padding: var(--gap-lg);
  }
}

@media (min-width: 993px) {
  .candidates-page {
    padding: var(--gap-lg) var(--gap-xl);
  }
}

/* ---------- Page Header ---------- */
.candidates-header {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin-bottom: 15px;
}

@media (min-width: 577px) {
  .candidates-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.candidates-header__title {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--color-dark);
}

.candidates-header__count {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  display: inline-block;
}

/* ---------- Search Bar ---------- */
.candidates-search {
  position: relative;
  margin-bottom: var(--gap-md);
}

.candidates-search__input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-md);
  font-family: inherit;
  background: var(--color-white);
  color: var(--color-dark);
  outline: none;
  transition: border-color 0.2s ease;
}

.candidates-search__input:focus {
  border-color: var(--color-primary);
}

.candidates-search__input::placeholder {
  color: var(--color-muted);
}

.candidates-search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* ---------- Filter Tabs ---------- */
.candidates-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: var(--gap-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.candidates-tabs::-webkit-scrollbar {
  display: none;
}

.candidates-tab {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: #F8E0DB;
  color: #E54B2A;
  font-size: var(--font-md);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.candidates-tab--active {
  background: var(--color-white);
  border-color: #E54B2A;
  color: #E54B2A;
  box-shadow: 0 2px 8px rgba(229, 75, 42, 0.15);
}

.candidates-tab:hover:not(.candidates-tab--active) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ---------- Cards Grid ---------- */
/* MOBILE: 2 cards per row */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-sm);
  padding-top: 30px;
  background-color: white;
  border-radius: 10px;
  height: 500px;
  overflow-y: auto; 
}

/* TABLET: 3 cards per row */
@media (min-width: 577px) {
  .candidates-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap-md);
  }
}

/* LAPTOP: 4 cards per row */
@media (min-width: 993px) {
  .candidates-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap-md);
  }
}

/* WIDE: 5 cards per row */
@media (min-width: 1200px) {
  .candidates-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ---------- Candidate Card ---------- */
.candidate-card {
  position: relative;
  margin-top: 90px;
  border-radius: var(--radius-lg);
  overflow: visible;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: cardFadeIn 0.25s ease both;
}

.candidate-card:hover {
  transform: translateY(-2px);
}

/* ---------- Floating oval photo — overflows above card ---------- */
.candidate-card__photo-wrap {
  position: absolute;
  bottom:100px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 148px;
  border-radius: 80px;
  overflow: hidden;
  background:transparent;
  z-index: 1;
}

.candidate-card__photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.candidate-card:hover .candidate-card__photo-wrap {
  box-shadow: 4px 4px 4px 0px #00000040; 
}
/* ---------- Card body — alliance/party colour background ---------- */
.candidate-card__body {
  width: 182px;
  height: 176px;
  border-radius:8px;
  color: black;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-top: 64px;
  overflow: hidden;
  transition: box-shadow 0.15s ease;  
}
.candidate-card:hover .candidate-card__body {
  box-shadow: 4px 4px 4px 0px #00000040; 
}

/* ---------- Footer — name, constituency, bar ---------- */
.candidate-card__footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.candidate-card__name {
  font-size: var(--font-sm);
  font-weight: 700;
  margin: 0 0 3px;
  padding: 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.candidate-card__constituency {
  font-size: var(--font-xs);
  font-weight: 600;
  margin: 0 0 10px;
  opacity: 0.8;
}

/* ---------- Party logo circle — bottom-left of bar ---------- */
.candidate-card__logo-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background:white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.candidate-card__logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
}

/* ---------- Party name bar at bottom ---------- */
.candidate-card__party-bar {
  width: 100%;
  height: 32px;
  font-size: var(--font-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
}

/* ---------- Empty / Loading States ---------- */
.candidates-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--gap-xl);
  color: var(--color-muted);
  font-size: var(--font-md);
  font-weight: 600;
}

.candidates-coming-soon {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-md);
  padding: 60px var(--gap-lg);
  color: var(--color-muted);
}

.candidates-coming-soon__icon {
  font-size: 48px;
  line-height: 1;
}

.candidates-coming-soon__text {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--color-dark);
}

.candidates-coming-soon__sub {
  font-size: var(--font-md);
  color: var(--color-muted);
}

/* ---------- Card enter animation ---------- */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.candidate-card {
  animation: cardFadeIn 0.25s ease both;
}

/*
/* ============================================
   Candidate Detail Popup — Figma Design
   ============================================ */

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-md);
  animation: popupFadeIn 0.2s ease both;
}
.popup-overlay--closing { animation: popupFadeOut 0.22s ease both; }
@keyframes popupFadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes popupFadeOut { from { opacity:1 } to { opacity:0 } }

/* Modal box */
.popup-modal {
  background: #f0f4f8;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  animation: popupSlideUp 0.22s ease both;
}
@keyframes popupSlideUp {
  from { transform: translateY(24px); opacity:0 }
  to   { transform: translateY(0);    opacity:1 }
}

/* Header */
.popup-header {
  display: flex;
  align-items: center;
  padding: 12px var(--gap-md);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.popup-header__title { font-size: var(--font-lg); font-weight: 800; color: var(--color-dark); }
.popup-header__back{
  background: none;
  border: none; 
  cursor: pointer; 
  padding: 4px;
  color: var(--color-dark); 
  display: flex; align-items: center;
  border-radius: var(--radius-sm); 
  transition: background 0.15s;
}
.popup-header__close {
  background: none;
  border: none; 
  cursor: pointer; 
  padding: 4px;
  margin-left: 500px;
  color: var(--color-dark); 
  display: flex; align-items: center;
  border-radius: var(--radius-sm); 
  transition: background 0.15s;
}
.popup-header__back:hover, .popup-header__close:hover { background: var(--color-bg); }
.popup-header__back svg, .popup-header__close svg { width: 22px; height: 22px; }

/* Scrollable body */
.popup-body {
  overflow-y: auto;
  flex: 1;
  padding: var(--gap-md);
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  -webkit-overflow-scrolling: touch;
}

/* ── TOP ROW: left panel + right competitors ── */
.popup-top-row {
  display: flex;
  gap: var(--gap-md);
  align-items: stretch;
}

/* LEFT PANEL */
.popup-left {
  display: flex;
  gap: var(--gap-md);
  background:transparent;
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  flex-shrink: 0;
  align-items: flex-start;
  min-width: 0;
}

.popup-main__photo-wrap {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: #e2e8f0;
}
.popup-main__photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}
.popup-main__photo-placeholder { width: 100%; height: 100%; }

.popup-main__info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.popup-main__name {
  font-size: 28px;
  font-family: 'Inter',sans-serif;
  font-weight: 900;
  line-height: 1.15;
  margin: 0;
}
.popup-main__constituency-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 4px;
  font-size: var(--font-xs);
  font-weight: 900;
  letter-spacing: 0.05em;
  width: fit-content;
}
.popup-main__party {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-muted);
}
.popup-main__contesting {
  font-size: var(--font-sm);
  font-weight: 700;
}

/* Wins / Losses bar */
.popup-wins-wrap { margin-top: 4px; }
.popup-wins-label {
  font-size: var(--font-xs);
  color: var(--color-muted);
  font-weight: 600;
  margin-bottom: 3px;
}
.popup-wins-counts {
  display: flex;
  gap: var(--gap-md);
  margin-bottom: 6px;
}
.popup-wins-w {
  font-size: var(--font-lg);
  font-weight: 900;
  color: #16a34a;
}
.popup-wins-l {
  font-size: var(--font-md);
  font-weight: 700;
  color: #ef4444;
}
.popup-wins-bar {
  height: 6px;
  border-radius: 3px;
  background: #fca5a5;
  width: 180px;
  max-width: 100%;
  overflow: hidden;
}
.popup-wins-bar__fill {
  height: 100%;
  background: #16a34a;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* RIGHT PANEL — competitors */
.popup-right {
  flex: 1;
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}
.popup-competitors__title {
  font-size: var(--font-md);
  font-weight: 800;
  color: var(--color-dark);
  flex-shrink: 0;
}
.popup-competitors__scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.popup-competitors__scroll::-webkit-scrollbar { height: 4px; }
.popup-competitors__scroll::-webkit-scrollbar-track { background: var(--color-bg); border-radius: 2px; }
.popup-competitors__scroll::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
.popup-competitors__empty { font-size: var(--font-sm); color: var(--color-muted); padding: var(--gap-sm); }

/* ── Competitor mini-card (matches candidate card style) ── */
.pcomp-card {
  flex-shrink: 0;
  height: 136px;
  width: 136px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin-top: 42px;
  border-radius: var(--radius-md);
  cursor: default;
}

.pcomp-card__photo-wrap {
  position: absolute;
  bottom: 82px; /* sits above body */
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 86px;
  border-radius: 40px;
  overflow: hidden;
  background: #e2e8f0;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.pcomp-card__body {
  width: 100%;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-top: 50px;
  overflow: hidden;
  position: relative;
  height: 150px;
}

.pcomp-card__name {
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  padding: 0 6px;
  margin: 0 0 2px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}
.pcomp-card__const {
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 8px;
  opacity: 0.85;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Party logo circle — bottom-left */
.pcomp-card__logo {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  z-index: 1;
}

/* Party name bar */
.pcomp-card__bar {
  width: 100%;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Details grid (bottom) ── */
.popup-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-md);
}
@media (max-width: 576px) {
  .popup-details-grid { grid-template-columns: 1fr; }
  .popup-top-row { flex-direction: column; }
  .popup-wins-bar { width: 100%; }
}

.popup-details-col {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.popup-details__heading {
  font-size: var(--font-md);
  font-weight: 800;
  color: var(--color-dark);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.popup-details__row {
  display: flex;
  gap: 8px;
  font-size: var(--font-sm);
  line-height: 1.5;
  align-items: flex-start;
}
.popup-details__label {
  font-weight: 700;
  color: var(--color-dark);
  min-width: 110px;
  flex-shrink: 0;
}
.popup-details__value {
  color: var(--color-muted);
  font-weight: 600;
  word-break: break-word;
}

/* ============================================
   POPUP — Additional Sections (Image 1 additions)
   ============================================ */

/* Fix: global img height:auto override */
.popup-main__photo-wrap img,
.pcomp-card__photo-wrap img { width:100%; height:100%; object-fit:cover; object-position:top center; display:block; }

/* Section title (About, Additional Details, Election History) */
.popup-section-title {
  font-size: var(--font-md);
  font-weight: 800;
  color: var(--color-dark);
  margin-bottom: var(--gap-sm);
}

/* ── ABOUT ── */
.popup-about-wrap {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
}
.popup-about-text {
  font-size: var(--font-sm);
  color: var(--color-muted);
  line-height: 1.7;
  margin: 0;
}

/* ── ADDITIONAL DETAILS ── */
.popup-additional-section {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
}
.popup-additional-box {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}
.popup-add-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  flex-wrap: wrap;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--gap-sm) var(--gap-md);
}

/* Contested constituencies pills */
.popup-add__const-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.popup-add__const-pill {
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid #6172F3;
  font-size: var(--font-xs);
  font-weight: 700;
  color: #6172F3;
  background: #f0f2ff;
  white-space: nowrap;
}

/* Cases count */
.popup-add__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.popup-add__stat-label {
  font-size: var(--font-xs);
  color: var(--color-muted);
  font-weight: 600;
}
.popup-add__stat-val {
  font-size: var(--font-xl);
  font-weight: 900;
  color: var(--color-dark);
}

/* Social media icons */
.popup-add__sm-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.popup-add__social {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  text-decoration: none;
}
.popup-add__social:hover { opacity: 0.8; }
.popup-add__social--tw { background: #000; color: #fff; }
.popup-add__social--ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); color: #fff; }
.popup-add__social--fb { background: #1877F2; color: #fff; }
.popup-add__social svg { width: 16px; height: 16px; }

/* ── ELECTION HISTORY TABLE ── */
.popup-hist-wrap {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--gap-md);
}
.popup-hist-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.popup-hist-scroll::-webkit-scrollbar { display: none; }
.popup-hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}
.popup-hist__th {
  text-align: left;
  font-weight: 800;
  color: var(--color-dark);
  padding: 8px 12px;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  background: var(--color-bg);
}
.popup-hist__td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-weight: 600;
  white-space: nowrap;
}
.popup-hist__result {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 700;
}
.popup-hist__won  { background: #dcfce7; color: #166534; }
.popup-hist__lost { background: #fee2e2; color: #991b1b; }
.popup-hist__other { background: #f1f5f9; color: var(--color-muted); }