/* Componentes — CSS estático (compatible con Tailwind CDN, sin @apply) */

:root {
    --hospital-50: #f0fdfa;
    --hospital-100: #ccfbf1;
    --hospital-500: #14b8a6;
    --hospital-600: #0d9488;
    --hospital-700: #0f766e;
    --hospital-800: #115e59;
}

/* ── Formularios ── */
.input-field {
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    background: #fff;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    transition: border-color .15s, box-shadow .15s;
}
.input-field:focus {
    outline: none;
    border-color: var(--hospital-600);
    box-shadow: 0 0 0 3px rgba(13,148,136,.25);
}
.dark .input-field {
    border-color: #4b5563;
    background: #1f2937;
    color: #f3f4f6;
}
.select-field { appearance: none; }

/* ── Botones ── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: var(--hospital-600);
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    transition: background .15s;
    text-decoration: none;
    border: none;
    cursor: pointer;
}
.btn-primary:hover { background: var(--hospital-700); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    background: #fff;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    transition: background .15s;
    text-decoration: none;
    cursor: pointer;
}
.btn-secondary:hover { background: #f9fafb; }
.dark .btn-secondary {
    border-color: #4b5563;
    background: #1f2937;
    color: #e5e7eb;
}
.dark .btn-secondary:hover { background: #374151; }

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: #dc2626;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    border: none;
    cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }

/* ── Tarjetas ── */
.card {
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (min-width: 640px) { .card { padding: 1.5rem; } }
.dark .card {
    border-color: #374151;
    background: #1f2937;
}

.section-title {
    margin-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}
.dark .section-title {
    border-color: #374151;
    color: #f3f4f6;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    border-radius: 9999px;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.dark .badge-green  { background: rgba(20,83,45,.4);  color: #86efac; }
.dark .badge-yellow { background: rgba(133,77,14,.4); color: #fde047; }
.dark .badge-red    { background: rgba(153,27,27,.4);  color: #fca5a5; }
.dark .badge-blue   { background: rgba(30,64,175,.4);  color: #93c5fd; }

/* ── Sidebar nav ── */
.nav-item-default,
.nav-item-active {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.nav-item-default {
    color: #374151;
}
.nav-item-default:hover {
    background: var(--hospital-50);
    color: var(--hospital-800);
}
.dark .nav-item-default { color: #d1d5db; }
.dark .nav-item-default:hover {
    background: #374151;
    color: #fff;
}

.nav-item-active {
    background: var(--hospital-100);
    color: var(--hospital-800);
}
.dark .nav-item-active {
    background: #134e4a;
    color: #5eead4;
}

.nav-logout {
    color: #dc2626 !important;
}
.nav-logout:hover {
    background: #fef2f2 !important;
}
.dark .nav-logout { color: #f87171 !important; }
.dark .nav-logout:hover { background: rgba(127,29,29,.3) !important; }

[x-cloak] { display: none !important; }

/* denser cards / section titles */
.card { padding: 0.75rem; }
@media (min-width: 640px) { .card { padding: 1rem; } }
.section-title {
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    font-size: 1rem;
}

/* Botones de icono compactos */
.btn-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 9999px;
    border: none;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    transition: transform .12s, filter .12s, box-shadow .12s;
    flex-shrink: 0;
}
.btn-icon:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.18); z-index: 30; }
.btn-icon svg { width: 1.15rem; height: 1.15rem; }
.btn-icon-sm { width: 2rem; height: 2rem; }
.btn-icon-sm svg { width: 1rem; height: 1rem; }
.btn-icon-lg { width: 2.75rem; height: 2.75rem; }
.btn-icon-lg svg { width: 1.35rem; height: 1.35rem; }
.btn-icon-teal { background: #0d9488; }
.btn-icon-green { background: #16a34a; }
.btn-icon-amber { background: #d97706; }
.btn-icon-orange { background: #ea580c; }
.btn-icon-red { background: #dc2626; }
.btn-icon-blue { background: #2563eb; }
.btn-icon-cyan { background: #0891b2; }
.btn-icon-indigo { background: #4f46e5; }
.btn-icon-slate { background: #475569; }
.btn-icon-pink { background: #db2777; }
.btn-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }

/* Label inmediato al hover (no depender del title nativo) */
.btn-icon[data-label]::after,
.btn-icon[title]::after {
    content: attr(data-label);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #111827;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    padding: 0.3rem 0.55rem;
    border-radius: 0.35rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .1s, transform .1s;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.btn-icon[title]:not([data-label])::after {
    content: attr(title);
}
.btn-icon:hover::after,
.btn-icon:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.btn-icon[data-label]::before,
.btn-icon[title]::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #111827;
    opacity: 0;
    pointer-events: none;
    transition: opacity .1s;
    z-index: 50;
}
.btn-icon:hover::before,
.btn-icon:focus-visible::before {
    opacity: 1;
}

/* denser tables */
.table-dense th, .table-dense td { padding: 0.35rem 0.5rem; font-size: 0.8125rem; }
.table-head-teal thead { background: #0d9488; color: #fff; }
.table-head-teal thead th { color: #fff; font-weight: 600; letter-spacing: .02em; }

/* typeahead dropdown */
.ta-wrap { position: relative; z-index: 1; }
.ta-wrap.ta-open { z-index: 10050; }
.ta-list {
    position: absolute; z-index: 10051; left: 0; right: 0; top: 100%;
    margin-top: 0.25rem; max-height: 14rem; overflow: auto;
    border-radius: 0.5rem; border: 1px solid #e5e7eb;
    background: #fff; box-shadow: 0 10px 25px rgba(0,0,0,.18);
}
.dark .ta-list { background: #1f2937; border-color: #4b5563; color: #f3f4f6; }
.ta-item {
    display: block; width: 100%; text-align: left;
    padding: 0.5rem 0.75rem; font-size: 0.875rem;
    border: none; background: transparent; cursor: pointer; color: inherit;
}
.ta-item:hover, .ta-item.active { background: #f0fdfa; }
.dark .ta-item:hover, .dark .ta-item.active { background: #134e4a; }
/* Evita que el card recorte el desplegable */
.card:has(.ta-open) { overflow: visible; }
.space-y-4:has(.ta-open) > div { position: relative; }

/* dialogs / modales nativos en tema oscuro */
dialog {
    color-scheme: light;
}
.dark dialog {
    color-scheme: dark;
    background-color: #111827;
    color: #f3f4f6;
    border-color: #374151;
}
.dark dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
}
.dark dialog h3,
.dark dialog label {
    color: #e5e7eb;
}
.dark dialog .text-gray-500 {
    color: #9ca3af;
}

/* ── SS Data Table toolbar ── */
.ss-table-host { display: flex; flex-direction: column; gap: 0.5rem; }
.ss-table-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
    gap: 0.5rem 0.75rem; padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb; background: #f9fafb;
}
.dark .ss-table-toolbar { background: #111827; border-color: #374151; }
.ss-table-toolbar-spacer { flex: 1; min-width: 0; }
.ss-table-toolbar-right {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
}
.ss-table-page-label {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.75rem; color: #6b7280; white-space: nowrap;
}
.ss-table-page-size {
    appearance: auto;
    -webkit-appearance: menulist;
    width: auto;
    min-width: 4.75rem;
    height: 2rem;
    padding: 0.25rem 0.45rem;
    font-size: 0.8125rem;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
    cursor: pointer;
}
.dark .ss-table-page-size {
    border-color: #4b5563;
    background: #1f2937;
    color: #e5e7eb;
}
.ss-table-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 2rem; min-width: 2rem; padding: 0 0.5rem;
    border-radius: 0.375rem; border: 1px solid #d1d5db; background: #fff;
    color: #374151; cursor: pointer; font-size: 0.75rem;
}
.ss-table-btn:hover { background: #f3f4f6; }
.ss-table-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.dark .ss-table-btn { background: #1f2937; border-color: #4b5563; color: #e5e7eb; }
.dark .ss-table-btn:hover { background: #374151; }
.ss-table-cols-wrap { position: relative; }
.ss-table-cols-menu {
    position: absolute; right: 0; top: calc(100% + 0.25rem); z-index: 40;
    min-width: 12rem; max-height: 18rem; overflow: auto;
    padding: 0.35rem; border-radius: 0.5rem; border: 1px solid #d1d5db;
    background: #fff; box-shadow: 0 10px 25px rgba(0,0,0,.15);
}
.dark .ss-table-cols-menu { background: #1f2937; border-color: #4b5563; }
.ss-table-cols-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.55rem; font-size: 0.8125rem; cursor: pointer;
    border-radius: 0.25rem;
}
.ss-table-cols-item:hover { background: #f0fdfa; }
.dark .ss-table-cols-item:hover { background: #134e4a; }
.ss-table-pager {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.8125rem; color: #6b7280;
    border-top: 1px solid #e5e7eb;
}
.dark .ss-table-pager { border-color: #374151; }
.ss-table-pager-btns { display: flex; align-items: center; gap: 0.5rem; }
.ss-table-pager-page { font-size: 0.75rem; }

/* Kardex — Entrada / Salida (legible en claro y oscuro) */
.ss-row-entrada {
    background: #d1fae5 !important;
    color: #064e3b;
}
.ss-row-salida {
    background: #fecdd3 !important;
    color: #881337;
}
.dark .ss-row-entrada {
    background: rgba(16, 185, 129, 0.28) !important;
    color: #a7f3d0;
}
.dark .ss-row-salida {
    background: rgba(244, 63, 94, 0.28) !important;
    color: #fecdd3;
}
.ss-badge-entrada,
.ss-badge-salida {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #fff;
}
.ss-badge-entrada { background: #059669; }
.ss-badge-salida { background: #e11d48; }
.dark .ss-badge-entrada { background: #10b981; color: #052e16; }
.dark .ss-badge-salida { background: #fb7185; color: #4c0519; }

/* ── Menú principal (Casa) — iconos grandes ── */
.menu-hub {
    max-width: 78rem;
    margin: 0 auto;
    padding: 0.5rem 0 2rem;
}

.menu-hub__hero {
    margin-bottom: 1.75rem;
    padding: 1.35rem 1.5rem;
    border-radius: 1.5rem;
    background:
        radial-gradient(120% 140% at 0% 0%, rgba(20, 184, 166, 0.18), transparent 55%),
        radial-gradient(100% 120% at 100% 0%, rgba(59, 130, 246, 0.12), transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 12px 28px rgba(15, 23, 42, 0.06);
}
.dark .menu-hub__hero {
    background:
        radial-gradient(120% 140% at 0% 0%, rgba(20, 184, 166, 0.18), transparent 55%),
        radial-gradient(100% 120% at 100% 0%, rgba(59, 130, 246, 0.12), transparent 50%),
        linear-gradient(180deg, #1f2937 0%, #111827 100%);
    border-color: #374151;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.menu-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    min-height: 11rem;
    padding: 1.45rem 1rem 1.2rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background:
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.05),
        0 10px 24px rgba(15, 23, 42, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition:
        transform .2s ease,
        box-shadow .2s ease,
        border-color .2s ease,
        background .2s ease;
    color: inherit;
    font: inherit;
    overflow: hidden;
}
.menu-tile::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: currentColor;
    opacity: 0.55;
}
.menu-tile:hover {
    transform: translateY(-5px) scale(1.015);
    border-color: rgba(148, 163, 184, 0.55);
    box-shadow:
        0 4px 10px rgba(15, 23, 42, 0.08),
        0 22px 40px rgba(15, 23, 42, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.menu-tile:active {
    transform: translateY(-1px) scale(1.005);
}
.menu-tile:focus-visible {
    outline: 2px solid var(--hospital-600);
    outline-offset: 3px;
}
.menu-tile--sm {
    min-height: 9.5rem;
    padding: 1.2rem 0.9rem 1rem;
    border-radius: 1.35rem;
}
.dark .menu-tile {
    background: linear-gradient(180deg, #273449 0%, #1f2937 100%);
    border-color: #374151;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 12px 28px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.dark .menu-tile:hover {
    border-color: #4b5563;
    box-shadow:
        0 8px 18px rgba(0, 0, 0, 0.35),
        0 24px 40px rgba(0, 0, 0, 0.35);
}

.menu-tile__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.35rem;
    height: 4.35rem;
    border-radius: 1.35rem;
    margin-bottom: 0.15rem;
    box-shadow:
        0 8px 18px rgba(15, 23, 42, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.menu-tile__icon svg {
    width: 2.15rem;
    height: 2.15rem;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.12));
}
.menu-tile--sm .menu-tile__icon {
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 1.15rem;
}
.menu-tile--sm .menu-tile__icon svg {
    width: 1.85rem;
    height: 1.85rem;
}

.menu-tile__label {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: #0f172a;
}
.dark .menu-tile__label { color: #f8fafc; }

.menu-tile__hint {
    font-size: 0.78rem;
    line-height: 1.35;
    color: #64748b;
    max-width: 12rem;
}
.dark .menu-tile__hint { color: #94a3b8; }

/* Acento superior + icono por variante */
.menu-tile--teal   { color: #0d9488; }
.menu-tile--violet { color: #7c3aed; }
.menu-tile--amber  { color: #d97706; }
.menu-tile--rose   { color: #e11d48; }
.menu-tile--blue   { color: #2563eb; }
.menu-tile--slate  { color: #475569; }
.menu-tile--emerald{ color: #059669; }
.menu-tile--indigo { color: #4f46e5; }
.menu-tile--gray   { color: #4b5563; }
.menu-tile--home   { color: #0f766e; }

.menu-tile--teal .menu-tile__icon   { background: linear-gradient(160deg, #99f6e4, #ccfbf1); color: #0f766e; }
.menu-tile--violet .menu-tile__icon { background: linear-gradient(160deg, #ddd6fe, #ede9fe); color: #6d28d9; }
.menu-tile--amber .menu-tile__icon  { background: linear-gradient(160deg, #fde68a, #fef3c7); color: #b45309; }
.menu-tile--rose .menu-tile__icon   { background: linear-gradient(160deg, #fecdd3, #ffe4e6); color: #be123c; }
.menu-tile--blue .menu-tile__icon   { background: linear-gradient(160deg, #bfdbfe, #dbeafe); color: #1d4ed8; }
.menu-tile--slate .menu-tile__icon  { background: linear-gradient(160deg, #cbd5e1, #e2e8f0); color: #334155; }
.menu-tile--emerald .menu-tile__icon{ background: linear-gradient(160deg, #a7f3d0, #d1fae5); color: #047857; }
.menu-tile--indigo .menu-tile__icon { background: linear-gradient(160deg, #c7d2fe, #e0e7ff); color: #4338ca; }
.menu-tile--gray .menu-tile__icon   { background: linear-gradient(160deg, #e5e7eb, #f3f4f6); color: #374151; }
.menu-tile--home .menu-tile__icon   { background: linear-gradient(160deg, #5eead4, #ccfbf1); color: #0f766e; }

.dark .menu-tile--teal .menu-tile__icon   { background: linear-gradient(160deg, rgba(13,148,136,.45), rgba(15,118,110,.25)); color: #5eead4; }
.dark .menu-tile--violet .menu-tile__icon { background: linear-gradient(160deg, rgba(124,58,237,.4), rgba(109,40,217,.22)); color: #c4b5fd; }
.dark .menu-tile--amber .menu-tile__icon  { background: linear-gradient(160deg, rgba(217,119,6,.4), rgba(180,83,9,.22)); color: #fcd34d; }
.dark .menu-tile--rose .menu-tile__icon   { background: linear-gradient(160deg, rgba(225,29,72,.4), rgba(190,18,60,.22)); color: #fda4af; }
.dark .menu-tile--blue .menu-tile__icon   { background: linear-gradient(160deg, rgba(37,99,235,.4), rgba(29,78,216,.22)); color: #93c5fd; }
.dark .menu-tile--slate .menu-tile__icon  { background: linear-gradient(160deg, rgba(71,85,105,.45), rgba(51,65,85,.25)); color: #cbd5e1; }
.dark .menu-tile--emerald .menu-tile__icon{ background: linear-gradient(160deg, rgba(5,150,105,.4), rgba(4,120,87,.22)); color: #6ee7b7; }
.dark .menu-tile--indigo .menu-tile__icon { background: linear-gradient(160deg, rgba(79,70,229,.4), rgba(67,56,202,.22)); color: #a5b4fc; }
.dark .menu-tile--gray .menu-tile__icon   { background: linear-gradient(160deg, rgba(75,85,99,.45), rgba(55,65,81,.25)); color: #d1d5db; }
.dark .menu-tile--home .menu-tile__icon   { background: linear-gradient(160deg, rgba(13,148,136,.45), rgba(15,118,110,.25)); color: #5eead4; }

@media (min-width: 640px) {
    .menu-tile {
        min-height: 12rem;
        padding: 1.7rem 1.15rem 1.35rem;
        border-radius: 1.65rem;
    }
    .menu-tile__icon {
        width: 4.85rem;
        height: 4.85rem;
        border-radius: 1.45rem;
    }
    .menu-tile__icon svg {
        width: 2.4rem;
        height: 2.4rem;
    }
    .menu-tile__label { font-size: 1.08rem; }
    .menu-tile__hint { font-size: 0.82rem; }
}
