/* Directorio DIDPEC - Styles v0.1.0 */

:root {
  --primary: #990000;
  --primary-light: #b81c1c;
  --primary-dark: #6b0000;
  --accent: #D8B806;
  --accent-light: #f0d860;
  --accent-dark: #a08600;
  --bg: #f5f3ef;
  --card-bg: #ffffff;
  --text: #1e1e1e;
  --text-muted: #64605a;
  --border: #e8e4dd;
  --border-light: #f0ece6;
  --success: #16a34a;
  --zona-norte: #3b82f6;
  --zona-centro: #D8B806;
  --zona-sur: #990000;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: white;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo-img {
  height: 150px;
  width: auto;
  margin: -3rem 0;
  position: relative;
  z-index: 5;
}

.header-title h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-title p {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: 400;
}

/* header-right moved to Auth section */

/* ── Tabs + Stats Bar ────────────────── */
.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.2rem;
}

.tab {
  padding: 0.5rem 1.2rem;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab.active {
  background: var(--card-bg);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tab:hover:not(.active) {
  color: var(--text);
}

.stats-bar {
  display: flex;
  gap: 0.75rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.stat-card .stat-number {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.stat-card.zona-norte .stat-number { color: var(--zona-norte); }
.stat-card.zona-centro .stat-number { color: var(--zona-centro); }
.stat-card.zona-sur .stat-number { color: var(--zona-sur); }

/* ── Filters Bar ────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.1);
}

.filter-select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: white;
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.filter-select:focus {
  border-color: var(--primary-light);
}

.btn-clear {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-clear:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Table ──────────────────────────── */
.table-container {
  margin: 1rem 2rem 2rem;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--primary);
  color: white;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.row-click {
  cursor: pointer;
  transition: background 0.15s;
}

.row-click:hover {
  background: #f0f4ff;
}

.col-num {
  color: var(--text-muted);
  font-size: 0.75rem;
  width: 40px;
  text-align: center;
}

.col-nombre strong {
  display: block;
  color: var(--primary);
  font-size: 0.85rem;
}

.tag-carisma {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.1rem 0.5rem;
  background: rgba(216,184,6,0.15);
  color: #8a7200;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 500;
}

.tag-mine {
  display: inline-block;
  margin-top: 0.25rem;
  margin-right: 0.35rem;
  padding: 0.1rem 0.5rem;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.my-colegio {
  background: rgba(153, 0, 0, 0.04);
}

.col-matricula {
  text-align: center;
  font-weight: 600;
}

/* ── Badges ─────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.zona-norte { background: #dbeafe; color: var(--zona-norte); }
.zona-centro { background: rgba(216,184,6,0.15); color: #8a7200; }
.zona-sur { background: rgba(153,0,0,0.1); color: var(--zona-sur); }

/* ── Empty / Loading ────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  box-shadow: var(--shadow-lg);
  margin-top: 1rem;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  border-radius: 12px 12px 0 0;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-close:hover {
  background: rgba(255,255,255,0.35);
}

.modal-content {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.ficha-section {
  margin-bottom: 1.5rem;
}

.ficha-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
}

.ficha-row {
  display: flex;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-light);
  gap: 1rem;
}

.ficha-row:last-child {
  border-bottom: none;
}

.ficha-label {
  min-width: 180px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.ficha-value {
  font-size: 0.82rem;
  color: var(--text);
  word-break: break-word;
}

/* ── Auth ───────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.version-label {
  font-size: 0.7rem;
  opacity: 0.5;
}

.btn-auth {
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-login {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.btn-login:hover {
  background: rgba(255,255,255,0.25);
}

.btn-logout {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.2);
}

.btn-logout:hover {
  background: rgba(220,50,50,0.3);
  color: white;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: white;
}

.user-rol {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rol-admin {
  background: var(--accent);
  color: var(--primary);
}

.rol-director {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* ── Login Modal ────────────────────── */
.login-modal {
  max-width: 400px;
}

.login-content {
  text-align: center;
  padding: 2rem 2rem 1.5rem;
}

.login-logo-img {
  width: 100px;
  height: auto;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.1);
}

.login-error {
  color: #dc2626;
  font-size: 0.78rem;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}

.btn-login-submit {
  width: 100%;
  padding: 0.7rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-login-submit:hover {
  background: var(--primary-light);
}

.btn-login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Users Panel ─────────────────────── */
.users-panel {
  padding: 1.25rem 2rem 2rem;
}

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

.users-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Dashboard ──────────────────────── */
.dash-grid {
  padding: 1.25rem 2rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.dash-kpi {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.dash-school-header {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1rem 0 0.25rem;
}

.dash-school-header h2 {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 700;
}

.dash-school-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}

.kpi-number {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.kpi-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.dash-chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.dash-chart-card h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.dash-chart-card canvas {
  max-height: 260px;
}

.dir-pastoral-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.dir-pastoral-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.dir-pastoral-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.dir-pastoral-item strong {
  display: block;
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.dir-pastoral-item p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.dir-pastoral-detail {
  font-size: 0.72rem !important;
  margin-top: 0.25rem !important;
  font-style: italic;
}

/* ── Nuevo Button ────────────────────── */
.btn-nuevo {
  padding: 0.6rem 1.2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-nuevo:hover {
  background: var(--primary-light);
}

/* ── Ficha Actions ──────────────────── */
.ficha-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.btn-edit, .btn-delete {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-edit:hover {
  background: var(--primary-light);
}

.btn-delete {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.btn-delete:hover {
  background: #dc2626;
  color: white;
}

/* ── Form Modal ─────────────────────── */
.form-modal {
  max-width: 900px;
}

.form-content {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.form-section {
  margin-bottom: 1.5rem;
}

.form-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-grid .form-group.full {
  grid-column: 1 / -1;
}

.form-grid .form-group label {
  display: block;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.form-grid .form-group input,
.form-grid .form-group select,
.form-grid .form-group textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}

.form-grid .form-group input:focus,
.form-grid .form-group select:focus,
.form-grid .form-group textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.1);
}

.form-grid .form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-cancel {
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.btn-cancel:hover {
  background: var(--bg);
  color: var(--text);
}

.form-buttons .btn-login-submit {
  width: auto;
  padding: 0.65rem 2rem;
}

/* ── Gate Screen ─────────────────────── */
.gate-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  background: linear-gradient(135deg, #f0f2f5 0%, #e2e6ec 100%);
}

.gate-card {
  text-align: center;
  background: var(--card-bg);
  padding: 2rem 2rem 1.5rem;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  width: 90%;
}

.gate-logo-img {
  width: 160px;
  height: auto;
  margin-bottom: 0.5rem;
}

.gate-card h2 {
  font-size: 1.15rem;
  color: var(--primary);
  margin-bottom: 0.1rem;
}

.gate-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.gate-subtitle {
  font-weight: 600;
  color: var(--text) !important;
  margin-bottom: 1.25rem !important;
}

.gate-card .form-group {
  text-align: left;
  margin-bottom: 0.7rem;
}

.gate-card .form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.gate-card .form-group input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.gate-card .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(153, 0, 0, 0.1);
}

.btn-gate-login {
  display: block;
  width: 100%;
  padding: 0.6rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 0.5rem;
}

.btn-gate-login:hover {
  background: var(--primary-light);
}

.btn-gate-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.gate-note {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Responsive ─────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0.5rem 1rem; }
  .header-title h1 { font-size: 1rem; }
  .tabs-bar { padding: 0.75rem 1rem; }
  .stats-bar { gap: 0.5rem; flex-wrap: wrap; }
  .stat-card { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
  .filters-bar { padding: 0.75rem 1rem; }
  .table-container { margin: 0.75rem; }
  thead th { padding: 0.6rem 0.75rem; font-size: 0.7rem; }
  tbody td { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
  .modal-overlay { padding: 0.5rem; }
  .modal-content { padding: 1rem; }
  .ficha-row { flex-direction: column; gap: 0.15rem; }
  .ficha-label { min-width: unset; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .form-group.full { grid-column: 1; }
  .ficha-actions { flex-wrap: wrap; }
  .form-buttons { flex-direction: column; }
  .form-buttons .btn-login-submit { width: 100%; }
  .btn-cancel { width: 100%; text-align: center; }
  .dash-grid { padding: 1rem; grid-template-columns: 1fr; }
  .dash-kpi { grid-template-columns: repeat(2, 1fr); }
}
