@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

/* Reset básico */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

button, input, select, textarea {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

/* Header */
.header {
  position: relative;
  background: url('../assets/bg-usa.jpg') no-repeat center center;
  background-size: cover;
  color: white;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.header-logo {
  height: 38px;
  width: auto;
  margin-bottom: 0.5rem;
  filter: brightness(0) invert(1);
  display: inline-block;
}

h1, h2, h3 {
  line-height: 1.15;
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 0.2rem;
  line-height: 1.1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.header p {
  font-size: 1.1rem;
  opacity: 0.95;
  margin-bottom: 0.1rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.header .subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 0.1rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Estilos globales para botones */
button, .btn-save, .btn-mode, .btn-token, .btn-login, .btn-logout, .btn-copy, .btn-home {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
  border-radius: 8px;
  text-align: center;
}

/* Botones de control del Hemiciclo */
.hemicycle-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  flex-wrap: wrap;
}

.btn-mode {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mode:hover {
  background: #fff7f2;
  color: #ec6531;
}

.btn-mode.active {
  background: #1f1f1f !important;
  color: white !important;
  border-color: #1f1f1f !important;
  box-shadow: 0 4px 10px rgba(31, 31, 31, 0.25);
}
main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Panel Page */
#panel-page {
  max-width: 1400px;
}

/* Subtítulos dentro de botones y títulos */
.subtitle-sub {
  display: block;
  font-size: 0.78em;
  font-weight: normal;
  opacity: 0.85;
  margin-top: 0.15rem;
}
.panel-tabs {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: none;
  padding-bottom: 0;
}

.tab-btn {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.75rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  text-align: center;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  bottom: 0;
}

.tab-btn:hover {
  color: #ec6531;
  background: #fff7f2;
}

.tab-btn.active {
  background: #1f1f1f;
  color: white;
  border-color: #1f1f1f;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(31, 31, 31, 0.25);
}

/* Panel Summary */
.panel-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: white;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid #f0f0f0;
}

.summary-card .label {
  font-size: 0.85rem;
  color: #666;
}

.summary-card .value {
  font-size: 1.8rem;
  font-weight: 700;
}

.summary-card .sub {
  font-size: 0.8rem;
  color: #888;
}

.summary-card.dem .value {
  color: #0052B4;
}

.summary-card.rep .value {
  color: #f10019;
}

.summary-card.unassigned .value {
  color: #666;
}

.summary-card.total .value {
  color: #333;
}

/* Auth Section */
.auth-section {
  background: white;
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  border: 1px solid #f0f0f0;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.auth-section h2 {
  color: #ec6531;
  font-size: 1.2rem;
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.auth-pending {
  background: #fff4e5;
  color: #b25e09;
}

.auth-success {
  background: #e8f5e9;
  color: #2e7d32;
}

.auth-error {
  background: #ffebee;
  color: #c62828;
}

#auth-message {
  font-weight: 500;
  color: #555;
}

/* Token input */
.token-input-group {
  margin-top: 1rem;
}

.token-details {
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.token-summary {
  cursor: pointer;
  font-weight: 600;
  color: #333;
}

.token-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.token-input {
  flex: 1;
  min-width: 280px;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.9rem;
}

.token-input:focus {
  outline: none;
  border-color: #ec6531;
  box-shadow: 0 0 0 2px rgba(236, 101, 49, 0.12);
}

.btn-token {
  background-color: #ec6531;
  color: white;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-token:hover {
  background-color: #d95523;
}

.btn-token-secondary {
  background-color: #f0f0f0;
  color: #333;
}

.btn-token-secondary:hover {
  background-color: #e5e5e5;
}

.token-help {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #666;
}

/* States Section */
.states-section {
  background: white;
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  border: 1px solid #f0f0f0;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.states-section h2 {
  color: #1e293b;
  margin-bottom: 0.15rem;
  font-size: 1.25rem;
}

.info {
  color: #666;
  font-size: 0.9rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Search */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8f9fa;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search-box:focus-within {
  border-color: #ec6531;
  box-shadow: 0 0 0 2px rgba(236, 101, 49, 0.12);
  background: white;
}

.search-icon {
  color: #666;
}

.search-input {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  min-width: 240px;
  outline: none;
  font-family: inherit;
}

/* Table */
.table-wrapper {
  /* Contenedor sin overflow */
}

.states-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.states-table thead {
  background-color: #ec6531;
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.states-table th {
  padding: 0.7rem 0.6rem;
  text-align: center;
  font-weight: 600;
  position: -webkit-sticky;
  position: sticky;
  top: 0px;
  z-index: 1000;
  background-color: #ec6531;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.states-table th:first-child {
  border-top-left-radius: 8px;
}

.states-table th:last-child {
  border-top-right-radius: 8px;
}

.states-table td {
  padding: 0.55rem 0.6rem;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}

.states-table tbody tr:nth-child(even) {
  background-color: #fafafa;
}

.states-table tbody tr:hover {
  background-color: #fff7f2;
}

.states-table tbody tr.row-completed {
  background-color: #d8e8d2 !important;
}

.states-table tbody tr.row-completed:hover {
  background-color: #c9dec2 !important;
}

.states-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 8px;
}

.states-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

.state-name {
  text-align: left !important;
  font-weight: 600;
}

/* Inputs */
.input-num {
  width: 68px;
  padding: 0.4rem 0.25rem;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  text-align: center;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-num:focus {
  outline: none;
  border-color: #ec6531;
  box-shadow: 0 0 0 2px rgba(236, 101, 49, 0.12);
}

/* Validation */
.valid {
  color: #2e7d32;
  font-weight: 600;
}

.invalid {
  color: #d32f2f;
  font-weight: 600;
}

/* Button */
.btn-save-container {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.check-icon {
  color: #2e7d32;
  font-size: 1.15rem;
  font-weight: bold;
  line-height: 1;
  display: none;
}

.check-icon.visible {
  display: inline-block;
}

.btn-save {
  background-color: #ec6531;
  color: white;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-save:hover {
  background-color: #d95523;
  box-shadow: 0 2px 6px rgba(236, 101, 49, 0.25);
}

.btn-save:active {
  background-color: #c44719;
}

/* Home Page */
#home-page {
  max-width: 1000px;
  padding-bottom: 40px;
}

.widgets-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Widget */
.widget {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.widget h2 {
  color: #1e293b;
  margin-bottom: 0.4rem;
  font-size: 1.25rem;
  line-height: 1.15;
  text-align: center;
}

/* Huincha (Bar) */
.bar-container {
  margin: 1.5rem 0;
}

.bar-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.bar-label-dem {
  color: #0052B4;
}

.bar-label-rep {
  color: #f10019;
}

.bar-track {
  position: relative;
  height: 40px;
  background-color: #e0e0e0;
  border-radius: 20px;
  overflow: hidden;
}

.bar-segment-dem {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background-color: #0052B4;
  transition: width 0.3s ease;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  display: flex;
}

.bar-segment-dem-base {
  height: 100%;
  background-color: #0052B4;
  transition: width 0.3s ease;
}

.bar-segment-dem-live {
  height: 100%;
  background-color: #3385ff;
  transition: width 0.3s ease;
}

.bar-segment-rep {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background-color: #f10019;
  transition: width 0.3s ease;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  display: flex;
  flex-direction: row-reverse;
}

.bar-segment-rep-base {
  height: 100%;
  background-color: #f10019;
  transition: width 0.3s ease;
}

.bar-segment-rep-live {
  height: 100%;
  background-color: #ff4d61;
  transition: width 0.3s ease;
}

.bar-majority-line {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background-color: #333;
  z-index: 10;
}

.bar-majority-label {
  position: absolute;
  left: 50%;
  top: -25px;
  transform: translateX(-50%);
  font-weight: 700;
  color: #333;
  font-size: 0.9rem;
}

.bar-counts {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Mapa SVG */
.map-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

#usa-map-object {
  width: 100%;
  height: auto;
  display: block;
}

/* Leyenda del Mapa */
.map-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.legend-dem { background-color: #0052B4; }
.legend-rep { background-color: #f10019; }
.legend-mixed { background-color: #eab308; }
.legend-unassigned { background-color: #c9c9c9; }
.legend-disabled { background-color: #e2e8f0; border: 1px dashed #cbd5e1; }

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background: white;
  color: #333;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #ec6531;
  min-width: 280px;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
}

.toast.success {
  border-left-color: #2e7d32;
}

.toast.error {
  border-left-color: #c62828;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Login Card */
.login-card-container {
  max-width: 420px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

.login-card h2 {
  color: #1e293b;
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.login-card p {
  color: #64748b;
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-field {
  margin-bottom: 1.2rem;
}

.login-field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.login-input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
  outline: none;
  border-color: #ec6531;
  box-shadow: 0 0 0 2px rgba(236, 101, 49, 0.15);
}

.btn-login {
  width: 100%;
  background-color: #ec6531;
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s;
  margin-top: 0.5rem;
}

.btn-login:hover {
  background-color: #d95523;
}

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
}

.btn-logout {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.825rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #ffebee;
  color: #c62828;
  border-color: #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
  .header h1 {
    font-size: 1.5rem;
  }
  
  .header p {
    font-size: 1rem;
  }
  
  .panel-tabs, .hemicycle-controls {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .tab-btn, .btn-mode {
    width: 100%;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
  }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input {
    min-width: 100%;
  }
  
  .toolbar {
    width: 100%;
  }
  
  .search-box {
    width: 100%;
  }
  
  .states-table {
    font-size: 0.8rem;
  }
  
  .states-table th,
  .states-table td {
    padding: 0.5rem 0.35rem;
  }
  
  .input-num {
    width: 58px;
  }
  
  .btn-save {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }
  
  .toast-container {
    right: 0.5rem;
    left: 0.5rem;
  }
  
  .toast {
    min-width: auto;
    width: 100%;
  }
}
