/* ============================= */
/* TEMA PRETO PROFUNDO */
/* ============================= */

* {
    box-sizing: border-box;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    margin: 20px;
    background-color: #000000;
    color: #e5e5e5;
}

/* ============================= */
/* TÍTULOS */
/* ============================= */

h1 {
    margin-bottom: 12px;
    font-weight: 600;
}

h2 {
    margin-top: 0;
}

/* ============================= */
/* OPTATIVAS BOX */
/* ============================= */

.optativas-box {
    padding: 8px 12px;
    background-color: #0a0a0a;
    border: 1px solid #1a3a1a;
    border-radius: 4px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.optativas-box span:first-child {
    color: #999;
    font-size: 14px;
}

.horas-count {
    font-size: 18px;
    font-weight: bold;
    color: #4ade80;
}

.horas-label {
    color: #999;
    font-size: 12px;
}

/* ============================= */
/* PROGRESS CONTAINER */
/* ============================= */

.progress-container {
    padding: 10px 14px;
    background-color: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 4px;
    margin-bottom: 10px;
}

.progress-info {
    margin-bottom: 10px;
    font-size: 13px;
    color: #ccc;
}

.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    flex: 1;
    height: 24px;
    background-color: #1a1a1a;
    border-radius: 4px;
    display: flex;
    overflow: hidden;
    border: 1px solid #333;
    position: relative;
}

.progress-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #000;
    font-weight: bold;
    transition: width 0.3s ease;
}

.progress-segment.aprobadas {
    background-color: #22c55e;
}

.progress-segment.regularizadas {
    background-color: #f97316;
}

.progress-segment.optativas {
    background-color: #22d3ee;
}

.progress-segment.puede-cursar {
    background-color: #666666;
}

.progress-percent {
    font-size: 12px;
    color: #999;
    min-width: 40px;
    text-align: right;
}


/* ============================= */
/* EXTENSION FORM */
/* ============================= */

.extension-form {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.extension-form input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #222;
    background-color: #111;
    color: white;
    border-radius: 4px;
    font-size: 12px;
}

.extension-form input:last-of-type {
    flex: 0.5;
}

.extension-form button {
    padding: 6px 10px;
    background-color: #111;
    border: 1px solid #222;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.extension-form button:hover {
    background-color: #1c1c1c;
}

/* texto de proyectos de extensión */
.extension-nombre {
    color: #86efac;
}

/* texto de materias optativas */
.optativa-nombre {
    color: #22d3ee;
}

/* ============================= */
/* TOP BAR */
/* ============================= */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.top-bar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.top-bar-controls label {
    font-size: 12px;
    color: #999;
}

.top-bar-divider {
    color: #333;
    margin: 0 4px;
}

.top-bar-controls button {
    min-width: 100px;
}

.top-bar-controls input {
    padding: 6px 8px;
    border: 1px solid #222;
    background-color: #111;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    width: 80px;
}

.top-bar-controls label {
    font-size: 12px;
    color: #999;
}

.top-bar-divider {
    color: #333;
    margin: 0 4px;
}

.btn-danger {
    background-color: transparent !important;
    border: 1px solid #444 !important;
    color: #fff !important;
    font-weight: bold;
    font-size: 12px !important;
    padding: 8px 16px !important;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background-color: #222 !important;
    border-color: #666 !important;
}

.btn-help {
    margin-left: auto;
    background-color: transparent !important;
    border: 1px solid #333 !important;
    color: #22d3ee !important;
    font-weight: bold;
    font-size: 11px !important;
    padding: 6px 12px !important;
    letter-spacing: 1px;
}

.btn-help:hover {
    background-color: #22d3ee11 !important;
    border-color: #22d3ee !important;
}

.btn-primary {
    background-color: transparent !important;
    border: 1px solid #444 !important;
    color: #fff !important;
    font-weight: bold;
    font-size: 12px !important;
    padding: 8px 16px !important;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: #222 !important;
    border-color: #666 !important;
}

.btn-primary:hover {
    background-color: #ffffff11 !important;
    border-color: #666 !important;
}

/* ============================= */
/* LEGEND BOX (REMOVED) */
/* ============================= */

/* ... styles removed ... */

/* ============================= */
/* OPTATIVAS BOX */
/* ============================= */

.listas {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.listas div {
    background-color: #0a0a0a;
    border: 1px solid #111;
    border-radius: 6px; /* menos arredondado */
}

/* ============================= */
/* ITEMS */
/* ============================= */

ul {
    padding-left: 8px;
    margin: 6px 0;
}

li {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #111;
    font-size: 14px;
}

/* Item row para no puede cursar - dois boxes na mesma linha */
li.item-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.item-box {
    display: flex;
    align-items: center;
    gap: 4px;
}

.item-nombre {
    flex: 0 1 300px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.item-requisitos {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1 0 auto;
    align-items: center;
    gap: 8px;
}

/* container holding progress bar/count and buttons, pushed to right */
.right-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* Container info-row para no puede cursar */
.info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    justify-content: space-between;
}

/* Progress fica à esquerda */
.info-row .progress {
    margin-right: auto;
}

/* Nome da matéria */
li span:first-child {
    flex: 1;
}

/* tag de año */
.anio-tag {
    font-size: 12px;
    color: #999;
    opacity: 0.8;
    margin-left: 8px;
    font-weight: normal;
    white-space: normal;
    min-width: 50px;
}

/* ============================= */
/* BOTÕES DE ESTADO */
/* ============================= */

.btn-warning-faltantes {
    background: none !important;
    border: none !important;
    color: #facc15 !important;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px !important;
    margin-left: 4px;
    display: inline-block !important; /* Forçar exibição */
    vertical-align: middle;
}

.btn-warning-faltantes:hover {
    transform: scale(1.2);
    background: transparent !important;
}

li button {
    font-size: 12px;
    padding: 4px 6px;
    background-color: transparent;
    border: none;
}

/* ============================= */
/* MODAL / POPUP */
/* ============================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.modal-content {
    background-color: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 24px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 14px;
    color: #facc15;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-close-x {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none !important;
    border: none !important;
    color: #999 !important;
    font-size: 20px !important;
    cursor: pointer;
    padding: 0 !important;
    line-height: 1;
}

.modal-close-x:hover {
    color: #fff !important;
}

.modal-content ul {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    border-top: 1px solid #222;
}

.modal-content li {
    padding: 10px 0;
    border-bottom: 1px solid #222;
    background: transparent;
    font-size: 14px;
    color: #ccc;
    display: block;
}

.modal-content button {
    cursor: pointer;
    transition: background 0.2s;
}

.modal-content button:hover {
    background-color: #333 !important;
}

/* Aprovar */
li button:nth-child(2) {
    color: #22c55e;
}

/* Regularizar */
li button:nth-child(3) {
    color: #facc15;
}

/* Reset */
li button:nth-child(4) {
    color: #ef4444;
}

li button:hover {
    background-color: #222;
}

/* Ocultar los botones dentro de "No puede cursar" */
#noPuedeCursar li button,
#noPuedeCursar-obligatorias li button,
#noPuedeCursar-optativas li button {
    display: none;
}

/* estilos anteriores de ocultar botones están obsoletos; ahora el JS decide qué mostrar */

/* ============================= */
/* REGULARIZADAS SUBDIVISÕES */
/* ============================= */

.regularizadas-box {
    background-color: #0a0a0a;
    padding: 10px;
    border: 1px solid #111;
    border-radius: 4px;
}

/* Cada seção interna */
.sub-section {
    margin-top: 4px;
}

/* Título interno menor */
.sub-section h4 {
    margin-bottom: 8px;
    font-size: 15px;
    opacity: 0.8;
}

/* Header colapsável para subsections de optativas */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    transition: opacity 0.2s ease;
}

.collapsible-header:hover {
    opacity: 0.9;
}

/* Conteúdo colapsável dentro de sub-sections */
.sub-content {
    overflow: hidden;
    max-height: none;
    opacity: 1;
    transition:
        max-height 0.3s ease,
        opacity 0.2s ease;
}

/* Quando sub-content está colapsado */
.sub-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Esconde automaticamente quando vazio */
.sub-section:has(ul:empty) {
    display: none;
}

/* Remove espaço se estiver vazio */
.sub-section ul:empty + * {
    margin-top: 0;
}

/* barra de progresso ao lado direito */
.progress {
    margin-left: 6px;
    opacity: 0.9;
    font-size: 12px;
}

/* missing requirement label */
.falta {
    font-size: 12px;
    opacity: 0.75;
    margin-right: 4px;
    white-space: normal;
}

/* emoji progress spacing */
.progress-emoji {
    margin-left: 4px;
}

.progress-bar-inner {
    height: 100%;
    background-color: #fff;
    transition: width 0.3s;
    border-radius: 3px;
}

/* when only one requirement remains */
.progress-bar.almost .progress-bar-inner {
    background-color: #facc15; /* amarillo */
}

/* ============================= */
/* FECHAS DE FINALES */
/* ============================= */

.fechas-proximas {
    display: inline;
    font-size: 12px;
    color: #22d3ee !important;
    margin-left: 4px;
}

.fechas-proximas.urgente {
    color: #f97316;
    font-weight: bold;
}

.btn-calendario {
    background: none !important;
    border: none !important;
    color: #22d3ee !important;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px !important;
    vertical-align: middle;
}

.btn-calendario:hover {
    transform: scale(1.2);
}

.catedra-select {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 15px;
    background-color: #111;
    border: 1px solid #333;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
}

.fechas-section-title {
    font-size: 13px;
    color: #22d3ee;
    margin: 15px 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fecha-item {
    font-weight: bold;
    color: #fff;
}

.fecha-item-anterior {
    color: #777;
}

.fechas-container {
    max-height: 300px;
    overflow-y: auto;
}

/* ============================= */
/* BOX COLAPSÁVEL AJUSTADO */
/* ============================= */

.box {
    padding: 10px 12px;
    border: 1px solid #111;
    border-radius: 4px;
    background-color: #0a0a0a;
    transition: all 0.25s ease;
}

/* Quando o box estiver colapsado */
.box:has(.box-content.collapsed) {
    padding: 10px 10px;
}

.box h3 {
    margin-left: 14px;
}

/* Conteúdo interno */
.box-content {
    overflow: hidden;
    max-height: none;
    opacity: 1;
    transition:
        max-height 0.3s ease,
        opacity 0.2s ease,
        margin 0.25s ease;
}

/* Quando fechado */
.box-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

/* 🔥 Reduz ainda mais o espaço quando fechado */
.box:has(.box-content.collapsed) {
    padding: 2px;
}

/* ============================= */
/* RESPONSIVIDADE MOBILE */
/* ============================= */

@media (max-width: 768px) {

    body {
        margin: 10px;
    }

    /* Grid vira 1 coluna no celular */
    .listas {
        grid-template-columns: 1fr;
    }

    /* Top bar - layout vertical */
    .top-bar {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .top-bar-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .top-bar-controls label {
        width: auto;
        font-size: 14px; /* Aumentar legibilidade */
    }

    .top-bar-controls input {
        flex: 0 0 80px;
        min-height: 44px; /* Tamanho mínimo para toque */
        font-size: 16px; /* Tamanho recomendado para inputs */
    }

    .top-bar-divider {
        display: none;
    }

    .top-bar-controls button {
        flex: 1;
        min-width: auto;
        min-height: 44px; /* Tamanho mínimo para toque */
        font-size: 16px;
    }

    .btn-help {
        width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    /* Optativas box */
    .optativas-box {
        flex-wrap: wrap;
        padding: 12px; /* Mais espaçamento para toque */
    }

    .optativas-box span:first-child {
        width: 100%;
        font-size: 14px;
    }

    .horas-count {
        font-size: 20px; /* Maior para destaque */
    }

    .horas-label {
        font-size: 14px;
    }

    /* Legend box */
    .legend-box {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Extension form - layout vertical */
    .extension-form {
        flex-direction: column;
        gap: 10px;
    }

    .extension-form input,
    .extension-form button {
        width: 100%;
        min-height: 44px; /* Tamanho mínimo para toque */
        font-size: 16px;
    }

    /* Inputs e buttons */
    select, input, button {
        max-width: 100%;
        min-height: 44px; /* Tamanho mínimo para toque */
        font-size: 16px;
    }

    /* LI ITEMS - layout para no pode cursar */
    li {
        display: flex;
        flex-wrap: wrap;
        padding: 12px; /* Mais espaçamento para toque */
        margin-bottom: 10px;
    }

    /* No pode cursar - dois boxes em linhas separadas no mobile */
    li.item-row {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .item-box {
        width: 100%;
    }

    .item-nombre {
        min-width: 100%;
        max-width: 100%;
        flex: none;
        font-size: 16px;
    }

    .item-requisitos {
        justify-content: flex-start;
        flex: none;
        width: 100%;
    }

    li span:first-child {
        width: 100%;
        margin-bottom: 6px;
        font-size: 16px;
    }

    /* Container da linha 2 (Falta + Emoji + Ano + Progress) */
    .info-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
        justify-content: flex-start;
    }

    .info-row .falta,
    .info-row .progress-emoji,
    .info-row .anio-tag,
    .info-row .progress {
        display: inline;
        width: auto;
        margin-left: 0;
        font-size: 14px;
    }

    /* Right group com botões alinhado à direita */
    .right-group {
        display: flex;
        margin-left: auto;
        gap: 10px;
    }

    .fechas-proximas {
        margin-left: 0;
        margin-top: 6px;
        font-size: 14px;
    }

    li button {
        width: auto;
        min-height: 40px; /* Tamanho mínimo para toque */
        font-size: 16px;
    }

    /* Botões de ação específicos */
    .btn-warning-faltantes,
    .btn-calendario {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Boxes */
    .box {
        padding: 12px; /* Mais espaçamento interno */
        margin-bottom: 12px;
    }

    .box h3 {
        font-size: 18px;
        padding: 8px;
    }

    h1 {
        font-size: 22px; /* Título maior para mobile */
        text-align: center;
    }
    
    /* Barra de progresso */
    .progress-container {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .progress-bar {
        height: 28px; /* Barra mais alta para toque */
    }
    
    .progress-percent {
        font-size: 14px;
        min-width: 50px;
    }
}

    /* Grid vira 1 coluna no celular */
    .listas {
        grid-template-columns: 1fr;
    }

    /* Top bar - layout vertical */
    .top-bar {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .top-bar-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .top-bar-controls label {
        width: auto;
    }

    .top-bar-controls input {
        flex: 0 0 80px;
    }

    .top-bar-divider {
        display: none;
    }

    .top-bar-controls button {
        flex: 1;
        min-width: auto;
    }

    .btn-help {
        width: 100%;
    }

    /* Optativas box */
    .optativas-box {
        flex-wrap: wrap;
    }

    .optativas-box span:first-child {
        width: 100%;
    }

    /* Legend box */
    .legend-box {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Extension form - layout vertical */
    .extension-form {
        flex-direction: column;
    }

    .extension-form input,
    .extension-form button {
        width: 100%;
    }

    /* Inputs e buttons */
    select, input, button {
        max-width: 100%;
    }

    /* LI ITEMS - layout para no puede cursar */
    li {
        display: flex;
        flex-wrap: wrap;
        padding: 8px;
        margin-bottom: 8px;
    }

    /* No puede cursar - dois boxes em linhas separadas no mobile */
    li.item-row {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }

    .item-box {
        width: 100%;
    }

    .item-nombre {
        min-width: 100%;
        max-width: 100%;
        flex: none;
    }

    .item-requisitos {
        justify-content: flex-start;
        flex: none;
        width: 100%;
    }

    li span:first-child {
        width: 100%;
        margin-bottom: 4px;
    }

    /* Container da linha 2 (Falta + Emoji + Ano + Progress) */
    .info-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        justify-content: flex-start;
    }

    .info-row .falta,
    .info-row .progress-emoji,
    .info-row .anio-tag,
    .info-row .progress {
        display: inline;
        width: auto;
        margin-left: 0;
    }

    /* Right group com botões alinhado à direita */
    .right-group {
        display: flex;
        margin-left: auto;
    }

    .fechas-proximas {
        margin-left: 0;
        margin-top: 4px;
    }

    li button {
        width: auto;
    }

    /* Boxes */
    .box {
        padding: 8px;
    }

    h1 {
        font-size: 18px;
    }
