/* =========================
   TISA Look & Feel - MOBILE FIRST
   Base: 320px+ (mÃ³viles)
   OPTIMIZADO: Controles compactos en mobile
   ========================= */

:root{
  /* Colores TISA */
  --tisa-blue:#003B8E;
  --tisa-blue-600:#0A4FAE;
  --tisa-yellow:#FFC300;

  /* Paleta base */
  --ink:#0f172a;
  --muted:#334155;
  --border:#e5e7eb;
  --bg:#f8fafc;
  --card:#ffffff;

  --radius:16px;
  --shadow:0 8px 28px rgba(2, 6, 23, .08);

  /* Colores Macroárea */
  --a:#ff8a00;   /* Área A acento naranja */
  --b:#7c3aed;   /* Área B acento violeta */
  --c:#16a34a;   /* Área C acento verde */
}

/* ===========================
   BASE STYLES (Mobile 320px+)
   =========================== */

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans";
  overflow-x: hidden;
}

/* ================
   HEADER - MOBILE (COMPACTO)
   ================ */
.site-header{
  position: sticky; 
  top:0; 
  z-index: 20;
  background:
    linear-gradient(90deg, var(--tisa-blue) 0 65%, var(--tisa-yellow) 65% 100%) top/100% 3px no-repeat,
    #fff;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  padding: 8px 12px;  /* Reducido de 12px 16px */
}

/* Brand - Mobile (MÃS COMPACTO) */
.brand{
  display:flex; 
  align-items:center; 
  gap:8px;  /* Reducido de 10px */
  margin-bottom:8px;  /* Reducido de 12px */
  flex-wrap: wrap;
}
.brand-logo{
  width:32px;  /* Reducido de 36px */
  height:32px; 
  border-radius:8px; 
  object-fit:cover;
  box-shadow: 0 0 0 2px #fff, 0 1px 6px rgba(0,0,0,.1);
  border: 2px solid var(--tisa-blue);
}
.brand-text h1{ 
  margin:0; 
  font-size:1.1rem;  /* Reducido de 1.25rem */
  color: var(--tisa-blue);
  line-height: 1.2;
}
.brand-text p{ 
  margin:2px 0 0; 
  color:var(--muted);
  font-size: 0.8rem;  /* Reducido de 0.85rem */
}

/* Buttons - Mobile (COMPACTOS) */
.btn{
  border:1px solid var(--tisa-blue);
  background: var(--tisa-blue);
  color:#fff;
  padding:6px 10px;  /* Reducido de 8px 12px */
  border-radius:8px;
  cursor:pointer;
  font-size: 0.8rem;  /* Reducido de 0.875rem */
  transition: transform .04s ease, filter .2s ease, box-shadow .2s ease;
  box-shadow: 0 4px 12px rgba(0,59,142,.16);
  white-space: nowrap;
}
.btn:hover{ filter: brightness(1.06); }
.btn:active{ transform: translateY(1px); }
.btn.secondary{
  background:#fff; 
  color:var(--tisa-blue);
  border-color: var(--tisa-blue);
  box-shadow: none;
}
.btn.inscribir{
  background: linear-gradient(180deg, var(--tisa-yellow), #ffdf6a);
  border-color: #d9a600;
  color:#1f2937;
  font-weight: 600;
}

/* Macrobar - Mobile (COMPACTA) */
.macrobar{
  display:flex; 
  gap:6px;  /* Reducido de 8px */
  margin-bottom:8px;  /* Reducido de 12px */
  flex-wrap:wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.macro-pill{
  display:flex; 
  align-items:center; 
  gap:5px;  /* Reducido de 6px */
  border:1px solid var(--border); 
  background:#fff; 
  color:var(--ink);
  padding:6px 8px;  /* Reducido de 8px 10px */
  border-radius:999px; 
  cursor:pointer;
  box-shadow: 0 2px 8px rgba(2,6,23,.06);
  font-size: 0.8rem;  /* Reducido de 0.85rem */
  white-space: nowrap;
  flex-shrink: 0;
}
.macro-pill .dot{
  width:7px;  /* Reducido de 8px */
  height:7px; 
  border-radius:50%;
  background:#94a3b8;
  flex-shrink: 0;
}
.macro-pill .count{ 
  font-variant-numeric: tabular-nums; 
  color:var(--muted);
}
.macro-pill strong{ font-weight:700; }

.macro-pill.a .dot{ background: var(--a); }
.macro-pill.b .dot{ background: var(--b); }
.macro-pill.c .dot{ background: var(--c); }
.macro-pill.active{ 
  border-color:#bfdbfe; 
  box-shadow: 0 4px 14px rgba(0,59,142,.12);
}

/* Controls - Mobile (MÃS COMPACTOS) */
.controls{
  display:grid;  /* Cambiado de flex a grid */
  grid-template-columns: 1fr 1fr;  /* 2 columnas en mobile */
  gap:6px;  /* Reducido de 10px */
  margin-bottom: 8px;
}
.control{ 
  display:flex; 
  flex-direction:column; 
  gap:4px;  /* Reducido de 5px */
  width: 100%;
}
.control label{ 
  font-size:0.75rem;  /* Reducido de 0.8rem */
  color:var(--muted);
  font-weight: 500;
}
/* Buscador ocupa 2 columnas */
.control.search {
  grid-column: 1 / -1;
}

input[type="search"], select{
  border:1px solid var(--border);
  background:#fff;
  padding:8px;  /* Reducido de 10px */
  border-radius:8px;
  outline: none;
  width: 100%;
  font-size: 0.85rem;  /* Reducido de 0.9rem */
  box-shadow: 0 1px 0 #fff inset;
}
input[type="search"]:focus, select:focus{
  border-color: var(--tisa-blue);
  box-shadow: 0 0 0 2px rgba(0,59,142,.1);  /* Reducido de 3px */
}

/* Botones de acciÃ³n en mobile */
#limpiar {
  grid-column: 1 / -1;  /* Ocupa todo el ancho */
  padding: 8px;
  font-size: 0.85rem;
}

/* Layout - Mobile */
.container{
  max-width: 100%;
  margin: 12px auto;  /* Reducido de 16px */
  padding: 0 12px 24px;  /* Reducido */
}
.counter{ 
  color:var(--muted); 
  margin: 6px 4px 8px;  /* Reducido */
  font-size:0.85rem;  /* Reducido de 0.9rem */
}

/* Grid - Mobile (1 columna) */
.grid{
  display: grid;
  gap: 14px;  /* Reducido de 16px */
  grid-template-columns: 1fr;
  align-items: stretch;
  width: 100%;
}

/* Cards - Mobile (MÃS COMPACTAS) */
.card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: 12px;  /* Reducido de 14px */
  box-shadow: 0 4px 16px rgba(2, 6, 23, .06);
  padding:12px;  /* Reducido de 14px */
  display:flex; 
  flex-direction:column; 
  gap:6px;  /* Reducido de 8px */
  transition: transform .06s ease, box-shadow .2s ease, border-color .2s ease;
  height: 100%;
}
.card:hover{
  transform: translateY(-1px);
  border-color:#dbeafe;
  box-shadow: 0 8px 20px rgba(0,59,142,.1);
}
.card h3{ 
  margin:0; 
  font-size:0.95rem;  /* Reducido de 1rem */
  line-height:1.3; 
  color:#0b2447;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card p{ 
  margin:0; 
  color:var(--muted);
  font-size: 0.8rem;  /* Reducido de 0.875rem */
  flex: 1 1 auto;
  line-height: 1.4;  /* Mejor legibilidad */
}
.card .chips{ 
  display:flex; 
  gap:4px;  /* Reducido de 5px */
  flex-wrap:wrap;
  margin-top: auto;
}
.card .actions{ 
  display:flex; 
  gap:6px;  /* Reducido de 8px */
  margin-top:6px;  /* Reducido de 8px */
}

/* Chips - Mobile (MÃS COMPACTAS) */
.chip{
  display:inline-block;
  font-size:0.65rem;  /* Reducido de 0.7rem */
  padding:4px 7px;  /* Reducido de 5px 8px */
  border-radius:999px;
  border:1px solid #dbeafe;
  background:#eef6ff;
  color:#0b3b8e;
  white-space: nowrap;
}
.chip.macro{ font-weight:700; }
.chip.macro[data-macro="Área A"]{ background:#fff4e6; border-color:#ffd9b3; color:#7a2e00; }
.chip.macro[data-macro="Área B"]{ background:#f3e8ff; border-color:#e9d5ff; color:#5b21b6; }
.chip.macro[data-macro="Área C"]{ background:#ecfdf5; border-color:#bbf7d0; color:#166534; }

/* Colores por área */
.chip[data-area="Lengua y Literatura"]{ background:#eef2ff; color:#3730a3; border-color:#c7d2fe; }
.chip[data-area="FilosofÃ­a"]{ background:#fef9c3; color:#854d0e; border-color:#fde68a; }
.chip[data-area="Historia, GeografÃ­a y Ciencias Sociales"]{ background:#e0f2fe; color:#075985; border-color:#bae6fd; }
.chip[data-area="MatemÃ¡tica"]{ background:#ecfccb; color:#3f6212; border-color:#d9f99d; }
.chip[data-area="Ciencias"]{ background:#dcfce7; color:#166534; border-color:#bbf7d0; }
.chip[data-area="EducaciÃ³n FÃ­sica y Salud"]{ background:#fff1f2; color:#9f1239; border-color:#ffe4e6; }
.chip[data-area="Artes"]{ background:#fae8ff; color:#6b21a8; border-color:#f5d0fe; }

/* Modal - Mobile */
.modal{ 
  border:none; 
  padding:0; 
  width:calc(100vw - 24px);
  max-width: 500px;
  border-radius:16px;
  margin: auto;
}
.modal::backdrop{ background: rgba(2,6,23,.5); }
.modal-card{ 
  background:#fff; 
  border-radius: 16px; 
  overflow:hidden; 
  border:1px solid var(--border);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 14px;  /* Reducido de 16px */
  max-height: 85vh;
}
.modal-header{
  display:flex; 
  flex-direction: column;
  gap:6px;  /* Reducido de 8px */
  padding-bottom: 8px;  /* Reducido de 10px */
  border-bottom:1px solid var(--border);
}
.modal-header h2{ 
  margin:0; 
  font-size:1.05rem;  /* Reducido de 1.1rem */
  color: var(--tisa-blue);
  line-height: 1.3;
}
.modal-meta{ 
  display:flex; 
  gap:5px;  /* Reducido de 6px */
  flex-wrap:wrap;
  align-items: flex-start;
}
.modal-body{ 
  padding: 10px 4px;  /* Reducido de 12px 4px */
  color: var(--ink);
  overflow:auto;
  line-height:1.6;
  font-size: 0.85rem;  /* Reducido de 0.9rem */
  max-height: calc(85vh - 180px);
}
.modal-body p{ margin: 8px 0; }  /* Reducido de 10px */
.modal-footer{
  display:flex;
  flex-direction:column;
  gap:8px;  /* Reducido de 10px */
  padding-top: 10px;  /* Reducido de 12px */
  border-top:1px solid var(--border);
}
.modal-footer .rating{
  display:flex;
  align-items:center;
  gap:8px;  /* Reducido de 10px */
  color:var(--muted);
  font-weight:600;
  font-size: 0.85rem;  /* Reducido de 0.9rem */
}
#modal-stars{ 
  color: #cfcfcf; 
  letter-spacing:2px;  /* Reducido de 3px */
  font-size:0.95rem;  /* Reducido de 1rem */
}
#modal-rating-count{ 
  color:var(--muted); 
  font-weight:500;
}
.modal-actions { 
  display:flex; 
  align-items:center;
}

/* Footer - Mobile */
.site-footer{
  border-top:1px solid var(--border);
  background:#fff;
  padding:12px 14px;  /* Reducido de 14px 16px */
  color:var(--muted);
  font-size: 0.8rem;  /* Reducido de 0.85rem */
  text-align: center;
}

/* Admin Toggle - Mobile */
body:not(.is-admin) .admin-toggle { display: none; }
.admin-toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;  /* Reducido de 8px */
  margin-left:6px;  /* Reducido de 8px */
  font-weight:600;
  color:var(--muted);
  font-size:0.8rem;  /* Reducido de 0.85rem */
}
.admin-toggle .admin-switch{
  width:38px;  /* Reducido de 40px */
  height:20px;  /* Reducido de 22px */
  border-radius:11px;  /* Reducido de 12px */
  background:#e6e9ef; 
  position:relative; 
  display:inline-block;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.admin-toggle input[type="checkbox"]{ display:none; }
.admin-toggle .admin-switch::after{
  content:''; 
  position:absolute; 
  top:3px; 
  left:3px; 
  width:14px;  /* Reducido de 16px */
  height:14px; 
  border-radius:50%;
  background:white; 
  box-shadow:0 2px 4px rgba(0,0,0,0.12); 
  transition: transform .18s ease;
}
.admin-toggle input[type="checkbox"]:checked + .admin-switch { 
  background:var(--tisa-blue); 
}
.admin-toggle input[type="checkbox"]:checked + .admin-switch::after { 
  transform: translateX(18px); 
}
.admin-toggle-completed input[type="checkbox"]:checked + .admin-switch { 
  background:#f97316; 
}
.admin-toggle-completed .admin-label {
  color: #c2410c;
}

/* Unavailable / Completed badges */
.card.not-available { 
  opacity:0.72; 
  filter:grayscale(.06); 
}
.badge-not-available{
  display:inline-block;
  background: #ffeef0;
  color:#a33;
  padding:4px 8px;  /* Reducido de 5px 10px */
  border-radius:10px;  /* Reducido de 12px */
  font-size:0.75rem;  /* Reducido de 0.8rem */
  margin-bottom:5px;  /* Reducido de 6px */
}
.badge-completed{
  background: #fff4e6;
  color:#c2410c;
  border: 1px solid #fed7aa;
}
.badge-unavailable-modal{
  background: #ffeef0;
  color:#a33;
  padding:7px 10px;  /* Reducido de 8px 12px */
  border-radius:8px;  /* Reducido de 10px */
  font-size:0.8rem;  /* Reducido de 0.85rem */
  text-align: center;
}

/* A11y util */
.visually-hidden{
  position:absolute!important; 
  width:1px;
  height:1px; 
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0 0 0 0);
  white-space:nowrap;
  border:0;
}

/* ===========================
   TABLET (600px+)
   =========================== */
@media (min-width: 600px) {
  body{
    font-size: 15px;
  }

  .site-header{
    padding: 12px 16px;
  }

  .brand{
    gap:10px;
    margin-bottom:10px;
  }

  .brand-logo{
    width:38px; 
    height:38px;
  }

  .brand-text h1{ 
    font-size:1.3rem;
  }

  .brand-text p{ 
    font-size: 0.9rem;
  }

  /* Controls en tablet: mÃ¡s espacio */
  .controls{
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
  }

  .control{
    width: auto;
    min-width: 160px;
  }

  .control.search {
    min-width: 250px;
  }

  /* Grid: 2 columnas en tablet */
  .grid{
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .card{
    padding:14px;
  }

  .card h3{
    font-size:1rem;
  }

  .card p{
    font-size: 0.875rem;
  }

  .modal{
    max-width: 600px;
  }

  .modal-card{
    padding: 16px;
  }

  .modal-header{
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .modal-header h2{
    font-size:1.15rem;
  }

  .modal-body{
    font-size: 0.9rem;
    padding: 12px 8px;
  }

  .modal-footer{
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* ===========================
   DESKTOP SMALL (900px+)
   =========================== */
@media (min-width: 900px) {
  body{
    font-size: 16px;
  }

  .site-header{
    padding: 16px 20px 14px;
  }

  .brand{
    gap:14px;
    margin-bottom:12px;
  }

  .brand-logo{
    width:44px; 
    height:44px;
  }

  .brand-text h1{ 
    font-size:1.5rem;
  }

  .brand-text p{
    font-size: 1rem;
  }

  .btn{
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .macrobar{
    gap: 8px;
    margin-bottom: 12px;
  }

  .macro-pill{
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .macro-pill .dot{
    width: 8px;
    height: 8px;
  }

  .controls{
    gap: 12px;
  }

  .control label{
    font-size: 0.82rem;
  }

  input[type="search"], select{
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .container{
    max-width: 1280px;
    margin: 20px auto;
    padding: 0 20px 40px;
  }

  .counter{
    font-size: 0.95rem;
    margin: 8px 2px 12px;
  }

  /* Grid: 3 columnas en desktop small */
  .grid{
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  .card{
    border-radius: var(--radius);
    padding:16px;
    gap: 8px;
  }

  .card h3{
    font-size: 1.05rem;
  }

  .card p{
    font-size: 0.9rem;
  }

  .chip{
    font-size:.72rem;
    padding:6px 10px;
  }

  input[type="search"], select{
    min-width: 220px;
  }

  .modal{
    max-width: 780px;
  }

  .modal-card{
    padding: 20px 28px;
  }

  .modal-header h2{
    font-size: 1.25rem;
  }

  .modal-body{
    padding: 18px 6%;
    line-height:1.7;
    font-size: 1rem;
    max-height: calc(85vh - 220px);
  }

  .modal-footer .rating{
    font-size: 1rem;
  }

  #modal-stars{
    letter-spacing:4px; 
    font-size:1.2rem;
  }

  .site-footer{
    padding: 16px 20px;
    font-size: 0.9rem;
  }
}

/* ===========================
   DESKTOP LARGE (1200px+)
   =========================== */
@media (min-width: 1200px) {
  .container { 
    max-width: 1320px;
  }

  /* Grid: 4 columnas en desktop large */
  .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
  }

  .card h3{
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  .modal{
    max-width: 1100px;
  }
}

/* ===========================
   DESKTOP ULTRA-WIDE (1600px+)
   =========================== */
@media (min-width: 1600px) {
  .grid {
    gap: 26px;
  }
}


/* MODAL ESTUDIANTES COMPLETADOS */
.modal-estudiantes {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-estudiantes::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-container-estudiantes {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal-header-estudiantes {
  background: linear-gradient(135deg, #0b5ed7 0%, #003B8E 100%);
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
}

.modal-header-estudiantes h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.btn-close-modal {
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
}

.btn-close-modal:hover {
  transform: scale(1.1);
  opacity: 0.8;
}

.modal-body-estudiantes {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-alert {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.modal-alert:empty {
  display: none;
}

.modal-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
  font-size: 15px;
}

.modal-textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.3s;
}

.modal-textarea:focus {
  outline: none;
  border-color: #0b5ed7;
  box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.1);
}

.modal-instructions {
  background: #f8fafc;
  border-left: 4px solid #0b5ed7;
  padding: 16px;
  margin-top: 16px;
  border-radius: 6px;
}

.modal-instructions p {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: #1e293b;
  font-size: 14px;
}

.modal-instructions ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

.modal-instructions li {
  margin: 4px 0;
  font-size: 13px;
  color: #475569;
}

.modal-footer-estudiantes {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border-radius: 0 0 12px 12px;
}

.modal-footer-estudiantes .btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
}

.modal-footer-estudiantes .btn-primary {
  background: #0b5ed7;
  color: white;
}

.modal-footer-estudiantes .btn-primary:hover {
  background: #0a58ca;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(11, 94, 215, 0.3);
}

.modal-footer-estudiantes .btn-secondary {
  background: #e2e8f0;
  color: #475569;
}

.modal-footer-estudiantes .btn-secondary:hover {
  background: #cbd5e1;
}

.btn-estudiantes-especificos {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f0f9ff;
  color: #0369a1;
  border: 2px solid #bae6fd;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 8px;
}

.btn-estudiantes-especificos:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(3, 105, 161, 0.2);
}

@media (max-width: 600px) {
  .modal-estudiantes {
    width: 95%;
    max-width: none;
  }
  
  .modal-header-estudiantes {
    padding: 16px 20px;
  }
  
  .modal-header-estudiantes h3 {
    font-size: 16px;
  }
  
  .modal-body-estudiantes {
    padding: 20px;
  }
  
  .modal-textarea {
    font-size: 12px;
  }
  
  .modal-footer-estudiantes {
    flex-direction: column;
  }
  
  .modal-footer-estudiantes .btn {
    width: 100%;
  }
}