/* ===================================================================
   Native <dialog> Component
   Uses @starting-style for entry animations and bottom-sheet on mobile
   =================================================================== */

@layer components {
    .dashboard-dialog {
        border: none;
        border-radius: 16px;
        padding: 0;
        max-width: min(560px, 90vw);
        width: 100%;
        background: var(--card-bg, white);
        color: var(--text-primary, #111827);
        box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
        opacity: 0;
        translate: 0 20px;
        transition:
            opacity 0.3s ease,
            translate 0.3s ease,
            display 0.3s allow-discrete,
            overlay 0.3s allow-discrete;

        &[open] {
            opacity: 1;
            translate: 0 0;
        }

        @starting-style {
            &[open] {
                opacity: 0;
                translate: 0 20px;
            }
        }

        &::backdrop {
            background: rgba(0, 0, 0, 0);
            transition: background 0.3s ease, display 0.3s allow-discrete, overlay 0.3s allow-discrete;
        }

        &[open]::backdrop {
            background: rgba(0, 0, 0, 0.4);
        }

        @starting-style {
            &[open]::backdrop {
                background: rgba(0, 0, 0, 0);
            }
        }
    }

    .dialog-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1.25rem 1.5rem;
        border-bottom: 1px solid var(--border-color, #ddd);

        & h2 {
            margin: 0;
            font-size: var(--text-lg, 1.2rem);
            font-weight: 600;
            color: var(--text-primary, #111827);
        }
    }

    .dialog-close-btn {
        appearance: none;
        border: none;
        background: var(--gray-100, #F3F4F6);
        border-radius: 8px;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 18px;
        color: var(--text-secondary, #374151);
        transition: background 0.15s ease;

        &:hover {
            background: var(--gray-200, #E5E7EB);
        }

        &:focus-visible {
            outline: 2px solid var(--accent-color, #C62828);
            outline-offset: 2px;
        }
    }

    .dialog-body {
        padding: 1.5rem;
        overflow-y: auto;
        max-height: 60vh;
    }

    /* Mobile: render as bottom sheet */
    @media (max-width: 768px) {
        .dashboard-dialog {
            max-width: 100%;
            width: 100%;
            margin: 0;
            border-radius: 16px 16px 0 0;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            translate: 0 100%;

            &[open] {
                translate: 0 0;
            }

            @starting-style {
                &[open] {
                    translate: 0 100%;
                }
            }
        }

        .dialog-header {
            padding: 1rem 1.25rem;

            /* Drag indicator bar */
            &::before {
                content: '';
                position: absolute;
                top: 8px;
                left: 50%;
                translate: -50% 0;
                width: 36px;
                height: 4px;
                border-radius: 2px;
                background: var(--gray-300, #D1D5DB);
            }
        }

        .dialog-body {
            max-height: 70vh;
            padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
        }
    }

    /* Respect reduced motion */
    @media (prefers-reduced-motion: reduce) {
        .dashboard-dialog {
            transition: none;

            &::backdrop {
                transition: none;
            }
        }
    }
}
