/* Mobile first overrides para FONAR */
:root {
    --fonar-primary: #f97316;
}

[data-theme="light"] {
    --pico-primary: #f97316;
    --pico-primary-hover: #ea580c;
    --pico-primary-focus: rgba(249, 115, 22, 0.25);
    --pico-primary-inverse: #fff;
}

/* ---- NAV ---- */
nav {
    padding: 0.5rem 0;
}

nav strong {
    color: var(--fonar-primary);
}

/* ---- TABLAS ---- */
table {
    font-size: 0.875rem;
}

figure {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- TOTALES BOX ---- */
.totales-box {
    background: var(--pico-card-background-color);
    border: 2px solid var(--fonar-primary);
    border-radius: var(--pico-border-radius);
    padding: 1rem;
    margin-top: 1rem;
}

.totales-box .totales-grid {
    display: flex;
    gap: 1.5rem;
}

.totales-box .monto {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--fonar-primary);
}

/* ---- BOTONES COMUNES ---- */
/* Normalizar todos los botones inline para misma altura */
.btn-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.btn-row form {
    margin: 0;
    display: flex;
}

.btn-row button,
.btn-row a[role="button"] {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-sizing: border-box;
    height: 40px;
}

/* ---- NAVEGACIÓN PERIODOS ← → ---- */
.periodo-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.periodo-nav a[role="button"] {
    padding: 0.4rem 0.8rem;
    width: auto;
}

.periodo-nav .periodo-nav-center {
    text-align: center;
}

.periodo-nav .periodo-nav-center h2 {
    margin: 0;
}

/* ---- ACCIONES DE TABLA ---- */
.acciones {
    display: flex;
    gap: 0.25rem;
}

.acciones button,
.acciones a[role="button"] {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.page-header h2 {
    margin: 0;
}

/* Clickable rows */
tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:active {
    background: var(--pico-primary-focus);
}

/* ---- NAV MOBILE FIX ---- */
nav ul {
    align-items: center;
}

nav ul li {
    display: flex;
    align-items: center;
}

nav form button.btn-salir,
nav form button.btn-salir:hover {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    margin: 0;
    border: 1px solid #9ca3af;
    background: transparent;
    color: #374151;
    border-radius: var(--pico-border-radius);
    cursor: pointer;
    line-height: 1.5;
    --pico-background-color: transparent;
    --pico-color: #374151;
}

/* ---- MOBILE ---- */
@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    table {
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 0.35rem 0.4rem;
    }

    /* Ocultar columnas en mobile */
    .hide-mobile {
        display: none;
    }

    /* Acciones de tabla: apilar verticalmente */
    .acciones {
        flex-direction: column;
        gap: 0.25rem;
    }

    .acciones button,
    .acciones a[role="button"] {
        min-height: 36px;
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
    }

    /* Page header: stack vertical */
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    /* Btn row: grid 2 columnas, se adapta a impares */
    .btn-row {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }

    /* Si hay un número impar, el último ocupa todo el ancho */
    .btn-row > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .btn-row form {
        width: 100%;
    }

    .btn-row button,
    .btn-row a[role="button"] {
        width: 100%;
        height: 44px;
        font-size: 0.85rem;
        padding: 0.4rem;
    }

    /* Profesionales table: hide acciones on mobile, rows are clickable */
    .table-profesionales .acciones {
        display: none;
    }

    .table-profesionales th:last-child {
        display: none;
    }
}

/* ---- PWA ---- */
body {
    min-height: 100dvh;
}

/* Pull to refresh indicator */
.ptr-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--fonar-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.15s ease-out;
    z-index: 9999;
}
