:root {
  --primary: #2aa0a0;
  --primary-light: #33bfc0;
  --primary-dark: #205a5a;
  --secondary: #263238;
  --accent: #ffca28;

  --bg-body: #f0f2f5;
  --bg-card: #ffffff;
  --text-main: #1c1e21;
  --text-muted: #65676b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 700;
  color: var(--secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

/* ===== LAYOUT ===== */
.container {
  max-width: 1000px;
  /* narrowed for better readability in centered layout */
  margin: 4rem auto;
  /* Increased from 2rem to 4rem for more separation from header */
  padding: 3rem 2rem;
  /* slightly increased padding */
  text-align: center;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: calc(100vh - 200px);
  /* ensures it fills screen nicely */
}

@media (max-width: 768px) {
  .container {
    margin: 1.5rem auto;
    padding: 1.5rem 1rem;
    border-radius: 0;
    width: 100%;
    min-height: auto;
  }
}

.container h2 {
  margin-bottom: 3rem;
  /* Extra space under the main page titles */
}

/* ===== HEADER / NAVIGATION ===== */
.topbar {
  background: var(--bg-card);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar h1,
.nav-logo {
  margin: 0;
  max-height: 50px;
  /* Adjust as needed */
  width: auto;
  object-fit: contain;
}

.login-logo {
  max-height: 100px;
  width: auto;
  object-fit: contain;
}

.register-logo {
  max-height: 100px;
  width: auto;
  object-fit: contain;
}

.topbar nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.topbar nav a {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.topbar nav a:hover,
.topbar nav a.active {
  background-color: #e8f5e9;
  color: var(--primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-left: 1px solid #e0e0e0;
  padding-left: 1.5rem;
}

.user-info strong {
  color: var(--secondary);
}

.hamburger-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--primary);
  padding: 0.5rem;
}

.desktop-only {
  display: block;
}

/* Mobile Nav Toggle */
@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    padding: 1rem;
    position: relative;
  }

  .hamburger-menu {
    display: block;
    order: 2;
  }

  .topbar h1 {
    flex-grow: 1;
    font-size: 1.25rem;
    order: 1;
  }

  .topbar nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-card);
    padding-top: 1rem;
    border-top: 1px solid #eee;
    order: 4;
    animation: slideDown 0.3s ease-out;
  }

  .topbar nav.active {
    display: flex;
  }

  .topbar nav a {
    text-align: center;
    padding: 1rem;
    border-radius: 0;
    border-bottom: 1px solid #f0f0f0;
  }

  .user-info {
    margin: 0;
    padding: 0.5rem 0;
    border: none;
    width: 100%;
    justify-content: center;
    border-top: 1px solid #eee;
    order: 3;
    font-size: 0.85rem;
    display: none;
    /* Hide in header, maybe show in nav? or just simplify */
  }

  .topbar nav.active~.user-info {
    display: flex;
    /* Show user info when menu is active if desired, or keep hidden/simplified */
  }

  .nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px);
  }

  .nav-backdrop.active {
    display: block;
  }

  .desktop-only {
    display: none;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--primary-dark);
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ===== BUTTONS ===== */
.btn,
button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-align: center;
  border: none;
  cursor: pointer;
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 6px rgba(46, 125, 50, 0.2);
  transition: var(--transition);
}

.btn:hover,
button:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 6px 8px rgba(46, 125, 50, 0.3);
  transform: translateY(-1px);
  color: white;
}

.btn-secondary {
  background-color: #e0e0e0;
  color: var(--text-main);
  box-shadow: none;
}

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

.export-buttons {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0;
}

/* ===== FORMS ===== */
/* ===== FORMS ===== */
form {
  /* Default form style, but allowing override */
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Reset for forms inside tables or specifically marked inline */
table form,
form.inline-form {
  display: inline-block;
  gap: 0;
  margin: 0;
  width: auto;
}

/* Table Actions Cell */
td.acciones {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}


label {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--secondary);
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid #d0d7de;
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

/* ===== TABLES ===== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: white;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border: 1px solid #eee;
}

@media (min-width: 769px) {
  .table-responsive {
    overflow: visible;
    /* Prevents dropdown clipping on desktop */
  }
}

/* Scroll indicator hint */
.table-responsive::after {
  content: '→ Deslice para ver más';
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.5rem;
}

@media (min-width: 769px) {
  .table-responsive::after {
    display: none;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  background-color: #f8f9fa;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  padding: 1rem;
  border-bottom: 2px solid #eee;
  text-align: left;
}

td {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  color: var(--text-main);
}

tr:hover td {
  background-color: #fafbfc;
}

/* Status Badges */
.status-badge,
.P,
.A,
.AJ {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
}

.P {
  background-color: #e6fffa;
  color: #047481;
}

/* Presente */
.A {
  background-color: #fff5f5;
  color: #c53030;
}

/* Ausente */
.AJ {
  background-color: #fffaf0;
  color: #dd6b20;
}

/* Ausente Justif */

/* ===== CALENDAR GRID ===== */
.calendar-controls {
  background: white;
  padding: 1rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 2rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: #e0e0e0;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header {
  background-color: #f8f9fa;
  padding: 1rem;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
}

.calendar-cell {
  background-color: white;
  min-height: 8rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
}

.day-number {
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
  .calendar-grid {
    display: flex;
    flex-direction: column;
  }

  .calendar-cell {
    min-height: auto;
    border-bottom: 1px solid #eee;
  }
}

/* ===== COMPACT TABLES (For Monthly Calendar) ===== */
.compact-table {
  font-size: 0.85rem;
}

.compact-table th,
.compact-table td {
  padding: 0.5rem 0.25rem;
  text-align: center;
}

.compact-table th:first-child,
.compact-table td:first-child {
  text-align: left;
  padding-left: 1rem;
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 10;
  border-right: 1px solid #eee;
}

.calendar-mini-badge {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
  margin: 0 auto;
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 600px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== FULLSCREEN CALENDAR (Mobile Optimization) ===== */
.fullscreen-calendar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  background: white;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.fullscreen-calendar .compact-table {
  font-size: 0.65rem;
  /* Even smaller for full view */
}

.fullscreen-calendar .compact-table th,
.fullscreen-calendar .compact-table td {
  padding: 0.25rem 0.1rem;
  min-width: 15px;
}

.fullscreen-calendar .calendar-mini-badge {
  width: 14px;
  height: 14px;
  font-size: 0.55rem;
}

.close-fullscreen {
  position: sticky;
  top: 0;
  right: 0;
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  z-index: 2001;
  font-weight: bold;
}

@media (min-width: 901px) {
  .btn-fullscreen {
    display: none;
  }
}

/* Generic Cards Grid (from salas) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.hijos-list {
  display: grid;
  gap: 1rem;
}

.hijo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
}

.sala-tag {
  background-color: #e3f2fd;
  color: #1976d2;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.notas-group .group-title {
  color: var(--primary);
  border-bottom: 2px solid #e8f5e9;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.nota-item {
  background: white;
  border-left: 4px solid var(--primary);
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-sm);
}

.nota-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== LOGIN PAGE ===== */
body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #ac4a2f 0%, #f46e49 100%);
}

.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 400px;
}

.login-box h2 {
  text-align: center;
  color: var(--primary-dark);
  margin-bottom: 2rem;
}

.login-box button {
  width: 100%;
  margin-top: 1rem;
  padding: 1rem;
  font-size: 1.1rem;
}


/* ===== DROPDOWN ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-btn {
  background-color: var(--primary-light);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dropdown-btn:hover {
  background-color: var(--primary);
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  /* Restore downward opening */
  background-color: white;
  min-width: 160px;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  z-index: 1000;
  /* Higher z-index to overflow tables */
  overflow: hidden;
  border: 1px solid #eee;
}

.dropdown-content.show {
  display: block;
}

.dropdown-content a {
  color: var(--text-main);
  padding: 0.75rem 1rem;
  text-decoration: none;
  display: block;
  font-size: 0.9rem;
}

.dropdown-content a:hover {
  background-color: #f1f1f1;
  color: var(--primary);
}

/* Mobile Dropdown - Bottom Sheet */
@media (max-width: 768px) {
  .dropdown-content {
    position: fixed;
    top: auto !important;
    /* reset top */
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    border: none;
    padding-bottom: 2rem;
    /* Safe area */
    animation: slideUp 0.3s ease-out;
    z-index: 2000;
  }

  .dropdown-content a {
    padding: 1rem;
    text-align: center;
    font-size: 1.1rem;
    border-bottom: 1px solid #f0f0f0;
  }

  .dropdown-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
  }

  .dropdown-backdrop.show {
    display: block;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}