/* ===================================================================
   Mi CEDSA Postítulos (v2.0) - Design System & Modern Responsive UI
   =================================================================== */

:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-dark: #172554;
  --secondary: #0ea5e9;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

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

body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===================================================================
   Header & Navbar
   =================================================================== */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;
  margin-top: 0 !important;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.navbar-brand img {
  height: 40px;
  width: auto;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.2;
}

.user-dni {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-action,
.btn-logout {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.btn-carrera {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.btn-carrera:hover {
  background: #bae6fd;
  color: #0284c7;
}

.btn-logout {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}
.btn-logout:hover {
  background: #fca5a5;
  color: #991b1b;
}

/* ===================================================================
   Contenedor principal y Tarjetas
   =================================================================== */
.main-container {
  max-width: 1100px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
  flex: 1;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.card-header .btn-back,
.card-header .btn-primary {
  flex-shrink: 0;
  white-space: nowrap;
}

.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ===================================================================
   Grilla de Postítulos (Cards Interactivas)
   =================================================================== */
.career-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.career-card {
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.career-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.career-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

.career-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Badges e Insignias */
.career-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-right: 6px;
}

.badge-active {
  background: #ecfdf5;
  color: #059669;
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ===================================================================
   Semáforo de Requisitos para Examen
   =================================================================== */
.requirements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.requirement-box {
  padding: 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.requirement-box.ok {
  background: var(--success-bg);
  border-color: #a7f3d0;
}

.requirement-box.fail {
  background: var(--danger-bg);
  border-color: #fecaca;
}

.req-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.req-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.req-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===================================================================
   Grilla de Turnos de Examen
   =================================================================== */
.turns-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 1.5rem 0;
}

.turn-option {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  background: #ffffff;
}

.turn-option:hover {
  border-color: var(--primary-light);
  background: #f0f7ff;
}

.turn-option input[type="radio"] {
  margin-right: 15px;
  transform: scale(1.3);
  accent-color: var(--primary);
  flex-shrink: 0;
}

.turn-details {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.turn-datetime {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-dark);
}

.turn-quota {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Botón Primario Universal */
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary:hover {
  background: var(--primary-light);
  color: #ffffff;
}

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* ===================================================================
   Módulo de Calificaciones: Vista Desktop vs Móvil (Opción A)
   =================================================================== */
.modules-desktop-view {
  display: block;
}

.modules-mobile-view {
  display: none;
}

.module-card-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

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

.module-card-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--primary-dark);
}

.module-card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-color);
}

.module-card-grade-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.module-card-grade-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.module-card-grade-val.grade-ok {
  color: #166534;
}

.module-card-tf {
  background: #f0fdf4;
  border: 2px solid #86efac;
}

.badge-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-status.badge-ok {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.badge-status.badge-ok-tf {
  background: #166534;
  color: #ffffff;
}

.badge-status.badge-fail {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.badge-status.badge-pending {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.action-boxes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

/* ===================================================================
   Footer
   =================================================================== */
footer {
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* ===================================================================
   Media Queries & Mobile Responsiveness
   =================================================================== */

/* Tablet & Pantallas Medianas (<= 768px) */
@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .navbar-brand {
    font-size: 1.1rem;
  }

  .navbar-brand img {
    height: 36px;
  }

  .navbar-user {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
    padding-top: 0.6rem;
    gap: 10px;
  }

  .user-badge {
    text-align: left;
    max-width: 55%;
  }

  .user-name {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-dni {
    font-size: 0.72rem;
  }

  .navbar-actions {
    gap: 6px;
  }

  .btn-action,
  .btn-logout {
    padding: 6px 11px;
    font-size: 0.78rem;
  }

  .main-container {
    padding: 0 1rem;
    margin: 1.25rem auto;
  }

  .card {
    padding: 1.25rem;
  }
}

/* Dashboard Modules Grid */
.dashboard-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.btn-back {
  background: #e2e8f0 !important;
  color: #334155 !important;
  font-size: 0.85rem !important;
  padding: 8px 16px !important;
  font-weight: 600 !important;
}

.btn-back:hover {
  background: #cbd5e1 !important;
  color: #0f172a !important;
}

.responsive-iframe {
  width: 100%;
  height: 750px;
  border: none;
  display: block;
}

/* ===================================================================
   Media Queries & Mobile Responsiveness
   =================================================================== */

/* Tablet & Pantallas Medianas (<= 768px) */
@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .navbar-brand {
    font-size: 1.1rem;
  }

  .navbar-brand img {
    height: 36px;
  }

  .navbar-user {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
    padding-top: 0.6rem;
    gap: 10px;
  }

  .user-badge {
    text-align: left;
    max-width: 55%;
  }

  .user-name {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-dni {
    font-size: 0.72rem;
  }

  .navbar-actions {
    gap: 6px;
  }

  .btn-action,
  .btn-logout {
    padding: 6px 11px;
    font-size: 0.78rem;
  }

  .main-container {
    padding: 0 1rem;
    margin: 1.25rem auto;
  }

  .card {
    padding: 1.25rem;
  }
}

/* Móviles y Pantallas Pequeñas (<= 640px) */
@media (max-width: 640px) {
  /* Alternar vista de Módulos (Opción A activa en móvil) */
  .modules-desktop-view {
    display: none !important;
  }

  .modules-mobile-view {
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
  }

  /* Encabezados adaptables sin aplastar botones */
  .card-header {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.75rem;
  }

  .card-header .btn-back,
  .card-header .btn-primary {
    width: 100% !important;
    text-align: center;
  }

  .card-title {
    font-size: 1.2rem;
  }

  /* Banner en móvil */
  .dashboard-banner-action {
    width: 100%;
  }

  .dashboard-banner-action .btn-primary {
    width: 100% !important;
    text-align: center;
  }

  /* Grilla de módulos dashboard */
  .dashboard-modules-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Semáforo en móvil */
  .requirements-grid {
    grid-template-columns: 1fr;
  }

  /* Turnos en móvil */
  .turn-details {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  /* Cajas de acción de actas oficiales */
  .action-boxes-grid {
    grid-template-columns: 1fr;
  }

  .action-boxes-grid .btn-primary {
    width: 100%;
    text-align: center;
  }

  .responsive-iframe {
    height: 520px;
  }
}

/* Móviles Muy Angostos (<= 480px) */
@media (max-width: 480px) {
  .navbar-brand span {
    font-size: 0.98rem;
  }

  .user-badge {
    max-width: 45%;
  }

  .btn-action,
  .btn-logout {
    padding: 5px 8px;
    font-size: 0.72rem;
  }

  .career-grid {
    grid-template-columns: 1fr;
  }

  .main-container {
    padding: 0 0.75rem;
    margin: 1rem auto;
  }

  .card {
    padding: 1rem;
  }
}

/* ===================================================================
   Form Controls & Modern Input System
   =================================================================== */
.form-group {
  margin-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--primary-dark);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input,
.form-select {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  display: block;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary-light);
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.15);
}

.form-input::placeholder {
  color: #94a3b8;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 1.1em;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* Modal Window System */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  backdrop-filter: blur(4px);
  box-sizing: border-box;
}

.modal-container {
  background: #ffffff;
  border-radius: var(--radius-md);
  max-width: 720px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 2.25rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  box-sizing: border-box;
}

.modal-container * {
  box-sizing: border-box;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.modal-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* Selector de Bandas Horarias (A, B, C) */
.schedule-options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.schedule-tile {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem 0.9rem;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.schedule-tile:hover {
  border-color: #93c5fd;
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.schedule-tile.active {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.schedule-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.schedule-letter {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.2px;
}

.schedule-tile.active .schedule-letter {
  color: var(--primary);
}

.schedule-tile-desc {
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.45;
  font-feature-settings: "tnum";
}

.schedule-tile.active .schedule-tile-desc {
  color: #1e3a8a;
  font-weight: 500;
}

.sub-block-btn {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sub-block-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: #f8fafc;
}

.sub-block-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
  .schedule-options-grid {
    grid-template-columns: 1fr;
  }
  .modal-grid-2,
  .modal-grid-3 {
    grid-template-columns: 1fr;
  }
  .modal-container {
    padding: 1.5rem 1.25rem;
  }
}

