/* ===========================================
   LegalConsultas - Estilos personalizados
   Complementa Tailwind CSS
   =========================================== */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: #F8FAFC;
    color: #0B1020;
}

.font-display { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* Sidebar: azul oscuro plano (slate-800) */
.sidebar-bg {
    background: #1E293B;
}

/* Topbar horizontal: fondo oscuro translúcido con efecto glass */
.topbar-bg {
    background:
        linear-gradient(180deg, rgba(11, 16, 32, 0.85) 0%, rgba(17, 24, 39, 0.85) 100%);
}

/* Sidebar vertical - estado colapsado (desktop) */
#vertical-sidebar.is-collapsed {
    width: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    opacity: 0;
    border-right: none !important;
}
#vertical-sidebar.is-collapsed .sidebar-label,
#vertical-sidebar.is-collapsed .sidebar-footer {
    display: none;
}
#vertical-sidebar.is-collapsed nav.sidebar-nav {
    display: none;
}

/* Scrollbar fina y discreta dentro del menú del sidebar */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* Módulos colapsables del sidebar (M1, M2...).
   El alto se anima con grid-template-rows: 1fr -> 0fr. */
.sidebar-group-panel {
    display: grid;
    grid-template-rows: 1fr;
}
.sidebar-group-panel > div {
    overflow: hidden;
    min-height: 0;
    transition: visibility 0s;
}
.sidebar-group.is-closed .sidebar-group-panel {
    grid-template-rows: 0fr;
}
/* visibility evita que los links ocultos reciban foco con Tab */
.sidebar-group.is-closed .sidebar-group-panel > div {
    visibility: hidden;
    transition: visibility 0s linear 0.25s;
}
.sidebar-group.is-closed .sidebar-group-chevron {
    transform: rotate(-90deg);
}
/* La animación solo se activa tras restaurar el estado guardado (sin parpadeo al cargar) */
#vertical-sidebar.is-ready .sidebar-group-panel {
    transition: grid-template-rows 0.25s ease;
}

/* En móvil el sidebar se comporta como drawer:
   oculto por defecto con -translate-x-full, visible con translate-x-0 */
@media (max-width: 767.98px) {
    #vertical-sidebar {
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    /* Forzar ocultamiento de las reglas de is-collapsed en móvil */
    #vertical-sidebar.is-collapsed {
        width: 16rem !important;
        opacity: 1;
    }
}

/* Backdrop para drawer móvil (transición suave) */
[data-sidebar-overlay] {
    transition: opacity 0.3s ease-in-out;
}

/* Cuando el drawer móvil está abierto, bloquea el scroll del body */
@media (max-width: 767.98px) {
    body.drawer-open {
        overflow: hidden;
    }
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #06B6D4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glass effect */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Animated background blobs - clase con prefijo para evitar
   conflicto con Tailwind (que podrña interpretar "blob" como
   una utilidad personalizada). */
.deco-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

/* Hover lift effect */
.hover-lift {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}
.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.2);
}

/* Status dot pulse */
.status-dot {
    position: relative;
}
.status-dot::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.4;
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
    75%, 100% { transform: scale(2); opacity: 0; }
}

/* Custom focus */
input:focus, select:focus, textarea:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
    border-color: #6366F1;
}

/* Card animations */
.fade-in-up {
    animation: fadeInUp 0.5s ease-out;
    /* opacity: 1 por defecto para que el contenido sea visible
       incluso si la animacián no se ejecuta (no-JS, animacián cortada, etc.) */
}
.fade-in-up.fade-start {
    opacity: 0;
}
.scale-in {
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.scale-in.fade-start {
    opacity: 0;
}
@keyframes fadeInUp {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

/* Stagger animations: solo animar cuando JS añade la clase */
.stagger.fade-start > * { animation: fadeInUp 0.5s ease-out; opacity: 0; }
.stagger.fade-start > *:nth-child(1) { animation-delay: 0.05s; }
.stagger.fade-start > *:nth-child(2) { animation-delay: 0.1s; }
.stagger.fade-start > *:nth-child(3) { animation-delay: 0.15s; }
.stagger.fade-start > *:nth-child(4) { animation-delay: 0.2s; }
.stagger.fade-start > *:nth-child(5) { animation-delay: 0.25s; }
.stagger.fade-start > *:nth-child(6) { animation-delay: 0.3s; }
.stagger.fade-start > *:nth-child(7) { animation-delay: 0.35s; }
.stagger.fade-start > *:nth-child(8) { animation-delay: 0.4s; }

/* Donut chart */
.donut-segment {
    transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1);
    transform: rotate(-90deg);
    transform-origin: center;
}

/* Timeline */
.timeline-line {
    position: absolute;
    left: 19px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, #6366F1 0%, #06B6D4 100%);
    opacity: 0.2;
}

/* Custom checkbox */
input[type="checkbox"].custom-check {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #CBD5E1;
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}
input[type="checkbox"].custom-check:hover {
    border-color: #6366F1;
}
input[type="checkbox"].custom-check:checked {
    background: #6366F1;
    border-color: #6366F1;
}
input[type="checkbox"].custom-check:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Form helpers */
.field-group {
    position: relative;
}
.field-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
}
.field-input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 1.5px solid #E2E8F0;
    border-radius: 12px;
    background: white;
    font-size: 14px;
    color: #0B1020;
    transition: all 0.2s;
}
.field-input:focus {
    border-color: #6366F1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.field-input::placeholder { color: #94A3B8; }

.field-textarea {
    width: 100%;
    padding: 14px;
    border: 1.5px solid #E2E8F0;
    border-radius: 12px;
    background: white;
    font-size: 14px;
    color: #0B1020;
    min-height: 140px;
    resize: vertical;
    font-family: inherit;
    transition: all 0.2s;
}

/* Category chip */
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}
.cat-chip .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid;
    line-height: 1;
}
.status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Table row hover */
.table-row-hover {
    transition: background 0.2s;
}
.table-row-hover:hover {
    background: linear-gradient(90deg, rgba(99,102,241,0.04) 0%, rgba(139,92,246,0.04) 100%);
}

/* Tab active indicator */
.tab-active {
    position: relative;
}
.tab-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, #6366F1, #8B5CF6);
    border-radius: 2px;
}

/* Selectable category card */
.cat-card {
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}
.cat-card input { position: absolute; opacity: 0; pointer-events: none; }
.cat-card .card-inner {
    position: relative;
    padding: 18px;
    border: 2px solid #E2E8F0;
    border-radius: 16px;
    background: white;
    transition: all 0.2s;
    text-align: center;
    overflow: hidden;
}
.cat-card .card-inner > * { position: relative; z-index: 2; }
.cat-card:hover .card-inner {
    border-color: #C7D2FE;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -10px rgba(99,102,241,0.2);
}
/* Tinte de color al seleccionar la categoría */
.cat-card input:checked + .card-inner {
    border-color: currentColor;
    box-shadow: 0 10px 30px -10px currentColor, 0 0 0 4px color-mix(in srgb, currentColor 12%, transparent);
    transform: translateY(-2px);
}
.cat-card input:checked + .card-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0.12;
    border-radius: 14px;
    z-index: 0;
    pointer-events: none;
}
.cat-card input:checked + .card-inner::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: currentColor;
    color: white;
    z-index: 3;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
    background-size: 14px 14px;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 2px 6px -1px rgba(0,0,0,0.25);
}

/* Drop zone para archivos */
.dropzone {
    border: 2px dashed #E2E8F0;
    border-radius: 12px;
    padding: 28px 20px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    background: #FAFBFC;
    position: relative;
}
.dropzone:hover {
    border-color: var(--dz-color, #6366F1);
    background: var(--dz-bg, rgba(99,102,241,0.04));
}
.dropzone.is-dragover {
    border-color: var(--dz-color, #6366F1);
    background: var(--dz-bg, rgba(99,102,241,0.08));
    transform: scale(1.01);
}
/* Input file: posición absoluta, opacidad 0 para asegurar que el .click() funcione
   en todos los navegadores (algunos requieren que el input no sea display:none) */
.dropzone input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 5;
}
.dropzone-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dropzone-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13px;
    text-align: left;
}
.dropzone-file .file-name { flex: 1; min-width: 0; font-weight: 500; color: #1E293B; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-file .file-size { color: #64748B; font-size: 11px; font-family: 'JetBrains Mono', monospace; }
.dropzone-file .file-remove { background: none; border: none; color: #94A3B8; cursor: pointer; padding: 2px; border-radius: 4px; }
.dropzone-file .file-remove:hover { color: #EF4444; background: #FEF2F2; }

/* Page header */
.page-header {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    padding: 32px;
    color: white;
    margin-bottom: 24px;
    background:
        radial-gradient(at 0% 0%, rgba(99,102,241,0.4) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139,92,246,0.4) 0px, transparent 50%),
        linear-gradient(135deg, #0B1020 0%, #1E1B4B 100%);
}

/* Variante compacta del page header (menor padding y altura) */
.page-header.compact {
    padding: 18px 24px;
    border-radius: 18px;
    margin-bottom: 20px;
}
.page-header.compact .deco-blob {
    opacity: 0.6;
}

/* Variante de fondo negro sólido (sin gradiente) */
.page-header--solid-black {
    background: #0B0B0B !important;
}

/* Variante con paleta de marca rojo / ámbar / negro
   (alineada con publico.php y login.php) */
.page-header--brand {
    background:
        radial-gradient(at 0% 0%, rgba(220, 38, 38, 0.40) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(217, 119, 6, 0.40) 0px, transparent 50%),
        linear-gradient(135deg, #0B0B0B 0%, #450A0A 60%, #7C2D12 100%);
}

/* Avatar gradient */
.avatar-grad-1 { background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%); }
.avatar-grad-2 { background: linear-gradient(135deg, #10B981 0%, #06B6D4 100%); }
.avatar-grad-3 { background: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%); }
.avatar-grad-4 { background: linear-gradient(135deg, #EC4899 0%, #8B5CF6 100%); }
.avatar-grad-5 { background: linear-gradient(135deg, #06B6D4 0%, #3B82F6 100%); }

/* Search highlight */
.search-highlight {
    background: linear-gradient(120deg, #FEF3C7 0%, #FDE68A 100%);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
}

/* Priority dot */
.priority-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #94A3B8;
}

/* Print friendly */
@media print {
    .sidebar-bg, .topbar-bg, .no-print { display: none !important; }
    body { background: white; }
}

/* Botón en estado "enviando" (sin usar atributo disabled para no romper
   el envío nativo del formulario) */
button.is-submitting,
button[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===========================================
   Login / Auth - Modo oscuro
   =========================================== */

/* Fondo mesh oscuro (login) */
.bg-mesh-dark {
    background:
        radial-gradient(at 0% 0%, rgba(220,38,38,0.20) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(217,119,6,0.15) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(11,11,11,0.45) 0px, transparent 50%),
        linear-gradient(180deg, #0B0B0B 0%, #1A0505 100%);
}

/* Inputs oscuros (login) */
.field-input-dark {
    width: 100%;
    padding: 10px 14px 10px 42px;
    border: 1.5px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}
.field-input-dark::placeholder { color: rgba(255,255,255,0.35); }
.field-input-dark:focus {
    border-color: #EF4444;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.20);
    outline: none;
}

/* Checkbox oscuro (login) */
input[type="checkbox"].custom-check-dark {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.20);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
    background: rgba(255,255,255,0.04);
}
input[type="checkbox"].custom-check-dark:hover {
    border-color: #EF4444;
}
input[type="checkbox"].custom-check-dark:checked {
    background: linear-gradient(135deg, #DC2626, #0B0B0B);
    border-color: #DC2626;
}
input[type="checkbox"].custom-check-dark:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
