/* Custom CSS for Elezioni Trasparenti - Centrodestra per il Salento */

/* Design Tokens & CSS Variables */
:root {
  --primary-color: #063263;      /* Blu istituzionale */
  --accent-color: #2298D0;       /* Blu mare */
  --warning-color: #F4A900;      /* Giallo sole */
  --success-color: #138C3D;      /* Verde tricolore */
  --danger-color: #D71920;       /* Rosso tricolore */
  
  --bg-primary: #F7FAFC;
  --bg-card: #FFFFFF;
  --text-main: #102033;
  --text-muted: #475569;
  
  --border-color: #E2E8F0;
  --focus-ring-color: #2298D0;
  
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(6, 50, 99, 0.05), 0 4px 6px -2px rgba(6, 50, 99, 0.03);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Screen Reader Only Utility */
.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;
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  top: -60px;
  left: 20px;
  background-color: var(--accent-color);
  color: white;
  padding: 10px 20px;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--primary-color);
}

/* Header Styles */
.site-header {
  background-color: var(--primary-color);
  color: white;
  padding: 3rem 0;
  border-bottom: 5px solid var(--accent-color);
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(34, 152, 208, 0.15) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
}

.header-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2rem;
}

@media (min-width: 768px) {
  .header-container {
    flex-direction: row;
    text-align: left;
    gap: 3rem;
  }
}

.logo-wrapper {
  background-color: white;
  padding: 1rem;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}

.site-logo {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.header-text {
  flex-grow: 1;
}

.badge {
  display: inline-block;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--accent-color);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.site-header h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .site-header h1 {
    font-size: 3rem;
  }
}

.subtitle {
  font-size: 1.1rem;
  color: #E2E8F0;
  max-width: 800px;
}

/* Main Content Layout */
.main-content {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

/* Intro Section */
.intro-section {
  margin-bottom: 2.5rem;
}

.normative-text {
  font-size: 1.15rem;
  color: var(--text-main);
  background-color: white;
  padding: 1.5rem 2rem;
  border-radius: var(--radius-md);
  border-left: 5px solid var(--accent-color);
  box-shadow: var(--shadow-md);
}

/* Box Adempimenti */
.adempimenti-section {
  margin-bottom: 3rem;
}

.card-adempimenti {
  background-color: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.card-adempimenti h2 {
  font-family: var(--font-display);
  color: var(--primary-color);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 992px) {
  .timeline {
    grid-template-columns: repeat(4, 1fr);
  }
}

.timeline-item {
  position: relative;
  background-color: var(--bg-primary);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border-top: 4px solid var(--accent-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timeline-item.highlight {
  border-top-color: var(--warning-color);
  background-color: #FFFDF5;
}

.timeline-date {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 0.95rem;
  text-transform: uppercase;
}

.timeline-item.highlight .timeline-date {
  color: #B27B00;
}

.timeline-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Search Bar Section */
.search-section {
  margin-bottom: 2.5rem;
}

.search-box {
  background-color: white;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.search-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

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

.search-icon {
  position: absolute;
  left: 1rem;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  font-size: 1.05rem;
  font-family: var(--font-body);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  color: var(--text-main);
  transition: all var(--transition-fast);
}

#search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background-color: white;
  box-shadow: 0 0 0 4px rgba(34, 152, 208, 0.15);
}

#clear-button {
  position: absolute;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color var(--transition-fast);
}

#clear-button:hover, #clear-button:focus {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--primary-color);
  outline: none;
}

.search-help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Alert fallback */
.alert-info {
  background-color: rgba(34, 152, 208, 0.1);
  border: 1px solid rgba(34, 152, 208, 0.3);
  color: var(--primary-color);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* Candidates Section Table & Cards Styles */
.section-title {
  font-family: var(--font-display);
  color: var(--primary-color);
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.no-results-card {
  text-align: center;
  background-color: white;
  padding: 3rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.no-results-card svg {
  width: 3rem;
  height: 3rem;
  color: var(--accent-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary {
  background-color: var(--primary-color);
  color: white;
}

.btn-secondary:hover, .btn-secondary:focus {
  background-color: var(--accent-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 152, 208, 0.25);
}

/* Desktop Table View */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background-color: white;
  border: 1px solid var(--border-color);
}

.candidates-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.candidates-table th {
  background-color: var(--primary-color);
  color: white;
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  font-family: var(--font-display);
}

.candidates-table td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.candidates-table tbody tr:last-child td {
  border-bottom: none;
}

.candidates-table tbody tr {
  transition: background-color var(--transition-fast);
}

.candidates-table tbody tr:hover {
  background-color: rgba(34, 152, 208, 0.03);
}

.cell-num {
  font-weight: 700;
  color: var(--accent-color);
}

.col-num {
  width: 60px;
}

.col-name {
  width: 300px;
}

.col-birth {
  width: 300px;
}

.col-doc {
  width: 250px;
}

/* Custom Buttons/Links to PDF downloads */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #EFF6FF;
  border: 1.5px solid #BFDBFE;
  color: #1E40AF;
  text-decoration: none;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  width: 100%;
  justify-content: center;
}

.btn-download.btn-casellario {
  background-color: #FEF2F2;
  border-color: #FEE2E2;
  color: #991B1B;
}

.btn-download:hover, .btn-download:focus {
  background-color: #2563EB;
  border-color: #2563EB;
  color: white;
  outline: none;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-download.btn-casellario:hover, .btn-download.btn-casellario:focus {
  background-color: #DC2626;
  border-color: #DC2626;
  color: white;
  box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.2);
}

/* Mobile responsive transforms */
@media (max-width: 991px) {
  /* Hide the standard table header */
  .candidates-table thead {
    display: none;
  }
  
  .table-responsive {
    background-color: transparent;
    border: none;
    box-shadow: none;
  }

  .candidates-table,
  .candidates-table tbody,
  .candidates-table tr,
  .candidates-table td {
    display: block;
    width: 100%;
  }

  .candidates-table tr {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    transition: transform var(--transition-normal);
  }

  .candidates-table tr:hover {
    transform: translateY(-2px);
    background-color: white;
  }

  .cell-num {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.25rem;
  }

  .cell-name {
    font-size: 1.25rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
  }

  .cell-birth {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    padding: 0 !important;
  }
  
  .cell-birth::before {
    content: "Luogo e data di nascita: ";
    font-weight: 600;
    color: var(--text-main);
  }

  .cell-doc {
    padding: 0.35rem 0 !important;
    border: none !important;
  }
}

/* Footer Section */
.site-footer {
  background-color: #0B192C;
  color: #94A3B8;
  padding: 3rem 0;
  text-align: center;
  font-size: 0.9rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.footer-update {
  font-weight: 500;
  color: white;
}

.footer-legal {
  max-width: 600px;
  line-height: 1.5;
}

/* Print CSS */
@media print {
  body {
    background-color: white;
    color: black;
    font-size: 12pt;
  }
  
  .site-header {
    background: none !important;
    color: black !important;
    border-bottom: 2px solid black !important;
    padding: 1rem 0 !important;
  }

  .site-header::before {
    display: none;
  }

  .logo-wrapper {
    box-shadow: none !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
  }

  .site-logo {
    max-width: 100px;
  }

  .badge, .skip-link, .search-section, noscript, .btn-download .btn-icon {
    display: none !important;
  }

  .main-content {
    padding: 0 !important;
  }

  .card-adempimenti {
    border: 1px solid black !important;
    box-shadow: none !important;
    padding: 1rem !important;
  }

  .timeline {
    display: block !important;
  }

  .timeline-item {
    border: none !important;
    border-bottom: 1px dashed #ccc !important;
    padding: 0.5rem 0 !important;
    background: none !important;
  }

  .table-responsive {
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }

  .candidates-table {
    display: table !important;
    width: 100% !important;
  }

  .candidates-table thead {
    display: table-header-group !important;
  }

  .candidates-table tr {
    display: table-row !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .candidates-table td, .candidates-table th {
    display: table-cell !important;
    border-bottom: 1px solid black !important;
    padding: 0.5rem !important;
    color: black !important;
    background: none !important;
  }

  .candidates-table th {
    font-weight: 700 !important;
  }

  .btn-download {
    border: none !important;
    background: none !important;
    color: black !important;
    padding: 0 !important;
    text-decoration: underline !important;
  }

  .btn-download .btn-text::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
  }

  .site-footer {
    border-top: 1px solid black !important;
    background: none !important;
    color: black !important;
    margin-top: 2rem !important;
    padding: 1rem 0 !important;
  }
}
