﻿/* =========================================================
   VillaDenti
   Global Responsive System
   ========================================================= */


/* =========================================================
   1. GLOBAL SAFETY
   ========================================================= */

html {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}


/* =========================================================
   2. LONG TEXT SAFETY
   ========================================================= */

p,
span,
a,
.mud-typography {
    overflow-wrap: break-word;
}

pre,
code {
    max-width: 100%;
}


/* =========================================================
   3. TABLET
   ========================================================= */

@media (max-width: 960px) {

    .mud-main-content {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

        .mud-main-content > .mud-container {
            width: 100%;
            max-width: 100% !important;
            padding-left: 20px !important;
            padding-right: 20px !important;
        }

    .mud-paper {
        max-width: 100%;
    }

    .mud-table-container {
        max-width: 100%;
    }


    /* -------------------------
       Main Layout Header
       ------------------------- */

    .vd-top-actions {
        gap: 6px !important;
    }

    .vd-header-language-menu .mud-button-root,
    .vd-header-language-menu > button {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }


    /* -------------------------
       Setup Flow
       ------------------------- */

    .vd-setup-bottom {
        justify-content: center !important;
    }
}


/* =========================================================
   4. MOBILE
   ========================================================= */

@media (max-width: 600px) {

    html,
    body,
    #app {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }


    /* =====================================================
       MAIN CONTENT
       ===================================================== */

    .mud-main-content {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

        .mud-main-content > .mud-container {
            width: 100%;
            max-width: 100% !important;
            padding-top: 14px !important;
            padding-bottom: 14px !important;
            padding-left: max(14px, env(safe-area-inset-left)) !important;
            padding-right: max(14px, env(safe-area-inset-right)) !important;
        }


    /* =====================================================
       GENERIC MUD COMPONENT SAFETY
       ===================================================== */

    .mud-paper {
        max-width: 100%;
    }

    .mud-grid {
        max-width: 100%;
    }

    .mud-stack {
        max-width: 100%;
    }


    /* =====================================================
       TABLES
       ===================================================== */

    .mud-table-container {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }


    /* =====================================================
       DIALOGS
       ===================================================== */

    .mud-dialog {
        width: auto !important;
        max-width: calc(100vw - 24px) !important;
        margin-left: 12px !important;
        margin-right: 12px !important;
    }

    .mud-dialog-content {
        max-width: 100%;
        overflow-x: hidden;
    }


    /* =====================================================
       FORMS
       Prevent automatic iOS zoom
       ===================================================== */

    input,
    textarea,
    select {
        font-size: 16px;
    }

    .mud-input-root {
        max-width: 100%;
    }

    .mud-input-control {
        max-width: 100%;
    }


    /* =====================================================
       TOUCH
       ===================================================== */

    button,
    .mud-button-root,
    .mud-icon-button,
    a {
        touch-action: manipulation;
    }


    /* =====================================================
       APP BAR
       ===================================================== */

    .vd-appbar .mud-toolbar {
        min-height: 64px;
        padding-left: 8px !important;
        padding-right: 8px !important;
        gap: 4px;
    }

    .vd-appbar .mud-icon-button {
        flex-shrink: 0;
    }

    .vd-title-sub {
        display: none !important;
    }

    .vd-title-main {
        max-width: 120px !important;
        font-size: .92rem !important;
        line-height: 1.15 !important;
    }

    .vd-top-actions {
        gap: 4px !important;
        flex-shrink: 0;
    }


    /* =====================================================
   HEADER LANGUAGE
   Show current language on phone
   ===================================================== */

    .vd-header-language-menu {
        flex-shrink: 0;
    }

        .vd-header-language-menu .mud-button-root,
        .vd-header-language-menu > button {
            width: auto !important;
            min-width: auto !important;
            max-width: 110px !important;
            height: 40px !important;
            padding-left: 9px !important;
            padding-right: 10px !important;
            display: inline-flex !important;
            align-items: center !important;
            justify-content: center !important;
            overflow: hidden;
        }

        .vd-header-language-menu .mud-button-label {
            font-size: .78rem !important;
            gap: 5px !important;
            white-space: nowrap !important;
        }

        .vd-header-language-menu .mud-icon-root {
            font-size: 18px !important;
            margin-inline-end: 3px !important;
            flex-shrink: 0;
        }


    /* =====================================================
       THEME BUTTON
       ===================================================== */

    .vd-theme-toggle {
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
    }

    .vd-theme-toggle-text {
        display: none !important;
    }


    /* =====================================================
       USER AVATAR
       ===================================================== */

    .vd-avatar {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        margin-right: 0 !important;
        margin-inline-end: 0 !important;
        flex-shrink: 0;
    }


    /* =====================================================
       LOGOUT
       Keep functional but compact
       ===================================================== */

    .vd-logout-btn {
        min-width: auto !important;
        min-height: 38px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        font-size: .74rem !important;
        flex-shrink: 0;
    }


    /* =====================================================
       DRAWER
       ===================================================== */

    .vd-layout-shell {
        --mud-drawer-width-left: min(86vw, 300px);
        --mud-drawer-width-right: min(86vw, 300px);
    }

        .vd-drawer .mud-stack.pa-4 {
            padding: 14px !important;
        }

    .vd-brand-card {
        border-radius: 16px !important;
    }

    .vd-brand-logo {
        width: 46px !important;
        height: 46px !important;
        border-radius: 14px !important;
    }

    .vd-drawer .mud-nav-link {
        min-height: 46px !important;
        margin: 2px 0 !important;
        border-radius: 11px !important;
    }

    .vd-section-title {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }


    /* =====================================================
       LOGIN / REGISTER
       ===================================================== */

    .vd-login-page {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding-top: max(18px, env(safe-area-inset-top));
        padding-bottom: max(18px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }

    .vd-login-shell {
        width: 100%;
        max-width: 100%;
    }

    .vd-login-card {
        width: 100%;
        max-width: 100%;
        border-radius: 22px !important;
    }

    .vd-login-top {
        padding: 26px 18px 20px !important;
    }

    .vd-login-body {
        padding: 24px 18px 26px !important;
    }

    .vd-logo-sq {
        width: 76px !important;
        height: 76px !important;
        border-radius: 21px !important;
    }

    .vd-headings {
        margin-top: 24px;
    }

    .vd-title {
        font-size: 1.55rem !important;
    }

    .vd-brand {
        font-size: 1.2rem !important;
    }

    .vd-brand-sub,
    .vd-subtitle {
        letter-spacing: .16rem !important;
    }

    .vd-input .mud-input-root {
        min-height: 54px !important;
    }

    .vd-btn {
        min-height: 50px !important;
    }


    /* -------------------------
       Google / Apple
       ------------------------- */

    .vd-socials {
        width: 100% !important;
        max-width: 320px;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .vd-google-wrap {
        width: 100% !important;
        max-width: 100%;
        overflow: hidden;
    }

        .vd-google-wrap > div {
            width: 100% !important;
            max-width: 100% !important;
        }

    .vd-apple-btn-official {
        width: 100% !important;
        max-width: 100% !important;
    }


    /* =====================================================
       SETUP FLOW
       ===================================================== */

    .vd-setup-page {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
    }

    .vd-setup-shell {
        width: 100%;
        max-width: 100%;
    }

    .vd-setup-title {
        font-size: 2rem !important;
    }

    .vd-setup-subtitle {
        max-width: 100%;
    }

    .vd-setup-card {
        width: 100%;
        min-height: auto !important;
        border-radius: 20px !important;
    }

    .vd-setup-avatar {
        width: 52px !important;
        height: 52px !important;
    }

    .vd-setup-glow-1 {
        width: 260px !important;
        height: 260px !important;
    }

    .vd-setup-glow-2 {
        width: 300px !important;
        height: 300px !important;
    }

    .vd-setup-btn {
        width: 100%;
        min-height: 50px;
    }

    .vd-setup-page:has(.vd-step-avatar)
    .vd-input .mud-input-root {
        min-height: 60px !important;
    }

    .vd-setup-page:has(.vd-step-avatar)
    .vd-input input {
        font-size: 1rem !important;
        letter-spacing: .13em !important;
    }

    .vd-setup-bottom {
        justify-content: center !important;
    }

    .vd-setup-links {
        max-width: 100%;
        text-align: center;
    }


    /* =====================================================
       SUBSCRIPTION
       ===================================================== */

    .sub-page {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
    }

    .sub-container {
        width: 100%;
        max-width: 100%;
        padding-top: 38px !important;
        padding-bottom: 38px !important;
    }

    .sub-hero {
        width: 100%;
        max-width: 100%;
    }

    .sub-title {
        font-size: 2.15rem !important;
    }

    .sub-subtitle {
        max-width: 100%;
        font-size: 1rem !important;
    }

    .sub-plan-switch {
        width: 100%;
        max-width: 560px;
        margin-bottom: 26px;
        padding: 6px;
    }

    .sub-plan-switch-option {
        min-width: 0;
        min-height: 58px;
        padding: 8px 10px;
        flex-direction: column;
        gap: 1px;
    }

    .sub-plan-switch-name {
        font-size: .78rem;
    }

    .sub-plan-switch-option strong {
        font-size: .92rem;
    }

    .sub-single-plan {
        width: 100%;
    }

    .sub-plan-card-dynamic {
        width: 100%;
        min-height: 0;
    }

    .sub-plan-card {
        width: 100%;
        padding: 24px 20px;
        border-radius: 18px;
    }

    .sub-plan-header {
        gap: 14px;
    }

    .sub-plan-description {
        max-width: 100%;
    }

    .sub-price {
        font-size: 2.8rem;
    }

    .sub-feature {
        align-items: flex-start;
    }

    .sub-restore-card,
    .sub-trust-card,
    .sub-alert {
        width: 100%;
        max-width: 100%;
    }

    .sub-restore-content {
        flex-direction: column;
        align-items: stretch;
    }

    .sub-restore-info {
        align-items: flex-start;
    }

    .sub-restore-button {
        width: 100%;
    }

    .sub-footer {
        flex-direction: column;
        text-align: center;
    }

    .sub-footer-separator {
        display: none;
    }

    .sub-stripe-badge-image {
        width: 110px;
    }


    /* =====================================================
       STRIPE STATUS / SUCCESS
       ===================================================== */

    .stripe-status-wrap {
        width: 100%;
    }

    .stripe-status-card {
        width: 100%;
        padding: 30px 20px;
        border-radius: 18px !important;
    }

    .stripe-status-icon {
        width: 64px;
        height: 64px;
        border-radius: 18px;
    }

    .stripe-status-detail {
        width: 100%;
    }

    .stripe-success-actions {
        width: 100%;
        flex-direction: column;
    }

        .stripe-success-actions .mud-button-root {
            width: 100%;
        }


    /* =====================================================
       MANAGE SUBSCRIPTION
       ===================================================== */

    .manage-sub-container {
        width: 100% !important;
        max-width: 100% !important;
    }

    .manage-sub-toolbar {
        width: 100%;
        margin-top: 0;
    }

    .manage-sub-refresh {
        width: 100%;
    }

    .manage-sub-main-wrap {
        width: 100%;
    }

    .manage-sub-card {
        width: 100%;
        padding: 24px 20px;
    }

    .manage-sub-card-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .manage-sub-card-heading {
        flex: 1 1 150px;
    }

    .manage-sub-status {
        margin-inline-start: 72px;
    }

    .manage-sub-actions {
        width: 100%;
        flex-direction: column;
    }

    .manage-sub-primary-button,
    .manage-sub-secondary-button {
        width: 100%;
        flex: none;
    }

    .manage-sub-info-card,
    .manage-sub-trust {
        width: 100%;
        max-width: 100%;
    }

    .manage-sub-info-content {
        align-items: flex-start;
    }


    /* =====================================================
       MINIMAL LAYOUT FOOTER
       ===================================================== */

    .minimal-shell {
        min-height: 100vh;
        min-height: 100dvh;
    }

    .minimal-footer {
        min-height: 72px;
        padding-top: 10px;
        padding-bottom: 10px;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        font-size: 12px;
    }

    .minimal-footer-content {
        row-gap: 4px;
    }

    .minimal-footer-sep {
        margin-inline: 5px;
    }


    /* =====================================================
       STARTUP LOADER
       ===================================================== */

    .startup-loading-overlay {
        min-height: 100vh;
        min-height: 100dvh;
        padding-top: max(18px, env(safe-area-inset-top));
        padding-bottom: max(18px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }

    .startup-loading-card {
        width: min(100%, 360px);
        padding: 32px 24px;
        border-radius: 22px;
    }

    .startup-bar-wrap {
        width: min(180px, 70vw);
    }
}


/* =========================================================
   5. NARROW MOBILE
   430px and below
   ========================================================= */

@media (max-width: 430px) {

    /* Header becomes tighter */

    .vd-appbar .mud-toolbar {
        padding-left: 5px !important;
        padding-right: 5px !important;
        gap: 2px;
    }

    .vd-title-main {
        max-width: 90px !important;
        font-size: .86rem !important;
    }

    .vd-top-actions {
        gap: 2px !important;
    }

    .vd-theme-toggle {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
    }

    .vd-header-language-menu .mud-button-root,
    .vd-header-language-menu > button {
        width: auto !important;
        min-width: auto !important;
        max-width: 105px !important;
        height: 38px !important;
        padding-left: 7px !important;
        padding-right: 8px !important;
    }

    .vd-header-language-menu .mud-button-label {
        font-size: .72rem !important;
        gap: 4px !important;
    }

    .vd-avatar {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    .vd-logout-btn {
        min-height: 36px !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
        font-size: .70rem !important;
    }


    /* Subscription */

    .sub-title {
        font-size: 1.95rem !important;
    }

    .sub-plan-card {
        padding-left: 18px;
        padding-right: 18px;
    }

    .sub-price {
        font-size: 2.55rem;
    }

    .sub-plan-icon {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }


    /* Setup */

    .vd-setup-title {
        font-size: 1.8rem !important;
    }
}


/* =========================================================
   6. VERY SMALL MOBILE
   iPhone SE / narrow Android
   ========================================================= */

@media (max-width: 380px) {

    .mud-main-content > .mud-container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }


    /* =====================================================
       HEADER
       Remove title on extremely narrow screens.
       Navigation and account controls remain available.
       ===================================================== */

    .vd-title-main {
        display: none !important;
    }

    .vd-top-actions {
        gap: 2px !important;
    }


    /* =====================================================
       LOGIN / REGISTER
       ===================================================== */

    .vd-login-page {
        padding-left: 10px;
        padding-right: 10px;
    }

    .vd-login-top {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .vd-login-body {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .vd-login-card {
        border-radius: 20px !important;
    }

    .vd-logo-sq {
        width: 70px !important;
        height: 70px !important;
        border-radius: 19px !important;
    }

    .vd-title {
        font-size: 1.42rem !important;
    }


    /* =====================================================
       SUBSCRIPTION
       ===================================================== */

    .sub-container {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
    }

    .sub-title {
        font-size: 1.8rem !important;
    }

    .sub-plan-switch-option {
        padding-left: 6px;
        padding-right: 6px;
    }

    .sub-plan-card {
        padding: 22px 16px;
    }

    .sub-price {
        font-size: 2.35rem;
    }

    .sub-currency {
        font-size: 1.05rem;
    }

    .sub-price-period {
        margin-left: 5px;
        font-size: .85rem;
    }

    .sub-restore-card,
    .sub-trust-card {
        padding-left: 16px;
        padding-right: 16px;
    }


    /* =====================================================
       MANAGE SUBSCRIPTION
       ===================================================== */

    .manage-sub-card {
        padding-left: 16px;
        padding-right: 16px;
    }

    .manage-sub-status {
        margin-inline-start: 0;
    }


    /* =====================================================
       STARTUP
       ===================================================== */

    .startup-loading-card {
        padding-left: 20px;
        padding-right: 20px;
    }
}


/* =========================================================
   7. LANDSCAPE PHONE
   ========================================================= */

@media (max-height: 500px) and (orientation: landscape) {

    .vd-login-page {
        align-items: flex-start;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .vd-login-card {
        max-width: 560px;
    }

    .startup-loading-overlay {
        position: fixed;
        overflow-y: auto;
        align-items: flex-start;
        padding-top: 20px;
        padding-bottom: 20px;
    }
}


/* =========================================================
   8. REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    .vd-login-card,
    .vd-logo-sq,
    .vd-input .mud-input-root,
    .vd-btn,
    .vd-setup-card,
    .vd-setup-btn,
    .sub-plan-card,
    .sub-plan-switch-option,
    .vd-theme-toggle,
    .vd-avatar,
    .mud-nav-link {
        transition: none !important;
    }
}
