:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --shell-sidebar-width: 16rem;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 6rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

a,
button,
input,
select,
textarea {
    touch-action: manipulation;
}

body.app-area-public,
body.app-area-auth,
body.app-area-checkout,
body.app-area-admin,
body.app-area-client {
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.responsive-shell-toggle,
.responsive-public-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.responsive-shell-toggle .material-symbols-outlined,
.responsive-public-toggle .material-symbols-outlined {
    font-size: 1.35rem;
}

.responsive-shell-overlay {
    display: none;
}

.responsive-public-panel[hidden] {
    display: none !important;
}

.responsive-public-panel {
    display: none;
}

.responsive-public-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
}

.responsive-public-link,
.responsive-public-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.8rem 1rem;
    border-radius: 0.95rem;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
}

.responsive-public-link {
    color: #334155;
    background: #f8fafc;
}

.responsive-public-link.current {
    color: #1d4ed8;
    background: #eff6ff;
}

.responsive-public-action.secondary {
    color: #0f172a;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.responsive-public-action.primary {
    color: #ffffff;
    background: linear-gradient(135deg, #004ac6 0%, #2563eb 100%);
}

.responsive-public-actions {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

@media (max-width: 1023px) {
    .responsive-shell-toggle,
    .responsive-public-toggle {
        display: inline-flex;
        flex-shrink: 0;
    }

    body.responsive-shell-page {
        position: relative;
    }

    body.responsive-shell-page .responsive-shell-sidebar {
        display: flex !important;
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        width: min(19rem, 86vw) !important;
        max-width: 86vw;
        min-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-110%) !important;
        transition: transform 0.25s ease, box-shadow 0.25s ease;
        box-shadow: none;
        z-index: 70 !important;
    }

    body.responsive-shell-page.is-shell-open .responsive-shell-sidebar {
        transform: translateX(0) !important;
        box-shadow: 0 28px 80px rgba(15, 23, 42, 0.26);
    }

    body.responsive-shell-page .responsive-shell-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.48);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
        z-index: 60;
    }

    body.responsive-shell-page.is-shell-open .responsive-shell-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    body.responsive-shell-page .responsive-shell-main {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0;
    }

    body.responsive-shell-page .responsive-shell-header {
        width: 100% !important;
        right: 0 !important;
        left: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    body.responsive-shell-page .responsive-shell-header > * {
        min-width: 0;
    }

    body.responsive-client-page .responsive-shell-main {
        padding-bottom: calc(5.25rem + var(--safe-bottom));
    }

    body.app-area-client nav.fixed.bottom-0,
    body.app-area-client nav[aria-label="Navegación móvil"] {
        height: calc(4rem + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
    }

    body.app-area-checkout main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    body.app-area-checkout main nav,
    body.app-area-checkout [aria-label="Progreso del checkout"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    body.app-area-checkout main nav::-webkit-scrollbar,
    body.app-area-checkout [aria-label="Progreso del checkout"]::-webkit-scrollbar {
        display: none;
    }

    body.app-area-checkout aside.sticky,
    body.app-area-checkout [class*="sticky top-"] {
        position: static !important;
        top: auto !important;
    }

    body.app-area-checkout footer {
        padding-bottom: max(1rem, var(--safe-bottom));
    }

    body.app-area-public nav.fixed > div,
    body.app-area-public header.fixed > div,
    body.app-area-checkout nav.fixed > div,
    body.app-area-checkout header.fixed > div,
    body.app-area-auth header.fixed > div {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    body.app-area-public .responsive-public-panel {
        display: block;
        padding: 0 1rem 1rem;
    }
}

@media (max-width: 767px) {
    body.app-area-public main,
    body.app-area-checkout main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    body.app-area-client #dashboard-content > header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    body.app-area-client #dashboard-content > header .flex.items-center.gap-6 {
        width: 100%;
        justify-content: space-between;
        margin-left: 0 !important;
        gap: 1rem;
        border-left: 0;
        padding-left: 0;
    }

    body.app-area-client #dashboard-content #dashboard-search {
        width: 100%;
    }

    body.app-area-client #dashboard-data > div:first-child {
        flex-direction: column;
    }

    body.app-area-client #dashboard-data > div:first-child > div {
        width: 100% !important;
    }

    body.app-area-client #dashboard-data > div:first-child > div:first-child {
        min-height: 16rem;
    }

    body.app-area-client #dashboard-data > div:first-child > div:last-child,
    body.app-area-client #dashboard-data > div:last-child {
        padding: 1.5rem !important;
    }

    body.app-area-public table,
    body.app-area-admin table,
    body.app-area-client table {
        min-width: 40rem;
    }
}

@media (min-width: 1024px) {
    .responsive-shell-overlay,
    .responsive-shell-toggle,
    .responsive-public-toggle,
    .responsive-public-panel {
        display: none !important;
    }
}
