/* Shell del panel doctor — sidebar Tabler (ver docs/design/handoff/app.html líneas ~150-178) */

[data-shell] {
    display: flex;
    min-height: 100vh;
}

[data-side] {
    width: 248px;
    flex: 0 0 auto;
    background: #10243E;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
}

[data-side] [data-brand] {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    line-height: 1;
    padding: 0 8px 24px;
}

[data-side] [data-search] {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, .08);
    border-radius: 9px;
    padding: 9px 12px;
    margin-bottom: 14px;
    color: #7E90A4;
}

[data-side] [data-search]:focus-within {
    background: rgba(255, 255, 255, .14);
    color: #B7C4D4;
}

[data-side] [data-search] input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
}

[data-side] [data-search] input::placeholder {
    color: #7E90A4;
}

[data-side] .pm-btn-nueva-carta {
    display: flex;
    align-items: center;
    gap: 9px;
    justify-content: center;
    background: #0BA47E;
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 18px;
    text-decoration: none;
}

[data-side] .pm-btn-nueva-carta:hover {
    opacity: .92;
}

[data-side] nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

[data-side] [data-navitem] {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 9px;
    cursor: pointer;
    color: #B7C4D4;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

[data-side] [data-navitem]:hover {
    background: rgba(255, 255, 255, .06);
}

[data-side] [data-navitem].activo {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

[data-side] [data-navitem] .pm-badge-amber {
    margin-left: auto;
    background: #F5B133;
    color: #3A2A05;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}

[data-side] [data-sidefoot] {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding-top: 14px;
}

[data-side] [data-sidefoot] .pm-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    /* The initials are text, so this carries the 4.5:1 bar: white on the display
       green #0BA47E was 3.17:1. The text-safe green is 5.17:1. */
    background: #087C60;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex: 0 0 auto;
}

[data-side] [data-sidefoot] .pm-sidefoot-nombre {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-side] [data-sidefoot] .pm-sidefoot-especialidad {
    color: #7E90A4;
    font-size: 12px;
}

[data-side] [data-sidefoot] .pm-logout {
    display: block;
    color: #7E90A4;
    font-size: 13px;
    padding: 8px;
    cursor: pointer;
    text-decoration: none;
}

[data-side] [data-sidefoot] .pm-logout:hover {
    color: #fff;
}

[data-main] {
    flex: 1;
    min-width: 0;
    background: #EDF1F6;
    padding: 28px 32px;
}

/* Mobile top bar + off-canvas drawer machinery (hidden on desktop). */
.pm-nav-toggle { display: none; }
.pm-mobilebar { display: none; }
.pm-nav-overlay { display: none; }

@media (max-width: 880px) {
    [data-shell] {
        flex-direction: column;
    }

    /* Sticky top bar: hamburger + brand (Tabler-style). */
    .pm-mobilebar {
        display: flex;
        align-items: center;
        gap: 12px;
        background: #10243E;
        padding: 10px 14px;
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .pm-hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 9px;
        color: #fff;
        cursor: pointer;
        flex: 0 0 auto;
    }

    .pm-hamburger:hover {
        background: rgba(255, 255, 255, .08);
    }

    .pm-mobilebar-brand {
        display: flex;
        align-items: flex-end;
    }

    /* Sidebar becomes an off-canvas drawer, keeping its full vertical menu
       (brand, search, nav with labels, footer with logout). */
    [data-side] {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 268px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 60;
        overflow-y: auto;
    }

    /* Dimmed backdrop behind the open drawer. */
    .pm-nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(6, 17, 33, .45);
        z-index: 55;
        display: none;
    }

    /* The hamburger toggles this checkbox; :checked slides the drawer in. */
    .pm-nav-toggle:checked ~ [data-shell] [data-side] {
        transform: translateX(0);
    }

    .pm-nav-toggle:checked ~ .pm-nav-overlay {
        display: block;
    }

    [data-main] {
        padding: 16px 14px;
    }
}

/* Drag-and-drop file upload (dropzone_controller.js). Reusable on any form
   that needs a file input — see nueva_carta.html.twig and bloqueados.html.twig. */
.pm-dropzone {
    position: relative;
    border: 2px dashed #C7D3E0;
    border-radius: 14px;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    color: #5D6A7A;
    background: #F7F9FB;
    transition: border-color .15s ease, background-color .15s ease;
}

.pm-dropzone:hover {
    border-color: #0BA47E;
}

.pm-dropzone.is-dragover {
    border-color: #0BA47E;
    background: #E7F6F0;
}

.pm-dropzone__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pm-dropzone__icon {
    font-size: 26px;
    margin-bottom: 8px;
}

.pm-dropzone__hint {
    font-size: 14px;
    font-weight: 500;
}

.pm-dropzone__filename {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #0A7E5E;
    word-break: break-all;
}

.pm-dropzone__filename:empty {
    display: none;
}

/* Mobile-first capture path (see dropzone_controller.js #camera and
   carta_upload_form.html.twig). The canonical carta arrives as a phone photo
   taken between cases, so on a phone the camera gets its own button and the hint
   stops telling a touch device to drag. Desktop keeps drag-and-drop and never
   sees the camera button, where `capture` is ignored anyway. */
.pm-hint--touch {
    display: none;
}

.pm-camera-btn {
    display: none;
    width: 100%;
    margin-top: 10px;
    padding: 14px 18px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    color: #087C60;
    border: 1.5px solid #087C60;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    /* Comfortably past the 44px touch-target minimum — the audience skews older
       and is often one-handed on a phone between cases. */
    min-height: 52px;
}

.pm-camera-btn:active {
    background: #E7F6F0;
}

@media (max-width: 640px) {
    .pm-hint--pointer {
        display: none;
    }

    .pm-hint--touch {
        display: inline;
    }

    .pm-camera-btn {
        display: flex;
    }
}

/* Progress indicator for slow native submits (see submit_progress_controller.js) —
   the "Leer carta" upload waits on the AI reading the PDF. */
.pm-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    border: 2px solid #C7D3E0;
    border-top-color: #0BA47E;
    border-radius: 50%;
    animation: pm-spin .7s linear infinite;
}

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

/* The spinner is a liveness signal for a slow upload, not decoration, so reduced
   motion slows it rather than stopping it. The drawer and dropzone below are
   decoration and are cut outright. */
@media (prefers-reduced-motion: reduce) {
    .pm-spinner {
        animation-duration: 2.4s;
    }

    /* The off-canvas drawer still opens and closes — only the slide is dropped,
       so it appears in place. */
    [data-side] {
        transition: none;
    }

    .pm-dropzone {
        transition: none;
    }
}

/* Panel CONTENT responsiveness — list tables, KPI/stat grids and two-column
   detail splits inside [data-main] use inline grid-template-columns that
   don't reflow on their own. Override them here (the shell/sidebar rules
   above already handle ≤880px; this block targets phones specifically). */
@media (max-width: 640px) {
    /* List tables: hide the header row, stack each row's cells into a card. */
    [data-list-head] {
        display: none !important;
    }

    [data-list-row] {
        grid-template-columns: 1fr !important;
        gap: 4px !important;
        row-gap: 4px !important;
        align-items: start !important;
    }

    /* KPI/stat grids: 2-up on phones. */
    [data-kpis],
    [data-grid4] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Two-column detail splits (and the doctor dashboard's detail grid):
       single column. */
    [data-split],
    [data-detailgrid] {
        grid-template-columns: 1fr !important;
    }

    /* Never let the page scroll sideways. */
    [data-main] {
        overflow-x: hidden;
    }
}

/* ---------- Facturación (página propia del doctor) ----------
   The doctor's invoicing setup: a readiness ledger, the series/folio form, and a
   collapsed CSD uploader. Raw file inputs are styled here (::file-selector-button
   can't live inline) so the .cer/.key controls stop looking like broken defaults. */
.pm-fact { background: #fff; border: 1px solid #E6EDF3; border-radius: 16px; padding: 28px; margin-bottom: 24px; }
.pm-fact__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.pm-fact__title { font-family: var(--pm-font-title); font-weight: 600; font-size: 16px; color: var(--pm-navy); }

.pm-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 999px; white-space: nowrap; }
.pm-pill--ok { background: #E7F6F0; color: #087C60; }
.pm-pill--wait { background: #FDF1E3; color: #916414; }

.pm-checklist { list-style: none; margin: 0 0 22px; padding: 0; }
.pm-checkrow { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid #F0F4F8; }
.pm-checkrow:first-child { border-top: 0; }
.pm-checkrow__badge { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center; font-size: 12px; font-weight: 700; line-height: 1; }
.pm-checkrow__badge--on { background: #0BA47E; color: #fff; }
.pm-checkrow__badge--off { background: #FDECEF; color: #CB2645; border: 1.5px solid #F6C9D2; }
.pm-checkrow__label { flex: 1 1 auto; font-size: 14px; color: var(--pm-navy); }
.pm-checkrow__value { font-size: 13px; color: var(--pm-text-secondary); font-family: var(--pm-font-mono); text-align: right; }
.pm-checkrow__link { font-size: 13px; color: #CB2645; font-weight: 600; }

.pm-fact__box { background: #F7F9FC; border: 1px solid #EAF0F6; border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.pm-fact__boxhead { font-size: 13px; font-weight: 600; color: var(--pm-navy); margin-bottom: 14px; }
.pm-fact__row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.pm-field__label { display: block; font-size: 12px; color: #5D6A7A; margin-bottom: 5px; font-weight: 500; }
.pm-next { font-size: 12.5px; color: var(--pm-text-secondary); margin-top: 12px; }
.pm-next b { font-family: var(--pm-font-mono); color: #087C60; font-weight: 600; }

/* Collapsed CSD uploader. The whole .cer/.key/password block hides behind one row
   so the profile page isn't cluttered with file pickers by default. */
.pm-drop { border: 1px solid #E6EDF3; border-radius: 12px; overflow: hidden; }
.pm-drop > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 15px 18px; }
.pm-drop > summary::-webkit-details-marker { display: none; }
.pm-drop > summary::after { content: '⌄'; margin-left: auto; font-size: 20px; line-height: 1; color: #9AA7B4; transition: transform .15s ease; }
.pm-drop[open] > summary::after { transform: rotate(180deg); }
.pm-drop__body { padding: 6px 18px 20px; border-top: 1px solid #F0F4F8; }

/* File inputs that match the panel instead of the browser default. */
.pm-file { width: 100%; font-size: 13px; color: #5D6A7A; }
.pm-file::file-selector-button {
    font-family: inherit; font-size: 13px; font-weight: 600; color: #087C60;
    background: #E7F6F0; border: 1px solid #CFEEE0; border-radius: 8px;
    padding: 9px 14px; margin-right: 12px; cursor: pointer;
}
.pm-file::file-selector-button:hover { background: #DBF0E7; }
.pm-filecell { border: 1.5px dashed #DDE5EC; border-radius: 10px; padding: 12px 14px; background: #fff; }

.pm-fact__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 6px; }

/* Sidebar footer: the doctor's name is the way into Mi perfil. */
.pm-sidefoot-user { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 10px; text-decoration: none; color: inherit; transition: background .15s ease; }
.pm-sidefoot-user:hover { background: rgba(255, 255, 255, .06); }

/* Bandeja: the ingest address is the whole point of the inbox, so it gets a highlighted chip. */
.pm-ingest { background: #E7F6F0; border: 1px solid #CFEEE0; border-left: 4px solid #0BA47E; border-radius: 12px; padding: 15px 20px; margin-bottom: 24px; }
.pm-ingest__label { font-size: 11.5px; font-weight: 700; color: #087C60; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.pm-ingest__addr { font-family: var(--pm-font-mono); font-size: 18px; color: var(--pm-navy); word-break: break-all; }
