@import '../../utils/shared-styles.scss';

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== BACKDROP ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;

    // Wichtig: Verhindert dass Backdrop selbst scrollt
    overflow: hidden;
}

/* ===== CONTAINER ===== */
.modal-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 2rem;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

    // Wichtig: Modal bleibt immer in der Mitte
    margin: auto;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;

    @media (max-width: 480px) {
        padding: 1.5rem;
        gap: 1.25rem;
        border-radius: 20px;
    }
}

/* ===== ICON ===== */
.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    position: relative;
    transition: transform 0.3s ease;
    flex-shrink: 0;

    @media (max-width: 480px) {
        width: 56px;
        height: 56px;
        border-radius: 16px;
    }

    &::after {
        content: '';
        position: absolute;
        inset: -6px;
        border-radius: 24px;
        opacity: 0.3;
        animation: pulse 2s ease-in-out infinite;
    }

    .material-symbols-outlined {
        font-size: 36px;
        position: relative;
        z-index: 1;
        filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));

        @media (max-width: 480px) {
            font-size: 32px;
        }
    }

    /* Type Variants */
    &--warning {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(251, 191, 36, 0.15));
        border: 2px solid rgba(245, 158, 11, 0.3);

        &::after {
            border: 2px solid rgba(245, 158, 11, 0.4);
        }

        .material-symbols-outlined {
            color: #f59e0b;
        }
    }

    &--danger {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(248, 113, 113, 0.15));
        border: 2px solid rgba(239, 68, 68, 0.3);

        &::after {
            border: 2px solid rgba(239, 68, 68, 0.4);
        }

        .material-symbols-outlined {
            color: #ef4444;
        }
    }

    &--info {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(59, 130, 246, 0.15));
        border: 2px solid rgba(37, 99, 235, 0.3);

        &::after {
            border: 2px solid rgba(37, 99, 235, 0.4);
        }

        .material-symbols-outlined {
            color: #2563eb;
        }
    }

    &--success {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(52, 211, 153, 0.15));
        border: 2px solid rgba(16, 185, 129, 0.3);

        &::after {
            border: 2px solid rgba(16, 185, 129, 0.4);
        }

        .material-symbols-outlined {
            color: #10b981;
        }
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.15;
    }
}

/* ===== CONTENT ===== */
.modal-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: $color-text-primary;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;

    @media (max-width: 480px) {
        font-size: 1.35rem;
    }
}

.modal-message {
    font-size: 1rem;
    color: $color-text-secondary;
    margin: 0;
    line-height: 1.6;

    @media (max-width: 480px) {
        font-size: 0.9375rem;
    }
}

/* ===== ACTIONS ===== */
.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;

    @media (max-width: 480px) {
        flex-direction: column-reverse;
        gap: 0.625rem;
    }

    .btn {
        flex: 1;
        justify-content: center;
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
        font-weight: 700;
        border-radius: 12px;
        transition: all 0.2s ease;
        position: relative;
        overflow: hidden;

        @media (max-width: 480px) {
            padding: 0.875rem 1.25rem;
            font-size: 0.9rem;
        }

        &:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .spinner {
            width: 18px;
            height: 18px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-top-color: white;
            border-radius: 50%;
            animation: spin 0.6s linear infinite;
            display: inline-block;
        }
    }

    .btn--ghost {
        background: rgba(0, 0, 0, 0.04);
        color: $color-text-secondary;
        border: 2px solid rgba(0, 0, 0, 0.08);

        &:hover:not(:disabled) {
            background: rgba(0, 0, 0, 0.08);
            color: $color-text-primary;
            border-color: rgba(0, 0, 0, 0.12);
        }

        &:active:not(:disabled) {
            transform: scale(0.98);
        }
    }

    .btn--warning {
        background: linear-gradient(135deg, #f59e0b, #fbbf24);
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);

        &:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
        }

        &:active:not(:disabled) {
            transform: translateY(0);
        }
    }

    .btn--danger {
        background: linear-gradient(135deg, #ef4444, #f87171);
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);

        &:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
        }

        &:active:not(:disabled) {
            transform: translateY(0);
        }
    }

    .btn--info {
        background: linear-gradient(135deg, #2563eb, #3b82f6);
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);

        &:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
        }

        &:active:not(:disabled) {
            transform: translateY(0);
        }
    }

    .btn--success {
        background: linear-gradient(135deg, #10b981, #34d399);
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);

        &:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
        }

        &:active:not(:disabled) {
            transform: translateY(0);
        }
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {

    .modal-backdrop,
    .modal-container,
    .modal-icon::after {
        animation: none !important;
    }

    .btn {
        transition: none !important;
    }
}