/*======================================
=           CSS Variables              =
======================================*/
:root {
  --primary-color: #3a86ff;
  --secondary-color: #ff006e;
  --light-bg: #f8f9fa;
  --dark-text: #2b2d42;
  --accent-color: #8338ec;
  --success-color: #38b000;
  --border-radius: 25px;
  --card-shadow: 0 10px 20px rgba(0, 0, 0, 0.08), 0 6px 6px rgba(0, 0, 0, 0.12);
  --transition-speed: 0.3s;
  
  /* Kolory partii z lepszym kontrastem */
  --td-color: #FFFF00;
  --nl-color: #FF0000;
  --pis-color: #000080;
  --konf-color: #8B4513;
  --ko-color: #FFA500;
  --rz-color: #a10249;
  --poz-color: #808080;
}

/*======================================
=           Global Styles              =
======================================*/
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: var(--light-bg);
  background-image: linear-gradient(to right, #c19dadc1, #dfb0b0bb, #eadcc3cc, #ebebcacb, #999089d8, #a2a2c2de);
  color: var(--dark-text);
  line-height: 1.6;
}

/*======================================
=      Utility Classes & Animations    =
======================================*/
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes loading {
  0% { left: -100%; }
  100% { left: 100%; }
}

.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: loading 1.5s infinite;
}

/*======================================
=            Header & Logo             =
======================================*/
.author-signature {
  border-radius: var(--border-radius);
  background-image: var(--light-bg);
}

.header-logo {
  display: block;
  margin: 20px auto 0;
  max-width: 20%;
  height: auto;
  animation: none !important;
}

@media (max-width: 600px) {
  .header-logo {
    max-width: 50%;
  }
}

/*======================================
=         Container & Layout           =
======================================*/
.container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  animation: fadeIn 1s ease-in-out;
}

/*======================================
=         Section Styling              =
======================================*/
.sliders-section,
.chart-section,
.map-section,
.details-section,
.coalitions-section,
.party-section {
  background-color: white;
  padding: 24px;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
  position: relative;
  overflow: hidden;
}

.sliders-section:hover,
.chart-section:hover,
.map-section:hover,
.details-section:hover,
.coalitions-section:hover,
.party-section:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12), 0 8px 8px rgba(0, 0, 0, 0.08);
}

.sliders-section::before,
.chart-section::before,
.map-section::before,
.details-section::before,
.coalitions-section::before,
.party-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(to right, #be5484, #fb6262, #fac563, #f8f867, #7d5437, #5b5bd8);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

/*======================================
=            Grid Rows               =
======================================*/
.row {
  display: grid;
  gap: 24px;
  transition: all var(--transition-speed);
}

#row1 {
  grid-template-columns: repeat(3, 1fr);
}

#row2 {
  grid-template-columns: repeat(2, 1fr);
}

#row3,
#row4 {
  grid-template-columns: 1fr;
}

/*======================================
=            Headings                =
======================================*/
h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 25px;
  font-weight: 600;
  color: var(--dark-text);
  letter-spacing: -0.5px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 8px;
}

/*======================================
=         Slider Controls            =
======================================*/
.slider-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.slider-row:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.slider-row label {
  width: 120px;
  flex-shrink: 0;
  font-weight: 500;
  font-size: 14px;
  opacity: 0.85;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 8px;
  margin-right: 12px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  outline: none;
  transition: opacity 0.2s;
}

input[type="range"]:hover {
  opacity: 0.9;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  border: 2px solid white;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="text"] {
  width: 28px;
  margin-right: 10px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border 0.2s;
  text-align: center;
}

input[type="text"]:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(58, 255, 104, 0.1);
}

.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  margin-right: 0;
}

.slider-row input[type="text"] {
  width: 35px;
  flex-shrink: 0;
  text-align: center;
  margin-right: 0;
}

.slider-row select {
  width: 45px;
  flex-shrink: 0;
}

select {
  padding: 6px 2px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background-color: white;
  transition: border 0.2s;
  cursor: pointer;
}

select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.1);
}

/*======================================
=          Canvas & Charts             =
======================================*/
canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: none;
}

#constituency-chart {
  width: 100%;
  max-height: 200px;
  transition: transform 0.3s ease;
}

#constituency-chart:hover {
  transform: scale(1.01);
}

/*======================================
=            Map Styling               =
======================================*/
#map {
  width: 100%;
  height: auto;
  overflow: visible;
  transition: filter 0.3s;
}

#party-map {
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
  transition: transform 0.3s;
}

#map svg,
#party-map svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

#map path,
#party-map path {
  transition: fill 0.3s, stroke-width 0.3s;
}

#map path:hover,
#party-map path:hover {
  stroke-width: 2;
}

/*======================================
=           Party Sliders              =
======================================*/
#td-slider {
  background: linear-gradient(to right, rgba(255, 255, 0, 0.3), rgba(255, 255, 0, 0.8));
}

#td-slider::-webkit-slider-thumb {
  background: var(--td-color);
}

#nl-slider {
  background: linear-gradient(to right, rgba(255, 0, 0, 0.3), rgba(255, 0, 0, 0.8));
}

#nl-slider::-webkit-slider-thumb {
  background: var(--nl-color);
}

#pis-slider {
  background: linear-gradient(to right, rgba(0, 0, 128, 0.3), rgba(0, 0, 128, 0.8));
}

#pis-slider::-webkit-slider-thumb {
  background: var(--pis-color);
}

#konf-slider {
  background: linear-gradient(to right, rgba(139, 69, 19, 0.3), rgba(139, 69, 19, 0.8));
}

#konf-slider::-webkit-slider-thumb {
  background: var(--konf-color);
}

#ko-slider {
  background: linear-gradient(to right, rgba(255, 165, 0, 0.3), rgba(255, 165, 0, 0.8));
}

#ko-slider::-webkit-slider-thumb {
  background: var(--ko-color);
}

#rz-slider {
  background: linear-gradient(to right, rgba(161, 2, 73, 0.3), rgba(161, 2, 73, 0.8));
}

#rz-slider::-webkit-slider-thumb {
  background: var(--rz-color);
}

#poz-slider {
  background: linear-gradient(to right, rgba(128, 128, 128, 0.3), rgba(128, 128, 128, 0.8));
}

#poz-slider::-webkit-slider-thumb {
  background: var(--poz-color);
}

/*======================================
=       Additional Range Focus         =
======================================*/
input[type="range"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.2);
}

/*======================================
=           Button Styling             =
======================================*/
button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

button:hover {
  background-color: #2a75e8;
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

/*======================================
=           Tooltip Styling            =
======================================*/
#custom-tooltip {
  white-space: pre-line;
}

/*======================================
=      Party Map & Legend Styling      =
======================================*/
#party-map-container {
  position: relative;
  width: 100%;
  margin-top: 15px;
}

#party-map-legend {
  position: relative;
  width: 80%;
  max-width: 300px;
  margin: 15px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background-color: none;
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: none;
}

#party-map-legend .legend-canvas {
  width: 100%;
  height: 30px;
  display: block;
  border-radius: 4px;
}

#party-map-legend .legend-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 4px;
}

#party-map-legend .legend-min,
#party-map-legend .legend-max {
  font-size: 12px;
  font-weight: 600;
  color: #000;
}

/*======================================
=           Responsive Styles          =
======================================*/
@media (max-width: 1200px) {
  #row1 {
    grid-template-columns: 1fr 1fr;
  }
  
  .container {
    padding: 12px;
  }
}

@media (max-width: 768px) {
  #row1,
  #row2 {
    grid-template-columns: 1fr;
  }
  
  .sliders-section,
  .chart-section,
  .map-section,
  .details-section,
  .coalitions-section,
  .party-section {
    padding: 16px;
  }
  
  #party-map-legend {
    width: 90%;
  }
  
  #party-map-legend .legend-min,
  #party-map-legend .legend-max {
    font-size: 11px;
  }
}

@media (max-width: 600px) {
  body {
    padding: 10px;
  }
  
  .container {
    gap: 16px;
    padding: 8px;
  }
  
  #row1,
  #row2,
  #row3,
  #row4 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  h2 {
    font-size: 18px;
  }
  
  .slider-row label {
    font-size: 13px;
  }
  
  #party-map-legend {
    width: 95%;
    padding: 4px 8px;
  }
  
  #party-map-legend .legend-canvas {
    height: 25px;
  }
  
  #party-map-legend .legend-min,
  #party-map-legend .legend-max {
    font-size: 10px;
  }
}

@media (hover: none) {
  .sliders-section:hover,
  .chart-section:hover,
  .map-section:hover,
  .details-section:hover,
  .coalitions-section:hover,
  .party-section:hover {
    transform: none;
    box-shadow: var(--card-shadow);
  }
  
  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }
}
