/* ============================================
   SISTEMA OTIC — DESIGN SYSTEM
   Tema visual unificado (estilo SaaS)
   ============================================ */

:root {
    /* Marca — OTIC Desk */
    --otic-primary: #155eef;
    --otic-primary-dark: #1248c0;
    --otic-primary-light: #eaf2ff;
    --otic-primary-rgb: 21, 94, 239;
    --otic-secondary: #0284c7;
    --otic-secondary-rgb: 2, 132, 199;

    /* Superficie oscura (sidebar / acentos dark) */
    --otic-dark: #071a42;
    --otic-dark-alt: #0d2b63;
    --otic-dark-rgb: 7, 26, 66;

    /* Neutrales */
    --otic-bg: #f8fafc;
    --otic-surface: #ffffff;
    --otic-border: #e5e7eb;
    --otic-text: #111827;
    --otic-text-muted: #6b7280;
    --otic-page-background:
        radial-gradient(ellipse 74% 230px at 74% -90px, rgba(110, 174, 255, .42) 0 52%, transparent 53%),
        radial-gradient(ellipse 72% 205px at 40% -95px, rgba(190, 218, 255, .72) 0 51%, transparent 52%),
        radial-gradient(ellipse 50% 170px at 100% 104%, rgba(191, 219, 254, .42) 0 45%, transparent 100%),
        linear-gradient(180deg, #eaf3ff 0, #f5f9ff 245px, #fbfdff 470px, #ffffff 100%);

    /* Geometría */
    --otic-radius-sm: 0.625rem;
    --otic-radius: 0.875rem;
    --otic-radius-lg: 1rem;

    /* Sombras suaves */
    --otic-shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.06);
    --otic-shadow: 0 8px 20px -6px rgba(17, 24, 39, 0.10), 0 2px 6px rgba(17, 24, 39, 0.05);

    /* Movimiento */
    --otic-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --otic-duration: 180ms;

    /* Overrides de variables Bootstrap 5.3 */
    --bs-primary: var(--otic-primary);
    --bs-primary-rgb: var(--otic-primary-rgb);
    --bs-body-font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-bg: var(--otic-bg);
    --bs-body-color: var(--otic-text);
    --bs-link-color: var(--otic-primary-dark);
    --bs-link-color-rgb: 18, 72, 192;
    --bs-link-hover-color: var(--otic-primary-dark);
    --bs-link-hover-color-rgb: 18, 72, 192;
    --bs-border-color: var(--otic-border);
    --bs-border-radius: var(--otic-radius);
    --bs-border-radius-sm: var(--otic-radius-sm);
    --bs-border-radius-lg: var(--otic-radius-lg);
}

body {
    font-family: var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    background-color: var(--otic-bg);
    background-image: var(--otic-page-background);
    background-attachment: fixed;
}

@font-face {
    font-family: "bootstrap-icons";
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/fonts/bootstrap-icons.woff2") format("woff2");
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.015em;
}

/* ---- Movimiento y estados interactivos ---- */
@media (prefers-reduced-motion: no-preference) {
    a, .btn, .card, .nav-link, .form-control, .form-select, .badge,
    .sidebar-otic, .main-content-otic, .dropdown-item {
        transition: background-color var(--otic-duration) var(--otic-ease),
                    border-color var(--otic-duration) var(--otic-ease),
                    color var(--otic-duration) var(--otic-ease),
                    box-shadow var(--otic-duration) var(--otic-ease),
                    transform var(--otic-duration) var(--otic-ease),
                    width var(--otic-duration) var(--otic-ease);
    }
}

.btn:active { transform: translateY(1px); }

a:focus-visible, .btn:focus-visible, .nav-link:focus-visible,
.form-control:focus-visible, .form-select:focus-visible {
    outline: 2px solid var(--otic-primary);
    outline-offset: 2px;
}

/* ---- Botones ---- */
.btn {
    font-weight: 500;
    border-radius: var(--otic-radius-sm);
}

.btn-primary {
    --bs-btn-bg: var(--otic-primary);
    --bs-btn-border-color: var(--otic-primary);
    --bs-btn-hover-bg: var(--otic-primary-dark);
    --bs-btn-hover-border-color: var(--otic-primary-dark);
    --bs-btn-active-bg: var(--otic-primary-dark);
    --bs-btn-active-border-color: var(--otic-primary-dark);
    --bs-btn-focus-shadow-rgb: var(--otic-primary-rgb);
    --bs-btn-disabled-bg: var(--otic-primary);
    --bs-btn-disabled-border-color: var(--otic-primary);
}

.btn-dark {
    --bs-btn-bg: var(--otic-dark);
    --bs-btn-border-color: var(--otic-dark);
    --bs-btn-hover-bg: var(--otic-dark-alt);
    --bs-btn-hover-border-color: var(--otic-dark-alt);
    --bs-btn-active-bg: var(--otic-dark-alt);
    --bs-btn-active-border-color: var(--otic-dark-alt);
}

.btn-outline-dark {
    --bs-btn-color: var(--otic-text);
    --bs-btn-border-color: var(--otic-border);
    --bs-btn-hover-bg: var(--otic-dark);
    --bs-btn-hover-border-color: var(--otic-dark);
}

/* ---- Utilidades de color de marca (respetan bg/text/border-opacity-*) ----
   Sin fijar --bs-*-opacity aquí: así una clase combinada como
   ".bg-primary.bg-opacity-10" conserva la opacidad que ponga esa
   segunda clase en vez de que esta regla se la pise (siempre ganaba
   ella por cargarse en un archivo posterior a bootstrap.min.css). */
.text-primary { color: rgba(var(--otic-primary-rgb), var(--bs-text-opacity, 1)) !important; }
.bg-primary { background-color: rgba(var(--otic-primary-rgb), var(--bs-bg-opacity, 1)) !important; }
.border-primary { border-color: rgba(var(--otic-primary-rgb), var(--bs-border-opacity, 1)) !important; }
.bg-dark { background-color: rgba(var(--otic-dark-rgb), var(--bs-bg-opacity, 1)) !important; }

.form-control:focus,
.form-select:focus {
    border-color: var(--otic-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--otic-primary-rgb), 0.15);
}

/* ---- Superficies: cards, sombras, bordes ---- */
.card {
    border-color: var(--otic-border);
    border-radius: var(--otic-radius);
}

.dashboard-action-alert {
    display: block;
    color: inherit;
    text-decoration: none;
    border-radius: var(--otic-radius-sm);
}
.dashboard-action-alert > div { transition: transform var(--otic-duration) var(--otic-ease), box-shadow var(--otic-duration) var(--otic-ease); }
.dashboard-action-alert:hover > div,
.dashboard-action-alert:focus-visible > div {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(15, 23, 42, .14);
}
.dashboard-action-alert:focus-visible { outline: 2px solid var(--otic-primary); outline-offset: 3px; }
.dashboard-kpi-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
    border-radius: var(--otic-radius);
}
.dashboard-kpi-link .card { height: 100%; transition: transform var(--otic-duration) var(--otic-ease), box-shadow var(--otic-duration) var(--otic-ease); }
.dashboard-kpi-link:hover .card,
.dashboard-kpi-link:focus-visible .card { transform: translateY(-2px); box-shadow: var(--otic-shadow) !important; }
.dashboard-kpi-link:focus-visible { outline: 2px solid var(--otic-primary); outline-offset: 3px; }

.shadow-sm { box-shadow: var(--otic-shadow-sm) !important; }
.shadow { box-shadow: var(--otic-shadow) !important; }

.table thead.table-light th,
.table thead.table-light > tr {
    --bs-table-bg: #f8fafc;
    color: var(--otic-text-muted);
    font-weight: 600;
}

.badge { font-weight: 600; letter-spacing: 0.01em; }

/* ---- Badges de estado / prioridad (puntos de color + texto, nunca solo color) ---- */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    font-weight: 600;
}
.status-dot::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: none;
    background: currentColor;
}

/* Mejorar contraste de estados en las superficies claras (WCAG AA). */
:root:not([data-bs-theme="dark"]) .status-dot.text-warning,
:root:not([data-bs-theme="dark"]) .ticket-mobile-status.text-warning {
    color: #795000 !important;
}
:root:not([data-bs-theme="dark"]) .status-dot.text-info,
:root:not([data-bs-theme="dark"]) .ticket-mobile-status.text-info {
    color: #087990 !important;
}

/* ---- Tabla premium: filas espaciadas, sin bordes duros ---- */
.table-premium {
    --bs-table-bg: transparent;
    font-size: 0.9rem;
}
.table-premium thead th {
    border-bottom: 1px solid var(--otic-border);
    color: var(--otic-text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    padding: 0.85rem 1rem;
}
.table-premium tbody td {
    padding: 1.1rem 1rem;
    border-bottom: 1px solid var(--otic-border);
    vertical-align: middle;
}
.table-premium tbody tr:last-child td { border-bottom: none; }
.table-premium tbody tr:hover { background-color: rgba(79, 70, 229, 0.03); }

/* ---- Scrollbar sutil ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 20px; border: 3px solid var(--otic-bg); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   MODO OSCURO
   ============================================ */
[data-bs-theme="dark"] {
    --otic-bg: #0f172a;
    --otic-surface: #1e293b;
    --otic-border: #334155;
    --otic-text: #f1f5f9;
    --otic-text-muted: #94a3b8;
    --otic-primary-light: rgba(21, 94, 239, 0.18);
    --otic-page-background:
        radial-gradient(ellipse 75% 240px at 72% -100px, rgba(30, 64, 126, .42) 0 52%, transparent 53%),
        radial-gradient(ellipse 72% 210px at 38% -100px, rgba(30, 58, 110, .32) 0 51%, transparent 52%),
        radial-gradient(ellipse 48% 170px at 100% 104%, rgba(30, 64, 126, .2) 0 45%, transparent 100%),
        linear-gradient(180deg, #0b1730 0, #0f172a 280px, #0f172a 100%);
    --otic-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --otic-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);

    /* Redeclaradas en el mismo selector que usa Bootstrap para su propio
       modo oscuro: así ganan sin depender del orden de los <link> de CSS. */
    --bs-body-bg: var(--otic-bg);
    --bs-body-color: var(--otic-text);
    --bs-link-color: #93c5fd;
    --bs-link-color-rgb: 147, 197, 253;
    --bs-link-hover-color: #bfdbfe;
    --bs-link-hover-color-rgb: 191, 219, 254;
    --bs-border-color: var(--otic-border);
    --bs-card-bg: var(--otic-surface);
    --bs-tertiary-bg: var(--otic-surface);
    --bs-secondary-bg: var(--otic-surface);
}

[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
    background-color: var(--otic-surface) !important;
}

[data-bs-theme="dark"] .text-dark {
    color: var(--otic-text) !important;
}

[data-bs-theme="dark"] .btn-light {
    --bs-btn-color: #e2e8f0;
    --bs-btn-bg: #1e293b;
    --bs-btn-border-color: #475569;
    --bs-btn-hover-color: #f8fafc;
    --bs-btn-hover-bg: #334155;
    --bs-btn-hover-border-color: #64748b;
    --bs-btn-active-color: #f8fafc;
    --bs-btn-active-bg: #334155;
    --bs-btn-active-border-color: #64748b;
}

[data-bs-theme="dark"] .btn-light.text-primary {
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .table .btn-light {
    color: #93c5fd !important;
    background-color: #1e293b !important;
    border-color: #475569 !important;
}

[data-bs-theme="dark"] .table .btn-light:hover,
[data-bs-theme="dark"] .table .btn-light:focus-visible {
    color: #bfdbfe !important;
    background-color: #334155 !important;
    border-color: #64748b !important;
}

/* .btn-dark usa --otic-dark (#111827), casi idéntico al fondo de página en
   modo oscuro (#0f172a): sin esto el botón se funde y parece invisible. */
[data-bs-theme="dark"] .btn-dark {
    --bs-btn-bg: var(--otic-dark-alt);
    --bs-btn-border-color: var(--otic-dark-alt);
    --bs-btn-hover-bg: #374151;
    --bs-btn-hover-border-color: #374151;
    --bs-btn-active-bg: #374151;
    --bs-btn-active-border-color: #374151;
}

[data-bs-theme="dark"] .table thead.table-light th,
[data-bs-theme="dark"] .table thead.table-light > tr {
    --bs-table-bg: var(--otic-dark-alt, #1f2937);
    color: var(--otic-text-muted);
}

.bg-naranja {
    background-color: #fd7e14 !important;
}
.bg-naranja.bg-opacity-25 {
    background-color: rgba(253, 126, 20, 0.25) !important;
}
.text-naranja {
    color: #fd7e14 !important;
}
.border-naranja {
    border-color: #fd7e14 !important;
}
.border-naranja.border-opacity-50 {
    border-color: rgba(253, 126, 20, 0.5) !important;
}
[data-bs-theme="dark"] .text-naranja {
    color: #ff9f5c !important;
}
[data-bs-theme="dark"] .bg-naranja.bg-opacity-25 {
    background-color: rgba(255, 159, 92, 0.25) !important;
}
.ticket-image-thumb {
    transition: transform .2s ease;
}

.ticket-image-thumb:hover {
    transform: scale(1.05);
}
