/* Botón flotante de To-Do - Estilo Pill saliendo de la sidebar */
.komexship-todo-float-btn {
    --todo-sidebar-width: 280px;
    position: fixed;
    bottom: 20px; /* Posición desde abajo */
    left: var(--todo-sidebar-width); /* Exactamente donde termina la sidebar */
    height: 48px; /* Solo lo necesario para el icono */
    width: 48px; /* Visible igual que antes, el resto queda oculto bajo la sidebar */

    padding: 0;
    background: #ff6a2a;
    border-radius: 0 24px 24px 0; /* Pill shape: redondeado a la derecha arriba y abajo */
    border: none;
    box-shadow: 4px -4px 20px rgba(255, 90, 7, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2 !important; /* Queda debajo del sidebar (z-index: 3) pero encima del contenido */
    animation: todoSlideFromSidebar 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform; /* Asegura que mantenga su z-index durante animaciones */
    --todo-pill-hidden-length: 140px; /* Ancho adicional que se mantiene bajo la sidebar */
}

.komexship-todo-float-btn::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 100%;
    width: var(--todo-pill-hidden-length);
    background: #ff6a2a;
    border-radius: 24px 0 0 24px;
    pointer-events: none;
}



.komexship-todo-float-btn:hover {
    transform: translateX(8px);
    box-shadow: 6px -6px 28px rgba(255, 90, 7, 0.45);
    z-index: 2 !important; /* Mantener por debajo del sidebar incluso en hover */
}

.komexship-todo-float-btn:active {
    transform: translateX(4px);
    z-index: 2 !important; /* Mantener por debajo del sidebar incluso en active */
}

.komexship-todo-float-btn .material-icons {
    font-size: 24px;
    transition: transform 0.3s ease;
}

.komexship-todo-float-btn:hover .material-icons {
    transform: scale(1.1);
}

.komexship-panel.komexship-todo-open .komexship-todo-float-btn {
    transform: translateX(24px);
    opacity: 0;
    pointer-events: none;
}

.komexship-panel.komexship-todo-open .komexship-todo-float-btn {
    transform: translateX(24px);
    opacity: 0;
    pointer-events: none;
}

/* Ajuste cuando el sidebar está colapsado */
@media (min-width: 1081px) {
    .komexship-app.sidebar-collapsed ~ .komexship-todo-float-btn {
        --todo-sidebar-width: 96px; /* Donde termina el sidebar colapsado */
        --todo-pill-hidden-length: 80px; /* Sidebar más angosto, ocultamos menos tramo */
        transition: left 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    }

    .komexship-app:not(.sidebar-collapsed) ~ .komexship-todo-float-btn {
        --todo-sidebar-width: 280px; /* Donde termina el sidebar expandido */
        --todo-pill-hidden-length: 140px;
        transition: left 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    }
}



/* Overlay del área de contenido (sin blur sobre la sidebar) */
.komexship-todo-overlay {
    --todo-sidebar-width: 280px;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--todo-sidebar-width);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.12) 0%, rgba(15, 23, 42, 0.34) 100%);
    backdrop-filter: blur(12px);
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.komexship-todo-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.komexship-app.sidebar-collapsed ~ .komexship-todo-overlay {
    --todo-sidebar-width: 96px;
}

/* Panel de To-Do - Desliza desde la sidebar */
.komexship-todo-modal {
    --todo-sidebar-width: 280px;
    --todo-panel-pocket: 32px;
    position: fixed;
    left: calc(var(--todo-sidebar-width) - var(--todo-panel-pocket));
    right: clamp(24px, 4vw, 56px);
    top: clamp(28px, 6vh, 72px);
    bottom: clamp(28px, 6vh, 72px);
    background: #ffffff;
    border-radius: 26px;
    box-shadow: 0 28px 64px rgba(15, 23, 42, 0.25);
    z-index: 2;
    transform: translateX(calc(-100% - var(--todo-panel-pocket))); /* Oculto por completo debajo de la sidebar */
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0.55s;
    overflow: hidden;
    display: flex;
}

.komexship-todo-modal::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--todo-panel-pocket);
    background: linear-gradient(180deg, rgba(255, 90, 7, 0.16) 0%, rgba(255, 90, 7, 0.08) 100%);
    box-shadow: inset -1px 0 0 rgba(255, 90, 7, 0.25);
    pointer-events: none;
}

.komexship-todo-modal-inner {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--todo-panel-pocket);
    width: calc(100% - var(--todo-panel-pocket));
    border-radius: inherit;
}

.komexship-todo-modal.active {
    transform: translateX(0); /* Se desliza desde la sidebar hacia la derecha */
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s;
}

.komexship-app.sidebar-collapsed ~ .komexship-todo-modal {
    --todo-sidebar-width: 96px;
    --todo-panel-pocket: 20px;
}


/* Header del modal */
.komexship-todo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.komexship-todo-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #1f2937;
}

.komexship-todo-modal-title .material-icons {
    font-size: 28px;
    color: #ff5a07;
}

.komexship-todo-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(15, 23, 42, 0.05);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
}

.komexship-todo-modal-close:hover {
    background: rgba(255, 90, 7, 0.1);
    color: #ff5a07;
    transform: rotate(90deg);
}

.komexship-todo-modal-close .material-icons {
    font-size: 20px;
}

/* Body del modal */
.komexship-todo-modal-body {
    flex: 1;
    padding: 32px 28px;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(120deg, rgba(248, 250, 252, 0.9), rgba(255, 247, 240, 0.9));
}

.komexship-todo-eyebrow {
    margin: 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.komexship-todo-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
    gap: 28px;
    min-height: calc(100% - 24px);
}

.komexship-todo-section {
    background: #fff;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.komexship-todo-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.komexship-todo-summary article {
    background: linear-gradient(135deg, #fff7f1, #fff);
    border-radius: 18px;
    padding: 18px;
    border: 1px solid rgba(255, 90, 7, 0.12);
}

.komexship-todo-summary p {
    margin: 0;
    font-size: 0.9rem;
    color: #64748b;
}

.komexship-todo-summary strong {
    display: block;
    margin-top: 6px;
    font-size: 2rem;
    color: #1f2937;
}

.komexship-todo-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.komexship-todo-filters {
    display: inline-flex;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px;
}

.komexship-todo-filters button {
    border: none;
    background: transparent;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.komexship-todo-filters button.is-active {
    background: #ff5a07;
    color: #fff;
    box-shadow: 0 10px 25px rgba(255, 90, 7, 0.25);
}


.komexship-todo-search {
    position: relative;
    flex: 1;
    min-width: 220px;
    border-radius: 999px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    isolation: isolate;
    min-height: 48px;
    height: 48px;
}

.komexship-todo-search::before,
.komexship-todo-search::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: 0;
    transition: box-shadow 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.komexship-todo-search::before {
    background: linear-gradient(120deg, #ff5a07, #f59e0b, #f97316, #ff5a07);
    background-size: 200% 200%;
    animation: todoSearchGlow 8s linear infinite;
    opacity: 0;
    transform: scale(0.94);
    filter: drop-shadow(0 14px 30px rgba(255, 90, 7, 0.2));
}

.komexship-todo-search::after {
    inset: 2px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08), 0 12px 24px rgba(15, 23, 42, 0.08);
}

.komexship-todo-search .material-icons,
.komexship-todo-search input {
    position: relative;
    z-index: 1;
}

.komexship-todo-search .material-icons {
    color: #ff5a07;
    transition: color 0.3s ease;
}

.komexship-todo-search input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
    background: transparent;
    color: #0f172a;
    min-height: 0;
    height: 100%;
    border-radius: 999px !important;
    padding: 0;
    line-height: 48px;
}

.komexship-todo-search input::placeholder {
    color: #94a3b8;
}

.komexship-todo-search:focus-within::before {
    opacity: 1;
    transform: scale(1);
}

.komexship-todo-search:focus-within::after {
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12), 0 18px 36px rgba(255, 90, 7, 0.25);
}

.komexship-todo-search:focus-within .material-icons {
    color: #e64900;
}

.komexship-todo-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    padding-right: 8px;
}

.komexship-todo-empty {
    text-align: center;
    padding: 48px 16px;
    border: 1px dashed #e2e8f0;
    border-radius: 20px;
    color: #64748b;
    background: #f8fafc;
}

.komexship-todo-empty .material-icons {
    font-size: 40px;
    color: #ff5a07;
    margin-bottom: 8px;
}

.komexship-todo-card {
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 18px 20px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    transition: box-shadow 0.2s ease;
}

.komexship-todo-card:hover {
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.komexship-todo-card.is-done {
    opacity: 0.65;
}

.komexship-todo-card.is-overdue {
    border-color: rgba(239, 68, 68, 0.4);
}

.komexship-todo-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.komexship-todo-card-title {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.komexship-todo-card-title h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1f2937;
}

.komexship-todo-card-title p {
    margin: 2px 0 0 0;
    font-size: 0.9rem;
    color: #94a3b8;
}

.komexship-todo-card-actions {
    display: inline-flex;
    gap: 8px;
}

.komexship-todo-status-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.komexship-todo-status-btn:hover {
    border-color: #ff5a07;
    color: #ff5a07;
}

.komexship-todo-card-actions button {
    border: none;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.komexship-todo-card-actions button:hover {
    background: rgba(255, 90, 7, 0.15);
    color: #ff5a07;
}

.komexship-todo-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.komexship-todo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    background: #f8fafc;
    color: #475569;
}

.komexship-todo-badge.warn {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
}

.komexship-todo-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.komexship-todo-card-relations {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.komexship-todo-card-notes {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 90, 7, 0.05);
    color: #7c2d12;
    font-size: 0.9rem;
}

.komexship-todo-form-head h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1f2937;
}

.komexship-todo-form-head p {
    margin: 4px 0 0 0;
    color: #64748b;
    font-size: 0.9rem;
}

.komexship-todo-field {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.komexship-todo-field span {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #475569;
}

.komexship-todo-field input,
.komexship-todo-field textarea,
.komexship-todo-field-row input,
.komexship-todo-field-row select,
.komexship-todo-field select {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 20px !important;
    padding: 10px 16px;
    font-size: 0.95rem;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    min-height: 48px;
    background: #fff;
    color: #0f172a;
    font-family: inherit;
}

.komexship-todo-field input:focus,
.komexship-todo-field textarea:focus,
.komexship-todo-field-row input:focus,
.komexship-todo-field-row select:focus,
.komexship-todo-field select:focus {
    outline: none;
    border-color: #ff5a07;
    box-shadow: 0 0 0 3px rgba(255, 90, 7, 0.15);
}

.komexship-todo-field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: flex-start;
}

.komexship-todo-field-row label {
    display: flex;
    flex-direction: column;
}

.komexship-todo-field textarea {
    min-height: 120px;
    resize: vertical;
    padding-top: 14px;
    border-radius: 24px !important;
}

.komexship-todo-field-row select,
.komexship-todo-field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath fill='%23ff5a07' d='M7 8L0 0h14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 16px) center;
    padding-right: 38px;
}

.komexship-todo-form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.komexship-todo-section.komexship-todo-form {
    position: sticky;
    top: 16px;
    align-self: flex-start;
    height: fit-content;
}

.komexship-btn-primary {
    background: #ff5a07;
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 0 20px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 15px 30px rgba(255, 90, 7, 0.35);
    min-height: 48px;
}

.komexship-btn-primary:hover {
    background: #f04c00;
}

.komexship-btn-link {
    border: none;
    background: transparent;
    color: #ff5a07;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    min-height: 48px;
    border-radius: 14px;
    padding: 0 16px;
}

#komexshipTodoForm.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.komexship-todo-notices {
    position: sticky;
    top: 0;
    z-index: 5;
}

.komexship-todo-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 16px;
    margin-bottom: 8px;
    background: #e0f2fe;
    color: #075985;
    box-shadow: 0 10px 30px rgba(14, 165, 233, 0.3);
    animation: fadeIn 0.2s ease;
}

.komexship-todo-toast.is-error {
    background: #fee2e2;
    color: #b91c1c;
    box-shadow: 0 10px 30px rgba(248, 113, 113, 0.3);
}

.komexship-todo-toast.is-leaving {
    opacity: 0;
    transform: translateY(-6px);
    transition: all 0.2s ease;
}

@media (max-width: 1200px) {
    .komexship-todo-layout {
        grid-template-columns: 1fr;
    }

    .komexship-todo-section.komexship-todo-form {
        position: static;
        top: auto;
        align-self: auto;
    }

    .komexship-todo-list {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .komexship-todo-field-row {
        grid-template-columns: 1fr;
    }

    .komexship-todo-section {
        padding: 20px;
    }
}

/* Animaciones */
@keyframes todoSlideFromSidebar {
    0% {
        transform: translateX(-100px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes todoSearchGlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}



/* Scrollbar personalizada */
.komexship-todo-modal-body::-webkit-scrollbar {
    width: 8px;
}

.komexship-todo-modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.komexship-todo-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.komexship-todo-modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive */
@media (max-width: 1080px) {
    .komexship-todo-float-btn {
        bottom: 24px;
        left: 24px;
        height: 48px; /* En móvil no necesita ser largo porque no hay sidebar */
        width: 48px;
        padding-top: 0;
        align-items: center; /* Centrado normal en móvil */
        border-radius: 24px; /* En móvil es completamente redondeado */
        z-index: 999; /* En móvil puede tener z-index normal */
        --todo-sidebar-width: 24px;
        --todo-pill-hidden-length: 0px;
    }

    .komexship-panel.komexship-todo-open .komexship-todo-float-btn {
        transform: translateX(0);
    }

    .komexship-todo-overlay {
        --todo-sidebar-width: 0px;
        left: 0;
    }

    .komexship-todo-modal {
        --todo-sidebar-width: 0px;
        --todo-panel-pocket: 0px;
        left: clamp(16px, 4vw, 24px);
        right: clamp(16px, 4vw, 24px);
        top: clamp(64px, 12vh, 92px);
        bottom: clamp(32px, 12vh, 92px);
    }
}

@media (max-width: 640px) {
    .komexship-todo-float-btn {
        bottom: 16px;
        left: 16px;
        height: 44px; /* En móvil no necesita ser largo */
        width: 44px;
        padding-top: 0;
        align-items: center;
        --todo-sidebar-width: 16px;
    }

    .komexship-todo-modal {
        left: 16px;
        right: 16px;
        top: 60px;
        bottom: 60px;
        border-radius: 20px;
    }

    
    .komexship-todo-modal-header {
        padding: 20px;
    }
    
    .komexship-todo-modal-title {
        font-size: 1.2rem;
    }
    
    .komexship-todo-modal-body {
        padding: 24px 20px;
    }
    
}