:root {
  --primary-color: #d4af37; /* Gold color */
  --secondary-color: #a0aec0;
  --background-color: #0f172a;
  --card-background: rgba(255, 255, 255, 0.1); /* Translucent glassmorphism */
  --text-color: #f8fafc;
  --text-light: #ffffff;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --success-color: #10b981;
  --danger-color: #ef4444;
  --info-color: #3b82f6;
  --warning-color: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background-color);
  background-image: linear-gradient(rgba(10, 15, 30, 0.6), rgba(10, 15, 30, 0.6)), url('/ibi_frente.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background-color: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  position: sticky;
  top: 0;
  z-index: 50;
}

header h1 {
  font-size: 1.5rem;
  margin: 0;
  color: var(--primary-color);
  font-weight: 700;
  letter-spacing: 0.5px;
}

#userInfo {
  margin-left: auto;
  font-weight: 500;
  color: var(--text-light);
}

#loginSection, #mainSection {
  padding: 2rem;
}

#loginSection {
  max-width: 420px;
  margin: 6rem auto;
  text-align: center;
}

.card {
  background-color: var(--card-background);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

nav button {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

nav button:hover {
  background-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

nav button.active {
  background-color: var(--primary-color);
  color: var(--text-light);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

nav button.secondary {
  margin-left: auto;
  background-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
nav button.secondary:hover {
  background-color: rgba(239, 68, 68, 0.4);
  color: white;
}

#content {
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: none;
}

/* Tablas */
.table-container {
  overflow-x: auto;
  background-color: var(--card-background);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

th {
  font-weight: 600;
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.member-link {
  color: #60a5fa;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.2s;
}
.member-link:hover {
  color: #93c5fd;
  text-decoration: underline;
}

.badge {
  padding: 0.3em 0.8em;
  font-size: 0.8em;
  font-weight: 600;
  border-radius: 20px;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.badge.present { background-color: var(--success-color); box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3); }
.badge.absent { background-color: var(--danger-color); box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute; content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: var(--success-color); }
input:focus + .slider { box-shadow: 0 0 1px var(--success-color); }
input:checked + .slider:before { transform: translateX(22px); }

/* Dashboard */
.dashboard-title {
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Dashboard Search */
.search-container {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--card-background);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}
.search-container input {
  flex: 1;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  color: white;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
}
.search-container input:focus {
  border-color: var(--primary-color);
}
.search-container button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.search-container button:hover {
  background: #b5952f;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.kpi-card {
  background: var(--card-background);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.5rem 1rem;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.4);
}
.kpi-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.kpi-value { font-size: 2.5rem; font-weight: 700; line-height: 1; margin-bottom: 0.5rem; color: white !important;}
.kpi-label { font-size: 0.85rem; color: var(--secondary-color); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;}

/* Charts */
#chartsContainer {
  padding: 0;
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.chart-container {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.chart-container h3 {
  margin-bottom: 1.5rem;
  text-align: center;
  font-weight: 600;
  color: var(--text-light);
  font-size: 1.1rem;
}
.chart-wide {
  grid-column: 1 / -1;
}

/* Tablas Dashboard */
.dashboard-tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: start;
}

.dashboard-tables-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
  align-items: start;
}

.dashboard-table-card {
  margin-bottom: 1.5rem;
}
.dashboard-table-card h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: white;
}
.badge-num {
  display: inline-block;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 20px;
  padding: 0.2em 0.8em;
  font-weight: 600;
  font-size: 0.85em;
}
.badge-num.badge-gold {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.4);
}
.badge-num.badge-absent {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Tarjeta de alerta de ausencias consecutivas */
.absence-alert-card {
  border-left: 4px solid #ef4444;
}
.absence-alert-card h3 {
  color: #fca5a5 !important;
}

/* Formularios */
.form-container {
  max-width: 600px;
  margin: 0 auto;
}
.form-container h2, #loginSection h2 {
  margin-bottom: 1.5rem;
  color: white;
  font-weight: 600;
}
.form-container form, #loginForm {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}
.form-container label, #loginForm label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  color: var(--secondary-color);
  font-size: 0.9rem;
}
.form-container input, .form-container select, .form-container textarea, #loginForm input {
  padding: 0.85rem 1rem;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  margin-top: 0.5rem;
  color: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-container input:focus, .form-container select:focus, .form-container textarea:focus, #loginForm input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}
.form-container button, #loginForm button {
  padding: 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  margin-top: 1rem;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}
.form-container button:hover, #loginForm button:hover {
  background-color: #b5952f;
  transform: translateY(-2px);
}
.form-container button:active, #loginForm button:active {
  transform: translateY(0);
}

.hint {
  margin-top: 1.5rem;
  color: var(--secondary-color);
  font-size: 0.85rem;
}

/* Notificaciones */
#notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transition: opacity 0.4s, transform 0.4s;
  opacity: 1;
  transform: translateY(0);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
#notification.hidden {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}
#notification.success { background-color: rgba(16, 185, 129, 0.9); }
#notification.error { background-color: rgba(239, 68, 68, 0.9); }

.hidden {
  display: none !important;
}

/* Autocomplete/Search Results list */
#searchResults {
  position: absolute;
  background: var(--card-background);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 5px;
  box-shadow: var(--shadow);
}
#searchResults li {
  padding: 0.8rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#searchResults li:hover {
  background: rgba(255,255,255,0.1);
}
#searchResults li span.type-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #ccc;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  header { padding: 1rem; flex-direction: column; text-align: center; gap: 0.5rem; }
  #userInfo { margin-left: 0; font-size: 0.9rem; }
  nav { justify-content: center; border-bottom: none; }
  nav button { padding: 0.6rem 1rem; font-size: 0.9rem; flex-grow: 1; text-align: center; }
  .table-container { padding: 0; border: none; background: transparent; }
  table, thead, tbody, th, td, tr { display: block; }
  thead tr { position: absolute; top: -9999px; left: -9999px; }
  tr { border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 1rem; background: var(--card-background); padding: 0.5rem; }
  td { position: relative; padding-left: 45%; text-align: right; border: none; padding-top: 0.8rem; padding-bottom: 0.8rem; }
  td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    width: 40%;
    padding-right: 10px;
    text-align: left;
    font-weight: 600;
    color: var(--secondary-color);
  }
  .switch { transform: scale(0.9); }
  .dashboard-title { flex-direction: column; text-align: center; gap: 1rem; }
  .search-container { flex-direction: column; }
  .search-container input, .search-container button { width: 100%; }
}

