/*
|--------------------------------------------------------------------------
| Dental App PWA - CSS limpio y escalable
|--------------------------------------------------------------------------
| - Header compatible con notch de iPhone mediante safe-area.
| - Footer fijo compatible con iOS / Android.
| - Inicio minimalista: bienvenida + módulos grandes.
| - Se conservan componentes reutilizables para las demás vistas.
*/

:root {
    --primary: #0ea5b7;
    --primary-600: #078ca0;
    --primary-700: #057284;
    --primary-soft: #e7fbfd;
    --aqua: #37d5e5;
    --mint: #6ee7b7;
    --ink: #0f172a;
    --text: #243044;
    --muted: #64748b;
    --line: #dbe7ef;
    --bg: #f6fafc;
    --surface: rgba(255, 255, 255, .88);
    --surface-solid: #ffffff;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --shadow-xs: 0 4px 12px rgba(15, 23, 42, .06);
    --shadow-sm: 0 10px 24px rgba(15, 23, 42, .08);
    --shadow-md: 0 18px 42px rgba(15, 23, 42, .12);
    --shadow-lg: 0 28px 65px rgba(15, 23, 42, .16);
    --radius-sm: 14px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-xl: 34px;
    --header-height: 74px;
    --footer-height: 84px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --max-app-width: 760px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 0% 0%, rgba(14, 165, 183, .10), transparent 34%),
        radial-gradient(circle at 100% 0%, rgba(110, 231, 183, .10), transparent 28%),
        linear-gradient(180deg, #fbfdff 0%, #f6fafc 46%, #f2f7fa 100%);
    overflow-x: hidden;
}

body.is-loading {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    width: 100%;
    min-height: 100vh;
}

/* HEADER */
.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    width: 100%;
    padding-top: var(--safe-top);
    color: var(--ink);
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid rgba(219, 231, 239, .78);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.app-header__inner {
    width: min(100%, var(--max-app-width));
    min-height: var(--header-height);
    margin: 0 auto;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 46px 1fr 46px;
    align-items: center;
    gap: 10px;
}

.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.brand__mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-700), var(--primary));
    border-radius: 16px;
    box-shadow: 0 12px 24px rgba(14, 165, 183, .22);
}

.brand__mark svg {
    width: 24px;
    height: 24px;
}

.brand__text {
    min-width: 0;
    display: grid;
    line-height: 1.05;
}

.brand__text strong {
    font-size: 1.05rem;
    letter-spacing: -.025em;
    white-space: nowrap;
}

.brand__text small {
    margin-top: 4px;
    font-size: .73rem;
    font-weight: 800;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-button {
    position: relative;
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 16px;
    color: var(--primary-700);
    background: rgba(231, 251, 253, .88);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 183, .10);
    cursor: pointer;
    transition: transform .18s ease, background .18s ease;
}

.icon-button:active {
    transform: scale(.96);
}

.icon-button:hover {
    background: #dff8fb;
}

.notify-dot {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #f97316;
    box-shadow: 0 0 0 3px #fff;
}

/* LAYOUT */
.app-main {
    width: min(100%, var(--max-app-width));
    margin: 0 auto;
    padding: 18px 16px calc(var(--footer-height) + var(--safe-bottom) + 28px);
}

/* FOOTER */
.app-footer {
    position: fixed;
    inset: auto 0 0;
    z-index: 28;
    width: 100%;
    padding: 8px 14px calc(8px + var(--safe-bottom));
    background: rgba(255, 255, 255, .88);
    border-top: 1px solid rgba(219, 231, 239, .86);
    box-shadow: 0 -15px 38px rgba(15, 23, 42, .08);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.bottom-nav {
    width: min(100%, 640px);
    min-height: 64px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    align-items: center;
}

.bottom-nav__item {
    min-width: 0;
    height: 58px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 850;
    letter-spacing: -.01em;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.bottom-nav__item:active {
    transform: scale(.96);
}

.bottom-nav__icon {
    display: inline-grid;
    place-items: center;
}

.bottom-nav__icon svg {
    width: 23px;
    height: 23px;
}

.bottom-nav__item.is-active {
    color: var(--primary-700);
    background: linear-gradient(180deg, #e8fbff, #f8ffff);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 183, .13), var(--shadow-xs);
}

/* PRELOADER */
.app-preloader {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 35%, rgba(55, 213, 229, .22), transparent 28%),
        linear-gradient(160deg, #e6fbff, #ffffff 54%, #effaf6);
    transition: opacity .35s ease, visibility .35s ease;
}

.app-preloader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-card {
    width: min(100%, 300px);
    padding: 26px;
    border-radius: 32px;
    text-align: center;
    background: rgba(255, 255, 255, .84);
    border: 1px solid rgba(255, 255, 255, .78);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.preloader-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-700), var(--primary), var(--aqua));
    box-shadow: 0 20px 38px rgba(14, 165, 183, .28);
    animation: preloadPulse 1.2s ease-in-out infinite;
}

.preloader-title {
    font-weight: 900;
    color: var(--ink);
    letter-spacing: -.02em;
}

.preloader-bar {
    height: 8px;
    margin-top: 18px;
    border-radius: 99px;
    background: #d9eef3;
    overflow: hidden;
}

.preloader-bar span {
    display: block;
    width: 45%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary-700), var(--aqua));
    animation: preloadBar 1.1s ease-in-out infinite;
}

@keyframes preloadPulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.04); }
}

@keyframes preloadBar {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(240%); }
}

/* HOME MINIMALISTA */
.home-page .app-main {
    padding-top: 20px;
}

.home-welcome {
    margin: 2px 0 18px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 28px;
    background: rgba(255, 255, 255, .84);
    border: 1px solid rgba(219, 231, 239, .82);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.home-welcome__logo {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-700), var(--primary));
    box-shadow: 0 14px 28px rgba(14, 165, 183, .24);
}

.home-welcome__logo svg {
    width: 29px;
    height: 29px;
}

.home-welcome__copy {
    min-width: 0;
}

.home-welcome__eyebrow {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 850;
}

.home-welcome h1 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(1.3rem, 6vw, 1.85rem);
    line-height: 1;
    letter-spacing: -.05em;
}

.home-welcome p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.35;
}

.home-app-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.home-module {
    min-height: 126px;
    padding: 17px 12px 15px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    text-align: center;
    border-radius: 27px;
    color: var(--ink);
    background: #fff;
    border: 1px solid rgba(219, 231, 239, .9);
    box-shadow: var(--shadow-xs);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.home-module:hover {
    transform: translateY(-2px);
    border-color: rgba(14, 165, 183, .28);
    box-shadow: var(--shadow-sm);
}

.home-module:active {
    transform: scale(.97);
}

.home-module__icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    color: var(--primary-700);
    background: linear-gradient(180deg, #e9fbff, #f8ffff);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 183, .12), 0 12px 22px rgba(14, 165, 183, .10);
}

.home-module__icon svg {
    width: 29px;
    height: 29px;
}

.home-module__label {
    display: block;
    font-size: .9rem;
    font-weight: 900;
    letter-spacing: -.025em;
}

/* BOTONES Y ENCABEZADOS INTERNOS */
.btn {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 16px;
    border-radius: 17px;
    font-weight: 900;
    letter-spacing: -.02em;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-700), var(--primary));
    box-shadow: 0 14px 30px rgba(14, 165, 183, .22);
}

.btn-secondary {
    color: var(--primary-700);
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(14, 165, 183, .14), var(--shadow-xs);
}

.btn-soft {
    color: var(--primary-700);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 183, .12);
}

.section-head {
    margin: 24px 2px 14px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.section-head h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.18rem;
    line-height: 1;
    letter-spacing: -.04em;
}

.section-head p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.35;
}

.section-link {
    flex: 0 0 auto;
    color: var(--primary-700);
    font-size: .82rem;
    font-weight: 900;
}

/* TARJETAS DE MÓDULOS PARA VISTAS INTERNAS */
.module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.module-card {
    position: relative;
    min-height: 148px;
    padding: 18px;
    overflow: hidden;
    border-radius: 28px;
    background: var(--surface-solid);
    border: 1px solid rgba(219, 231, 239, .82);
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.module-card:hover {
    transform: translateY(-2px);
    border-color: rgba(14, 165, 183, .25);
    box-shadow: var(--shadow-md);
}

.module-card:active {
    transform: scale(.98);
}

.module-icon {
    position: relative;
    z-index: 1;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 21px;
    color: var(--primary-700);
    background: linear-gradient(180deg, #e8fbff, #f7ffff);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 183, .12), 0 13px 24px rgba(14, 165, 183, .12);
}

.module-card h3 {
    position: relative;
    z-index: 1;
    margin: 15px 0 6px;
    color: var(--ink);
    font-size: 1.02rem;
    letter-spacing: -.035em;
}

.module-card p {
    position: relative;
    z-index: 1;
    margin: 0;
    max-width: 210px;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.34;
}

/* COMPONENTES REUTILIZABLES PARA PÁGINAS */
.page-title-card {
    padding: 20px;
    border-radius: var(--radius-lg);
    color: #fff;
    background:
        radial-gradient(circle at 90% 20%, rgba(255, 255, 255, .28), transparent 24%),
        linear-gradient(135deg, var(--primary-700), var(--primary));
    box-shadow: var(--shadow-md);
}

.page-title-card h1 {
    margin: 0;
    font-size: clamp(1.65rem, 6vw, 2.4rem);
    line-height: 1;
    letter-spacing: -.06em;
}

.page-title-card p {
    margin: 9px 0 0;
    max-width: 620px;
    color: rgba(255, 255, 255, .78);
    line-height: 1.45;
}

.toolbar {
    margin: 16px 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(219, 231, 239, .9);
    box-shadow: var(--shadow-xs);
}

.search-box svg {
    width: 21px;
    height: 21px;
    color: var(--primary-700);
}

.search-box input {
    width: 100%;
    min-height: 34px;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-weight: 750;
}

.search-box input::placeholder {
    color: #9aa9ba;
}

.panel {
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid rgba(219, 231, 239, .84);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.panel-padding {
    padding: 18px;
}

.list-stack,
.timeline-day {
    display: grid;
    gap: 12px;
}

.patient-card,
.appointment-card,
.simple-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 24px;
    background: #fff;
    border: 1px solid rgba(219, 231, 239, .86);
    box-shadow: var(--shadow-xs);
}

.avatar {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 19px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-700), var(--primary));
    font-weight: 950;
    letter-spacing: -.02em;
}

.avatar.is-soft {
    color: var(--primary-700);
    background: var(--primary-soft);
}

.card-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.card-copy h3,
.card-copy h4 {
    margin: 0;
    color: var(--ink);
    font-size: .98rem;
    letter-spacing: -.025em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-copy p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: .81rem;
    line-height: 1.35;
}

.card-meta {
    flex: 0 0 auto;
    display: grid;
    gap: 6px;
    justify-items: end;
}

.status-pill {
    min-height: 28px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: var(--primary-700);
    background: var(--primary-soft);
    font-size: .72rem;
    font-weight: 900;
    white-space: nowrap;
}

.status-pill.is-warning {
    color: #92400e;
    background: #fffbeb;
}

.status-pill.is-success {
    color: #047857;
    background: #ecfdf5;
}

.status-pill.is-danger {
    color: #b91c1c;
    background: #fef2f2;
}

.time-chip {
    min-width: 62px;
    padding: 9px 10px;
    border-radius: 17px;
    text-align: center;
    color: var(--primary-700);
    background: var(--primary-soft);
    font-weight: 950;
    line-height: 1;
}

.time-chip small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .65rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat-card {
    min-height: 104px;
    padding: 16px;
    border-radius: 24px;
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(219, 231, 239, .82);
    box-shadow: var(--shadow-xs);
}

.stat-card strong {
    display: block;
    color: var(--ink);
    font-size: 1.55rem;
    line-height: 1;
    letter-spacing: -.06em;
}

.stat-card span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.25;
}

.notice-card {
    padding: 16px;
    border-radius: 24px;
    color: #0f5132;
    background: linear-gradient(135deg, #ecfdf5, #f7fffb);
    border: 1px solid rgba(16, 185, 129, .18);
    box-shadow: var(--shadow-xs);
}

.notice-card strong {
    display: block;
    margin-bottom: 5px;
    color: #047857;
}

.notice-card p {
    margin: 0;
    color: #286451;
    font-size: .86rem;
    line-height: 1.45;
}

.feature-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.feature-box {
    padding: 16px;
    border-radius: 24px;
    background: #fff;
    border: 1px solid rgba(219, 231, 239, .84);
    box-shadow: var(--shadow-xs);
}

.feature-box h3 {
    margin: 0 0 7px;
    color: var(--ink);
    font-size: .98rem;
    letter-spacing: -.02em;
}

.feature-box p {
    margin: 0;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.4;
}

@media (min-width: 760px) {
    .app-main {
        padding-top: 24px;
    }

    .home-app-grid,
    .module-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .home-module {
        min-height: 138px;
    }
}

@media (max-width: 640px) {
    :root {
        --header-height: 72px;
        --footer-height: 86px;
    }

    .brand__text small {
        max-width: 170px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar {
        grid-template-columns: 1fr;
    }

    .toolbar .btn {
        width: 100%;
    }

    .feature-row {
        grid-template-columns: 1fr;
    }

    .card-meta {
        display: none;
    }
}

@media (max-width: 380px) {
    .app-header__inner {
        grid-template-columns: 42px 1fr 42px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .icon-button {
        width: 42px;
        height: 42px;
        border-radius: 15px;
    }

    .brand__mark {
        width: 39px;
        height: 39px;
        border-radius: 14px;
    }

    .brand__text strong {
        font-size: .98rem;
    }

    .brand__text small {
        max-width: 122px;
    }

    .app-main {
        padding-left: 12px;
        padding-right: 12px;
    }

    .home-welcome {
        padding: 15px;
        border-radius: 24px;
    }

    .home-welcome__logo {
        width: 52px;
        height: 52px;
        border-radius: 19px;
    }

    .home-app-grid,
    .module-grid {
        gap: 10px;
    }

    .home-module {
        min-height: 116px;
        border-radius: 24px;
    }

    .home-module__icon,
    .module-icon {
        width: 52px;
        height: 52px;
        border-radius: 19px;
    }

    .bottom-nav__item {
        font-size: .62rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
    }
}
