/*
  Global colour palette
  ---------------------
  Updated with gradients for a more modern look.
*/

:root {
  /* Core colours */
  --primary: #0033ad;
  --primary-light: #1a5dd6;
  --primary-dark: #00227a;
  --accent: #00a3c4;
  
  /* Gradients */
  --primary-gradient: linear-gradient(135deg, #0033ad 0%, #1a5dd6 100%);
  --header-gradient: linear-gradient(135deg, #0033ad 0%, #0055e6 100%);
  --btn-gradient: linear-gradient(135deg, #0033ad 0%, #00a3c4 100%);
  --btn-hover-gradient: linear-gradient(135deg, #00227a 0%, #008ba3 100%);

  --background: #f5f9ff;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #d4dce8;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Base styling */
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--background);
  color: var(--text-dark);
  line-height: 1.5;
}

/* Layout containers */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Site header */
.site-header {
  background: var(--header-gradient); /* UPDATED: Now uses the gradient */
  color: #fff;
  padding: 1rem 0;
  box-shadow: var(--shadow-md);
}
.site-header .site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header .site-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}
header h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--primary);
  /* Optional: Gradient text for the main title */
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; 
  background-clip: text;
  color: transparent; /* Fallback */
  display: inline-block;
}
/* Fallback for browsers that don't support text-fill-color well with specific setups */
@supports not (-webkit-background-clip: text) {
  header h1 {
    background: none;
    color: var(--primary);
  }
}

header h2 {
  margin: 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-dark);
}
.subtitle {
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--text-muted);
}

/* Guide */
.guide {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; /* Softer corners */
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
}
.guide h3 {
    color: var(--primary);
    border-bottom: 2px solid var(--surface-alt);
    padding-bottom: 0.5rem;
    margin-top: 0;
}
.guide h4 {
    color: var(--primary-dark);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}
.guide ul {
    padding-left: 1.5rem;
}
.guide li {
    margin-bottom: 0.25rem;
}

/* Form type switcher */
.form-switch {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  justify-content: center;
}

.form-switch button {
  flex: 1 1 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--primary-dark);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.form-switch button:hover {
  background-color: var(--surface-alt);
  transform: translateY(-1px);
}
.form-switch button.active {
  background: var(--btn-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-md);
}
/* Disabled state for switcher */
.form-switch button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Messages */
.messages {
  margin-bottom: 1rem;
  min-height: 1.5rem; /* Prevent jump */
}

.messages .error,
.messages .success {
  padding: 0.75rem;
  border-radius: 6px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.messages .error {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.messages .success {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* Form */
form .form-group {
  margin-bottom: 1.25rem;
}

form label {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.4rem;
  color: #334155;
}

form input,
form textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background-color: var(--surface);
  color: var(--text-dark);
  box-sizing: border-box; /* Important for width: 100% */
}

form input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin-right: 0.5rem;
  cursor: pointer;
  accent-color: var(--primary);
  vertical-align: middle;
}

form input:focus,
form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 51, 173, 0.1);
}

form input:disabled {
  background-color: var(--surface-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

form textarea {
  resize: vertical;
}

form .char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  float: right;
  margin-top: -1.5rem; /* Visually align with label line if needed, or just float */
  margin-right: 0;
}

form .helper-text {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.35rem;
}

/* --- NEW: Filter and Search Controls --- */
.filter-controls {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping on small screens */
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background-color: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.search-bar {
  flex-grow: 1;
  min-width: 250px;
}

.search-bar input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  box-sizing: border-box;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 51, 173, 0.1);
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap; /* Allow buttons to wrap */
}

.filter-buttons .btn {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
}

.filter-buttons .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
/* --- End Filter/Search Styles --- */


/* Candidate cards on candidates page */
.applications-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.candidate-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
/* Decorative stripe on top of cards */
.candidate-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.candidate-card:hover::before {
    opacity: 1;
}

.candidate-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--primary-light);
}
.candidate-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
}
.candidate-type {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.candidate-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-family: monospace;
  background: var(--surface-alt);
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Modal overlay */
.hidden {
  display: none !important;
}
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6); /* Darker backdrop */
  backdrop-filter: blur(4px); /* Nice blur effect */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-content {
  background-color: var(--surface);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.success-modal-content {
  border-top: 6px solid #16a34a;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary-dark);
}
.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}
.modal-close:hover {
  color: var(--text-dark);
}
.modal-details .detail {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.6;
}
.modal-details .detail span {
  font-weight: 600;
  color: var(--primary-dark);
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.1rem;
}

/* Member card inside modal/form */
.member-card {
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.member-card h4 {
    margin-top: 0;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: var(--btn-gradient);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.btn:hover {
  background: var(--btn-hover-gradient);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active {
    transform: translateY(0);
}

.btn.secondary {
  background: transparent;
  background-color: #fff;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn.secondary:hover {
  background-color: var(--surface-alt);
  color: var(--primary-dark);
  border-color: var(--primary);
}

/* Top navigation */
.top-nav {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}
.top-nav a {
  padding: 0.5rem 1.5rem;
  border-radius: 20px; /* Pill shape */
  background-color: transparent;
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.top-nav a:hover {
  background-color: var(--surface-alt);
  color: var(--primary);
}
.top-nav a.active {
  background-color: #e0e7ff; /* Very light blue */
  color: var(--primary);
  border-color: #c7d2fe;
}

/* --- New Styles for Candidate Detail Page --- */
.candidate-details-section {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow-sm);
}

.candidate-details-section .detail {
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.6;
  overflow-wrap: break-word; /* --- THIS IS THE FIX --- */
}
.candidate-details-section .detail span {
  font-weight: 600;
  color: var(--primary-dark);
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

/* Style for links within details */
.candidate-details-section .detail a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.candidate-details-section .detail a:hover {
    text-decoration: underline;
}

/* Style for pre-formatted (textarea) content */
.candidate-details-section .detail pre {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.95rem;
    margin: 0;
    color: var(--text-dark);
    line-height: 1.6;
}

/* Grid for short details */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

/* Section headers for long-form content */
.detail-section-header {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 2px solid var(--surface-alt);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* Member cards on detail page */
.candidate-details-section .member-card {
    background-color: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
}
.candidate-details-section .member-card h5 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-dark);
    font-size: 1.1rem;
}
.candidate-details-section .member-card .detail {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.candidate-details-section .member-card .detail span {
    font-size: 0.75rem;
    color: var(--text-muted);
}
/* --- End New Styles --- */


/* Timeline styles for the guide */
.timeline {
    list-style: none;
    padding: 0;
    border-left: 2px solid var(--border);
    margin-left: 1rem;
}
.timeline li {
    margin-bottom: 1rem;
    padding-left: 1rem;
    position: relative;
}
.timeline li::before {
    content: "";
    position: absolute;
    left: -0.4rem;
    top: 0.4rem;
    width: 0.7rem;
    height: 0.7rem;
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 50%;
}

/* Edit Mode Banner */
.edit-banner {
    background-color: #fffbeb;
    color: #b45309;
    padding: 1rem 1.5rem;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
}
