/* --- Layout general --- */

.taskboard-wrapper {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 16px 60px;
    min-height: 70vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2933;
}

/* Header general */

.tb-header {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 24px;
}

.tb-title-main {
    font-size: 2.1rem;
    margin: 0;
}

/* Controles: dos filas bien separadas (fila 1 = buscador+botones, fila 2 = filtros) */

.tb-controls {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Fila buscador + botones (escritorio: una sola fila) */

.tb-controls-row-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: nowrap;
}

/* Buscador: ocupa el 50% de la fila */

.tb-controls-row-search .tb-search {
    flex: 0 0 50%;
    max-width: 50%;
    width: 100%;
    min-width: 260px;
}

/* Contenedor de botones: ocupa el otro 50% */

.tb-actions {
    flex: 0 0 50%;
    max-width: 50%;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* Fila de filtros debajo: a lo ancho, con aire */

.tb-controls-row-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tb-controls-row-filters .tb-select {
    flex: 1 1 0;
    min-width: 180px;
}

/* Inputs, selects y botones */

.tb-input,
.tb-select,
.tb-btn {
    font-size: 0.9rem;
}

.tb-input,
.tb-select {
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #d0d7e2;
    background-color: #ffffff;
    min-width: 120px;
}

.tb-input:focus,
.tb-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79,70,229,0.15);
}

.tb-search {
    min-width: 220px;
}

.tb-btn {
    border-radius: 999px;
    border: none;
    padding: 6px 14px;
    background: #f3f4ff;
    color: #111827;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.tb-btn:hover {
    background: #e0e7ff;
}

.tb-btn:active {
    transform: translateY(1px);
}

.tb-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
}

.tb-btn-primary:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
}

.tb-btn-danger {
    background-color: #dc2626;
    color: #ffffff;
}

.tb-btn-danger:hover {
    background-color: #b91c1c;
}

/* --- Contenedor de tabla principal --- */

.tb-table-wrapper {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    padding: 20px 18px;
    overflow-x: auto;
    min-height: 320px;
}

/* Tabla principal con pequeño margen abajo para separar de archivadas */

.tb-table-main {
    margin-bottom: 2.5rem;
}

/* --- Tabla --- */

.tb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tb-table thead {
    background: #f9fafb;
}

.tb-table th,
.tb-table td {
    padding: 14px 10px;
    text-align: left;
    white-space: normal;
}

.tb-table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.tb-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
}

.tb-col-title {
    font-weight: 500;
    color: #111827;
}

.tb-empty {
    margin: 16px;
    font-size: 0.9rem;
    color: #6b7280;
}

/* Fechas sin partir en varias líneas (pedido y cierres) */

.tb-table th:nth-child(5),
.tb-table th:nth-child(7),
.tb-table th:nth-child(8),
.tb-table td:nth-child(5),
.tb-table td:nth-child(7),
.tb-table td:nth-child(8) {
    white-space: nowrap;
}

/* --- Pills de prioridad, estado y sector --- */

.tb-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Prioridades: 1=Normal, 2=Requerida, 3=Máxima */

.tb-pill-priority-1 {
    background: #dcfce7;
    color: #166534;
}

.tb-pill-priority-2 {
    background: #fef9c3;
    color: #92400e;
}

.tb-pill-priority-3 {
    background: #fee2e2;
    color: #b91c1c;
}

/* Estados: open, progress, suspended, done */

.tb-pill-status-open {
    background: #e0f2fe;
    color: #075985;
}

.tb-pill-status-progress {
    background: #fef3c7;
    color: #92400e;
}

.tb-pill-status-suspended {
    background: #f3e8ff;
    color: #6b21a8;
}

.tb-pill-status-done {
    background: #dcfce7;
    color: #166534;
}

/* Badge para SECTOR */

.tb-pill-sector {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 500;
}

.taskboard-loading,
.taskboard-error {
    text-align: center;
    padding: 40px 0;
}

.taskboard-error {
    color: #b91c1c;
}

/* --- Modal --- */

.tb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.tb-modal {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(15,23,42,0.25);
}

.tb-modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tb-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.tb-modal-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    cursor: pointer;
}

.tb-modal-body {
    padding: 16px 18px;
    overflow-y: auto;
}

.tb-modal-footer {
    padding: 12px 18px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.tb-field-row {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tb-field-row label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.tb-checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Lista de sectores en el modal --- */

.tb-sector-list {
    margin-bottom: 12px;
}

.tb-sector-ul {
    margin: 0 0 10px 0;
    padding: 0;
    list-style: none;
}

.tb-sector-ul li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    padding: 4px 8px;
    border-radius: 8px;
    background: #f9fafb;
    margin-bottom: 4px;
}

.tb-sector-ul li span {
    flex: 1;
}

.tb-sector-delete {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #9ca3af;
    padding: 0 4px;
}

.tb-sector-delete:hover {
    color: #ef4444;
}

/* --- Tarjetas de resumen --- */

.tb-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    padding: 12px 18px;
}

.tb-summary-card {
    flex: 1 1 160px;
    min-width: 0;
    border-radius: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tb-summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}

.tb-summary-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}

.tb-summary-total {
    background: linear-gradient(135deg, rgba(79,70,229,0.12), #f9fafb);
}

.tb-summary-open {
    background: linear-gradient(135deg, rgba(14,165,233,0.12), #f9fafb);
}

.tb-summary-progress {
    background: linear-gradient(135deg, rgba(249,115,22,0.12), #f9fafb);
}

.tb-summary-done {
    background: linear-gradient(135deg, rgba(22,163,74,0.12), #f9fafb);
}

/* --- Fila coloreada por prioridad y finalizadas --- */

.tb-table tbody tr.tb-row {
    transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}

.tb-table tbody tr.tb-row-priority-3 {
    background: linear-gradient(to right, rgba(248, 113, 113, 0.15), transparent);
}

.tb-table tbody tr.tb-row-priority-2 {
    background: linear-gradient(to right, rgba(250, 204, 21, 0.15), transparent);
}

.tb-table tbody tr.tb-row-priority-1 {
    background: linear-gradient(to right, rgba(52, 211, 153, 0.10), transparent);
}

/* Las tareas FINALIZADAS con un tinte verdoso suave */

.tb-table tbody tr.tb-row-status-done {
    background: linear-gradient(to right, rgba(34, 197, 94, 0.12), transparent);
}

.tb-table tbody tr.tb-row:hover {
    background: rgba(249, 250, 251, 0.98);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

/* --- Números alineados (columna %) --- */

.tb-table td:nth-child(9) {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* --- Barra de progreso en la columna % --- */

.tb-progress {
    position: relative;
    width: 80px;
    height: 8px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.tb-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #22c55e);
    border-radius: inherit;
    transition: width 0.2s ease-out;
}

.tb-progress-text {
    margin-left: 6px;
    font-size: 0.78rem;
    color: #4b5563;
    vertical-align: middle;
}

/* --- Historial en el modal --- */

.tb-history {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

.tb-history-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 4px;
}

.tb-history-body {
    font-size: 0.8rem;
    color: #4b5563;
}

.tb-history-list {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.tb-history-list li {
    margin-bottom: 3px;
}

.tb-history-empty {
    font-size: 0.78rem;
    color: #9ca3af;
}

/* --- Botón "Cargar más" --- */

.tb-load-more-wrap {
    margin-top: 12px;
    text-align: center;
}

.tb-load-more-btn {
    padding: 8px 18px;
    border-radius: 999px;
    border: none;
    background: #f3f4ff;
    cursor: pointer;
    font-size: 0.9rem;
}

.tb-load-more-btn:hover {
    background: #e0e7ff;
}

/* --- Login wrapper --- */

.tb-notes-textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.4;
}

.taskboard-login-wrapper {
    max-width: 420px;
    margin: 40px auto;
    padding: 24px 20px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    border: 1px solid #e5e7eb;
}

.taskboard-login-title {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    text-align: center;
}

.taskboard-login-subtitle {
    margin: 0 0 16px;
    font-size: 14px;
    color: #6b7280;
    text-align: center;
}

/* Ajustes al formulario nativo de WP dentro del wrapper */

.taskboard-login-wrapper form {
    margin-top: 8px;
}

.taskboard-login-wrapper .login-username,
.taskboard-login-wrapper .login-password,
.taskboard-login-wrapper .login-remember {
    margin-bottom: 12px;
}

.taskboard-login-wrapper label {
    font-size: 13px;
    color: #374151;
    display: block;
    margin-bottom: 4px;
}

.taskboard-login-wrapper input.input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    box-sizing: border-box;
}

.taskboard-login-wrapper .login-submit input[type="submit"] {
    width: 100%;
    border-radius: 999px;
    background-color: #2563eb;
    border: none;
    color: #ffffff;
    padding: 8px 12px;
    font-weight: 500;
    cursor: pointer;
}

.taskboard-login-wrapper .login-submit input[type="submit"]:hover {
    background-color: #1d4ed8;
}

/* --- Sección de tareas archivadas (finalizadas / suspendidas) --- */

.tb-archived-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #ececec;
}

.tb-subtitle-archived {
    margin: 0 0 16px;
    font-size: 1.4rem;
    font-weight: 600;
}

.tb-table-archived {
    margin-top: 0.75rem;
}

/* --- Responsive general --- */

@media (max-width: 900px) {
    .taskboard-wrapper {
        margin-top: 20px;
        padding-bottom: 40px;
    }

    .tb-table-wrapper {
        padding: 12px;
        overflow-x: auto;
    }

    /* En pantallas chicas, apilamos buscador y botones */
    .tb-controls-row-search {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: wrap;
    }

    .tb-controls-row-search .tb-search,
    .tb-actions {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .tb-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .tb-table th,
    .tb-table td {
        padding: 10px 6px;
        vertical-align: top;
    }
}

/* En pantallas muy chicas ocultamos % y Notas para que no explote el ancho */

@media (max-width: 640px) {
    .tb-table th:nth-child(9),
    .tb-table th:nth-child(10),
    .tb-table td:nth-child(9),
    .tb-table td:nth-child(10) {
        display: none;
    }

    .tb-summary {
        gap: 8px;
    }

    .tb-summary-card {
        padding: 6px 8px;
    }
}

/* === Ajuste de alineación header vs. filtros y tabla === */

/* El header usa el mismo padding lateral interno que las tarjetas */
.tb-header {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 24px;
    padding: 0 18px; /* clave: igual que las tarjetas */
}

/* Aseguramos que el bloque de controles siga ocupando todo el ancho disponible */
.tb-controls {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Fila buscador + botones, igual que antes pero dentro del nuevo padding */
.tb-controls-row-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: nowrap;
}

/* Buscador: 50% de la fila aprox. */
.tb-controls-row-search .tb-search {
    flex: 0 0 50%;
    max-width: 50%;
    width: 100%;
    min-width: 260px;
}

/* Botones: otro 50%, alineados a la derecha */
.tb-actions {
    flex: 0 0 50%;
    max-width: 50%;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* Fila de filtros debajo, a lo ancho */
.tb-controls-row-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tb-controls-row-filters .tb-select {
    flex: 1 1 0;
    min-width: 180px;
}

/* Responsive: en pantallas chicas apilamos buscador y botones */
@media (max-width: 900px) {
    .tb-controls-row-search {
        flex-direction: column;
        align-items: stretch;
    }

    .tb-controls-row-search .tb-search,
    .tb-actions {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .tb-actions {
        justify-content: flex-start;
    }
}

