// =============================================================================
// MATCHA DROP LIST STYLES
// =============================================================================

// Mixin para cores e temas
@mixin matcha-drop-list-theme($theme) {
    $primary: map-get($theme, primary);
    $accent: map-get($theme, accent);
    $warn: map-get($theme, warn);
    $background: map-get($theme, background);
    $foreground: map-get($theme, foreground);

    // =============================================================================
    // COMPONENTE PRINCIPAL
    // =============================================================================

    .matcha-drop-list {
        display: block;
        position: relative;
    }

    // =============================================================================
    // CONTAINER DAS LISTAS
    // =============================================================================

    .matcha-drop-list-container {
        position: relative;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 0px;
        border-radius: 8px;
        border-width: 0px;
        transition: all 0.2s ease;

        &.matcha-drop-list-receiving {
            background-color: getPrimaryAlpha($theme);
            border-color: getPrimary($theme);
            border-width: 2px;
            border-style: dashed;
            border-radius: 8px;
            padding: 8px;
            transition: all 0.2s ease;

            &::before {
                content: '';
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: linear-gradient(45deg,
                        transparent 25%,
                        getPrimaryAlpha($theme) 25%,
                        getPrimaryAlpha($theme) 50%,
                        transparent 50%,
                        transparent 75%,
                        getPrimaryAlpha($theme) 75%,
                        getPrimaryAlpha($theme));
                background-size: 16px 16px;
                animation: drop-zone-animation 2s linear infinite;
                border-radius: 6px;
                opacity: 0.4;
            }
        }

        // Estados de aceitação de drop
        &.matcha-drop-list-can-accept {
            background-color: getGreenAlpha($theme);
            border-color: getGreen($theme);
            cursor: copy;

            &::before {
                background: linear-gradient(45deg,
                        transparent 25%,
                        getGreenAlpha($theme) 25%,
                        getGreenAlpha($theme) 50%,
                        transparent 50%,
                        transparent 75%,
                        getGreenAlpha($theme) 75%,
                        getGreenAlpha($theme));
                background-size: 16px 16px;
                animation: drop-zone-animation 1.5s linear infinite;
                opacity: 0.5;
            }
        }



        &.matcha-drop-list-cannot-accept {
            background-color: getRedAlpha($theme);
            border-color: getRed($theme);
            cursor: not-allowed;

            &::before {
                background: linear-gradient(45deg,
                        transparent 25%,
                        getRedAlpha($theme) 25%,
                        getRedAlpha($theme) 50%,
                        transparent 50%,
                        transparent 75%,
                        getRedAlpha($theme) 75%,
                        getRedAlpha($theme));
                background-size: 16px 16px;
                animation: drop-zone-animation 0.8s linear infinite;
                opacity: 0.6;
            }
        }

        &.matcha-drop-list-disabled {
            opacity: 0.6;
            pointer-events: none;
        }
    }

    // =============================================================================
    // DROP ZONE (matchaDropZone directive — reparenting target)
    // =============================================================================

    .matcha-drop-zone-cannot-accept {
        border: 2px dashed getRed($theme) !important;
        border-radius: 8px;
        background-color: getRedAlpha($theme);
        cursor: not-allowed;
        transition: background-color 0.15s linear, border-color 0.15s linear;
    }

    // Fix C: quando o drop zone pai está rejeitado (vermelho), a lista filha
    // recebendo o drag também deve ficar vermelha — não verde.
    .matcha-drop-zone-cannot-accept .matcha-drop-list-container.matcha-drop-list-receiving {
        background-color: getRedAlpha($theme);
        border-color: getRed($theme);

        &::before {
            background: linear-gradient(45deg,
                transparent 25%, getRedAlpha($theme) 25%, getRedAlpha($theme) 50%,
                transparent 50%, transparent 75%, getRedAlpha($theme) 75%, getRedAlpha($theme));
            background-size: 16px 16px;
            animation: drop-zone-animation 0.8s linear infinite;
            opacity: 0.6;
        }
    }

    // =============================================================================
    // GHOST CLONE (criado dinamicamente no body durante o drag)
    // =============================================================================

    .matcha-drag-ghost {
        pointer-events: none;
        opacity: 0.85;
        z-index: 9999;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
        border-radius: 4px;
        will-change: transform;
    }

    // =============================================================================
    // ITENS ARRASTÁVEIS
    // =============================================================================

    .matcha-drag-item {
        position: relative;
        display: flex;
        padding: 12px;
        border-radius: 6px;
        transition: all 0.2s ease;
        user-select: none;
        background-color: getSurface($theme);
        color: getForeground($theme);

        &:last-child {
            margin-bottom: 0;
        }

        &:hover {
            // box-shadow: 0 0 0 8px getForegroundAlpha($theme);
        }

        &.matcha-drag-dragging {
            z-index: 1000;
            cursor: grabbing;
            position: relative;
            box-shadow: 0 8px 25px getDisabledContrastAlpha($theme);
            background-color: getSurface($theme);
            transform: scale(1.02);
            opacity: 0.95;

            // Efeito de destaque sutil
            &::before {
                content: '';
                position: absolute;
                top: 0px;
                left: 0px;
                right: 0px;
                bottom: 0px;
                border-radius: 8px;
                z-index: -1;
                opacity: 0.1;
                background: linear-gradient(45deg, getSurface($theme), getPrimary($theme));
                animation: drag-glow 1s ease-in-out infinite alternate;
            }
        }

        &.matcha-drag-disabled {
            cursor: not-allowed;
            opacity: 0.7;
        }

        &.disabled-item {
            cursor: not-allowed;
            opacity: 0.7;
        }
    }

    // =============================================================================
    // HANDLE DE DRAG
    // =============================================================================

    .matcha-drag-handle {
        cursor: grab;
        touch-action: none;

        &:active {
            cursor: grabbing;
        }

        &.disabled {
            cursor: not-allowed;
        }
    }

    // =============================================================================
    // CONTEÚDO DOS ITENS
    // =============================================================================

    .item-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;

        .item-title {
            font-weight: 500;
            color: getForeground($theme);

            &.completed {
                text-decoration: line-through;
                opacity: 0.7;
            }
        }

        .item-id {
            font-size: 12px;
            font-family: monospace;
            color: getDisabledContrastAlpha($theme);
        }

        small {
            font-size: 11px;
            font-style: italic;
            color: getForegroundAlpha($theme);
        }
    }

    // =============================================================================
    // AÇÕES DOS ITENS
    // =============================================================================

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

        i {
            font-size: 18px;
        }
    }

    // =============================================================================
    // INDICADOR DE DROP
    // =============================================================================

    .matcha-drop-indicator {
        position: absolute;
        left: 0;
        right: 0;
        height: 2px;
        opacity: 0;
        transition: opacity 0.2s ease;
        transform: translateY(-8px);
        z-index: 1000;
        pointer-events: none;
        margin: 0;
        border-radius: 1px;
        background-color: getAccent($theme);

        &.active {
            opacity: 1;
        }
    }

    // =============================================================================
    // PLACEHOLDER PARA LISTAS VAZIAS
    // =============================================================================

    .matcha-drop-list-placeholder {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10;

        .matcha-drop-list-empty-placeholder {
            font-style: italic;
            padding: 20px;
            text-align: center;
            font-size: 14px;
            border-radius: 4px;
            transition: all 0.2s ease;
            color: getDisabledContrastAlpha($theme);
            border-color: getForegroundAlpha($theme);

            &.can-accept {
                color: getGreen($theme);
                border-color: getGreen($theme);
                background-color: getGreenAlpha($theme);
            }

            &.cannot-accept {
                color: getRed($theme);
                border-color: getRed($theme);
                background-color: getRedAlpha($theme);
                animation: shake 0.5s ease-in-out;
            }
        }
    }

    // =============================================================================
    // HIGH CONTRAST MODE SUPPORT
    // =============================================================================

    @media (prefers-contrast: high) {
        .matcha-drop-list-container.matcha-drop-list-receiving {
            border-color: getForeground($theme);
            background-color: getForegroundAlpha($theme);
        }

        .matcha-drag-item.matcha-drag-dragging {
            border: 2px solid getForeground($theme);
        }
    }
}

// =============================================================================
// ANIMAÇÕES
// =============================================================================

@keyframes drop-zone-animation {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 32px 0, 32px 0, 32px 0;
    }
}

@keyframes pulse-reject {
    0% {
        opacity: 0.5;
        transform: scaleY(1);
    }

    100% {
        opacity: 1;
        transform: scaleY(1.5);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

@keyframes drag-glow {
    0% {
        opacity: 0.1;
    }

    100% {
        opacity: 0.3;
    }
}
