/* ==========================================================================
   Tema macOS — capa visual sobre app.css
   Barra lateral translúcida tipo «source list», barra de herramientas con desenfoque,
   controles con bisel suave, controles segmentados, menús y hojas al estilo macOS.
   El color de acento sigue siendo el primario configurable (Administración → Apariencia).
   Para desactivarlo basta con quitar su <link> en app/Views/layout.php.
   ========================================================================== */

:root {
    --mac-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --mac-bg: #f5f5f7;
    --mac-window: #ffffff;
    --mac-text: #1d1d1f;
    --mac-secondary: #6e6e73;
    --mac-tertiary: #8e8e93;
    --mac-separator: rgba(0, 0, 0, .09);
    --mac-hairline: rgba(0, 0, 0, .12);
    --mac-fill: rgba(0, 0, 0, .05);
    --mac-fill-strong: rgba(0, 0, 0, .08);
    --mac-sidebar: rgba(236, 236, 238, .78);
    --mac-toolbar: rgba(255, 255, 255, .72);
    --mac-menu: rgba(246, 246, 248, .86);
    --mac-radius-window: 12px;
    --mac-radius-control: 7px;
    --mac-shadow-window: 0 0 0 .5px rgba(0, 0, 0, .08), 0 2px 6px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
    --mac-shadow-popover: 0 0 0 .5px rgba(0, 0, 0, .12), 0 10px 30px rgba(0, 0, 0, .18);
    --mac-focus: 0 0 0 3.5px color-mix(in srgb, rgb(var(--bs-primary-rgb)) 38%, transparent);
    --mac-blur: saturate(180%) blur(24px);

    --app-bg: var(--mac-bg);
    --app-text: var(--mac-text);
    --app-muted: var(--mac-secondary);
    --app-border: var(--mac-separator);
    --app-radius: var(--mac-radius-window);
    --app-radius-sm: var(--mac-radius-control);
    --app-shadow-sm: var(--mac-shadow-window);
    --app-shadow: 0 0 0 .5px rgba(0, 0, 0, .08), 0 6px 18px rgba(0, 0, 0, .08);
    --bs-body-font-family: var(--mac-font);
    --bs-body-color: var(--mac-text);
    --bs-border-color: var(--mac-separator);
}

body {
    font-family: var(--mac-font);
    font-size: .875rem;
    letter-spacing: -.003em;
    color: var(--mac-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 { letter-spacing: -.015em; color: var(--mac-text); }
.page-header h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -.022em; }
.text-muted { color: var(--mac-secondary) !important; }
::selection { background: color-mix(in srgb, rgb(var(--bs-primary-rgb)) 28%, transparent); }

/* Barras de desplazamiento finas tipo superposición */
* { scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .25) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .22); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(0, 0, 0, .38); }
::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------------------
   Barra lateral: «source list» translúcida
   -------------------------------------------------------------------------- */
.sidebar {
    background: var(--mac-sidebar) !important;
    -webkit-backdrop-filter: var(--mac-blur);
    backdrop-filter: var(--mac-blur);
    border-right: 1px solid var(--mac-separator);
    scrollbar-color: rgba(0, 0, 0, .2) transparent;
}
.sidebar-brand { min-height: 64px; justify-content: flex-start; padding: 1rem 1.1rem .5rem; }
.sidebar-brand img { background: transparent; padding: 0; border-radius: 0; max-height: 38px; }
.sidebar-brand .brand-text { color: var(--mac-text); font-size: .95rem; font-weight: 600; }
.sidebar-brand .bi { color: var(--app-primary) !important; }
.sidebar-section {
    color: var(--mac-tertiary);
    font-size: .6875rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    padding: .9rem 1.25rem .25rem;
}
.sidebar .nav-link {
    color: var(--mac-text) !important;
    font-weight: 400;
    font-size: .8125rem;
    padding: .32rem .6rem;
    margin: 1px .6rem;
    border-radius: 6px;
    gap: .55rem;
}
.sidebar .nav-link .bi { color: var(--app-primary); font-size: 1rem; }
.sidebar .nav-link:hover { background: var(--mac-fill); color: var(--mac-text) !important; }
.sidebar .nav-link.active {
    background: var(--app-primary);
    color: #fff !important;
    font-weight: 500;
    box-shadow: none;
}
.sidebar .nav-link.active .bi { color: #fff; }
.sidebar .nav-link:focus-visible { outline: none; box-shadow: var(--mac-focus); }
.sidebar-footer { border-top: 1px solid var(--mac-separator); padding: .75rem .6rem; }
.sidebar-user { color: var(--mac-text); }
.sidebar-user .user-name { font-weight: 600; font-size: .8125rem; }
.sidebar-user .user-role { color: var(--mac-secondary); font-size: .72rem; }
.sidebar .avatar { background: var(--app-primary-soft); color: var(--app-primary-dark); }
.sidebar-section-divider { background: var(--mac-separator); }

/* --------------------------------------------------------------------------
   Barra de herramientas unificada
   -------------------------------------------------------------------------- */
.topbar {
    min-height: 52px;
    background: var(--mac-toolbar) !important;
    -webkit-backdrop-filter: var(--mac-blur);
    backdrop-filter: var(--mac-blur);
    border-bottom: 1px solid var(--mac-separator);
}
.topbar .topbar-title { font-size: .875rem; font-weight: 700; }
.topbar .btn-icon { width: 32px; height: 28px; border-radius: 6px; color: var(--mac-secondary); }
.topbar .btn-icon:hover { background: var(--mac-fill); color: var(--mac-text); }
.topbar-search { max-width: 340px; }
.topbar-search .form-control {
    height: 30px;
    border-radius: 8px;
    background: var(--mac-fill);
    border: 0;
    box-shadow: none;
    font-size: .8125rem;
    padding-left: 2rem;
}
.topbar-search .form-control:focus { background: #fff; box-shadow: var(--mac-focus), 0 0 0 1px color-mix(in srgb, rgb(var(--bs-primary-rgb)) 60%, transparent); }
.topbar-search .bi-search { left: .7rem; font-size: .8rem; }
.topbar-search kbd { background: transparent; border: 1px solid var(--mac-hairline); border-radius: 4px; }
.topbar .user-toggle { padding: .15rem .4rem; border-radius: 7px; }
.topbar .user-toggle:hover { background: var(--mac-fill); }
.topbar .avatar { width: 28px; height: 28px; font-size: .7rem; }
.topbar-date { font-size: .75rem; }

.main-content { padding: 1.5rem 2rem; }
.breadcrumb { font-size: .75rem; }
.footer-clinica { border-top: 0; color: var(--mac-tertiary); }

/* --------------------------------------------------------------------------
   Ventanas (tarjetas)
   -------------------------------------------------------------------------- */
.card, .card.border-0 {
    border: 0 !important;
    border-radius: var(--mac-radius-window);
    background: var(--mac-window);
    box-shadow: var(--mac-shadow-window) !important;
}
.card > .card-header, .card > .card-footer { background: transparent; border-color: var(--mac-separator); padding: .8rem 1.1rem; }
.card-header h5, .card-header .h5, .card-header h6 { font-size: .9375rem; font-weight: 600; }
a.stat-card:hover { transform: none; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .1), 0 6px 18px rgba(0, 0, 0, .08) !important; }
.stat-card .stat-label { font-size: .75rem; font-weight: 500; color: var(--mac-secondary); }
.stat-card .stat-value { font-weight: 700; letter-spacing: -.03em; }
.stat-icon { border-radius: 10px; width: 42px; height: 42px; font-size: 1.2rem; }

/* --------------------------------------------------------------------------
   Botones con bisel macOS
   -------------------------------------------------------------------------- */
.btn {
    border-radius: var(--mac-radius-control);
    font-weight: 500;
    font-size: .8125rem;
    padding: .34rem .8rem;
    line-height: 1.35;
    transition: background-color .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:active { transform: none; filter: brightness(.94); }
.btn-sm { font-size: .78rem; padding: .22rem .6rem; border-radius: 6px; }
.btn-lg { font-size: .9375rem; padding: .5rem 1rem; border-radius: 9px; }
.btn:focus-visible { box-shadow: var(--mac-focus) !important; }

.btn-primary, .btn-success, .btn-danger, .btn-info, .btn-warning, .btn-dark {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0));
    box-shadow: 0 .5px 1px rgba(0, 0, 0, .25), inset 0 .5px 0 rgba(255, 255, 255, .2);
}

/* Botones secundarios: bisel blanco con borde fino */
.btn-light,
.btn-secondary,
.btn-outline-secondary,
.btn-outline-dark,
.btn-outline-primary,
.btn-outline-success,
.btn-outline-info,
.btn-outline-warning,
.btn-outline-danger {
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--mac-hairline);
    --bs-btn-hover-bg: #f6f6f7;
    --bs-btn-hover-border-color: var(--mac-hairline);
    --bs-btn-active-bg: #ececee;
    --bs-btn-active-border-color: var(--mac-hairline);
    --bs-btn-disabled-bg: #fff;
    --bs-btn-disabled-border-color: var(--mac-hairline);
    box-shadow: 0 .5px 1.5px rgba(0, 0, 0, .1);
}
.btn-light, .btn-secondary, .btn-outline-secondary, .btn-outline-dark { --bs-btn-color: var(--mac-text); --bs-btn-hover-color: var(--mac-text); --bs-btn-active-color: var(--mac-text); }
.btn-outline-primary { --bs-btn-color: var(--app-primary-dark); --bs-btn-hover-color: var(--app-primary-dark); --bs-btn-active-color: var(--app-primary-darker); }
.btn-outline-success { --bs-btn-color: #1a7f37; --bs-btn-hover-color: #1a7f37; --bs-btn-active-color: #1a7f37; }
.btn-outline-info { --bs-btn-color: #0a6c86; --bs-btn-hover-color: #0a6c86; --bs-btn-active-color: #0a6c86; }
.btn-outline-warning { --bs-btn-color: #9a6400; --bs-btn-hover-color: #9a6400; --bs-btn-active-color: #9a6400; }
.btn-outline-danger { --bs-btn-color: #d70015; --bs-btn-hover-color: #d70015; --bs-btn-active-color: #d70015; }
.btn-check:checked + .btn-outline-primary { --bs-btn-active-bg: var(--app-primary); --bs-btn-active-color: #fff; --bs-btn-active-border-color: var(--app-primary); }
.btn-link { box-shadow: none; }

/* Controles segmentados (grupos de radio) */
.btn-group:has(> .btn-check) {
    background: var(--mac-fill-strong);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}
.btn-group:has(> .btn-check) > .btn {
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-color: var(--mac-text);
    --bs-btn-hover-color: var(--mac-text);
    border-radius: 6px !important;
    box-shadow: none;
    margin: 0 !important;
    padding-top: .2rem;
    padding-bottom: .2rem;
}
.btn-group:has(> .btn-check) > .btn-check:checked + .btn {
    background: #fff;
    color: var(--mac-text);
    border-color: transparent;
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .14);
}

/* --------------------------------------------------------------------------
   Campos de formulario
   -------------------------------------------------------------------------- */
.form-control, .form-select {
    border-radius: var(--mac-radius-control);
    border: 1px solid var(--mac-hairline);
    box-shadow: inset 0 .5px 1px rgba(0, 0, 0, .04);
    font-size: .8125rem;
    padding: .38rem .65rem;
    background-color: #fff;
}
.form-select { padding-right: 2rem; background-position: right .55rem center; }
.form-control-sm, .form-select-sm { font-size: .78rem; padding-top: .26rem; padding-bottom: .26rem; border-radius: 6px; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: color-mix(in srgb, rgb(var(--bs-primary-rgb)) 70%, #fff);
    box-shadow: var(--mac-focus);
}
.form-control::placeholder { color: #a1a1a6; }
.form-label { font-size: .78rem; font-weight: 500; color: var(--mac-text); }
.form-label.small { font-size: .75rem; }
.form-text { font-size: .72rem; color: var(--mac-tertiary); }
.input-group-text { background: #f5f5f7; border-color: var(--mac-hairline); font-size: .8125rem; color: var(--mac-secondary); }
.form-check-input { border-color: rgba(0, 0, 0, .25); box-shadow: 0 .5px 1px rgba(0, 0, 0, .08); }
.form-check-input[type="checkbox"] { border-radius: 4px; }
.form-switch .form-check-input { border-radius: 2em; }
textarea.form-control { line-height: 1.45; }

/* --------------------------------------------------------------------------
   Tablas tipo lista de macOS
   -------------------------------------------------------------------------- */
.table { --bs-table-hover-bg: color-mix(in srgb, rgb(var(--bs-primary-rgb)) 7%, #fff); font-size: .8125rem; }
.table > thead th, .table > thead td {
    text-transform: none;
    letter-spacing: 0;
    font-size: .75rem;
    font-weight: 600;
    color: var(--mac-secondary);
    background: transparent;
    border-bottom: 1px solid var(--mac-separator);
}
.table > tbody > tr:nth-of-type(even) > * { background-color: #fafafb; }
.table > tbody > tr.table-light > *, .table > tbody > tr.lote-historial > * { background-color: #f5f5f7; }
.table > :not(caption) > * > * { padding: .55rem .8rem; border-color: rgba(0, 0, 0, .05); }
.table-light { --bs-table-bg: transparent; }

/* --------------------------------------------------------------------------
   Menús, popovers, hojas (modales) y avisos
   -------------------------------------------------------------------------- */
.dropdown-menu {
    background: var(--mac-menu);
    -webkit-backdrop-filter: var(--mac-blur);
    backdrop-filter: var(--mac-blur);
    border: 0;
    border-radius: 10px;
    box-shadow: var(--mac-shadow-popover);
    padding: 5px;
    font-size: .8125rem;
    min-width: 13rem;
}
.dropdown-item { border-radius: 5px; padding: .3rem .6rem; color: var(--mac-text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--app-primary); color: #fff; }
.dropdown-item:hover .bi, .dropdown-item:focus .bi { color: #fff !important; }
.dropdown-item.text-danger:hover { background: #ff3b30; color: #fff !important; }
.dropdown-divider { border-color: var(--mac-separator); margin: 4px 6px; }

.modal-backdrop { background: rgba(0, 0, 0, .25); }
.modal-backdrop.show { opacity: 1; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-content {
    border-radius: 14px;
    border: 0;
    background: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: var(--mac-blur);
    backdrop-filter: var(--mac-blur);
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .15), 0 24px 60px rgba(0, 0, 0, .28);
}
.modal-header { border-bottom: 1px solid var(--mac-separator); padding: .85rem 1.15rem; }
.modal-title { font-size: .9375rem; font-weight: 600; }
.modal-footer { border-top: 1px solid var(--mac-separator); padding: .7rem 1.15rem; background: rgba(245, 245, 247, .6); border-radius: 0 0 14px 14px; }
.modal-footer.border-0 { background: transparent; }
.modal.fade .modal-dialog { transform: scale(.97); transition: transform .18s ease-out; }
.modal.show .modal-dialog { transform: none; }

.tooltip { --bs-tooltip-bg: rgba(40, 40, 42, .92); --bs-tooltip-border-radius: 6px; --bs-tooltip-font-size: .75rem; }
.toast { border: 0; border-radius: 12px; background: var(--mac-menu); -webkit-backdrop-filter: var(--mac-blur); backdrop-filter: var(--mac-blur); box-shadow: var(--mac-shadow-popover); }
.toast-header { background: transparent; border-bottom-color: var(--mac-separator); }

.alert {
    border: 0 !important;
    border-radius: 10px;
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .06);
    font-size: .8125rem;
}
.alert-success { background: #e9f7ee; color: #14532d; }
.alert-danger { background: #fdecec; color: #7f1d1d; }
.alert-warning { background: #fff6e0; color: #6b4500; }
.alert-info { background: #e8f3fd; color: #0b3c66; }
.alert-light { background: #fff; }

.badge { border-radius: 999px; font-weight: 600; font-size: .7rem; padding: .3em .6em; }
.text-bg-light.border { border-color: var(--mac-hairline) !important; }

.nav-tabs { border-bottom: 1px solid var(--mac-separator); gap: .25rem; }
.nav-tabs .nav-link { border: 0; border-radius: 7px 7px 0 0; font-size: .8125rem; color: var(--mac-secondary); }
.nav-tabs .nav-link.active { background: transparent; color: var(--app-primary-dark); box-shadow: inset 0 -2px 0 var(--app-primary); }

.list-group-item { border-color: var(--mac-separator); }
.quick-action { border: 0; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .04); font-size: .8125rem; }
.quick-action:hover { box-shadow: 0 0 0 1px var(--app-primary), 0 1px 2px rgba(0, 0, 0, .04); }
.agenda-item { border-bottom-color: rgba(0, 0, 0, .05); }
.agenda-time { border-radius: 8px; }
.ubicacion-chip { background: #fff; border-color: var(--mac-hairline); }
.back-to-top { box-shadow: var(--mac-shadow-popover); }
.paciente-picker-results { border-radius: 10px; box-shadow: var(--mac-shadow-popover) !important; overflow: hidden; }

/* --------------------------------------------------------------------------
   Acceso: ventana sobre fondo de escritorio
   -------------------------------------------------------------------------- */
.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(1200px 700px at 12% 18%, color-mix(in srgb, rgb(var(--bs-primary-rgb)) 55%, #fff) 0, transparent 60%),
        radial-gradient(900px 600px at 88% 82%, color-mix(in srgb, rgb(var(--bs-primary-rgb)) 40%, #7aa7ff) 0, transparent 55%),
        radial-gradient(800px 500px at 70% 10%, #f3d2c1 0, transparent 55%),
        linear-gradient(160deg, #e9eef3, #cfd9e2);
}
.auth-aside { display: none; }
.auth-main { background: transparent; padding: 0; width: 100%; }
.auth-card {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 14px !important;
    background: rgba(255, 255, 255, .78) !important;
    -webkit-backdrop-filter: var(--mac-blur);
    backdrop-filter: var(--mac-blur);
    box-shadow: 0 0 0 .5px rgba(0, 0, 0, .12), 0 30px 80px rgba(0, 0, 0, .25) !important;
}
/* Botones de ventana (decorativos) */
.auth-card::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5f57;
    box-shadow: 20px 0 0 #febc2e, 40px 0 0 #28c840;
}
.auth-card .card-body { padding: 2.75rem 2.25rem 2rem; }
.auth-icon { border-radius: 16px; width: 64px; height: 64px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.auth-card .form-control { height: 36px; }
.auth-card .btn-lg { height: 38px; font-size: .875rem; }
.auth-card .input-group-text { background: #fff; }

@media (max-width: 991.98px) {
    .main-content { padding: 1rem; }
    .sidebar { background: rgba(240, 240, 242, .92) !important; }
}

@media print {
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
