/* ============================================================
   NEXO — Sistema de diseño profesional
   ============================================================
   - Tipografía: Inter (cargada en app.php)
   - Inputs: altura 38px, focus elegante
   - Botones: jerarquía clara
   - Sidebar: soporte modo colapsado
   ============================================================ */

/* === RESET Y BASE === */
html {
    transition: background-color 0.15s ease, color 0.15s ease;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11"; /* Inter optimizations */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === SCROLLBAR ELEGANTE === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }
.dark ::-webkit-scrollbar-thumb { background: #3f3f46; }
.dark ::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* === FOCUS RING UNIFICADO === */
*:focus { outline: none; }
*:focus-visible {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    border-radius: 8px;
}

/* === SELECCIÓN DE TEXTO === */
::selection {
    background-color: rgba(124, 58, 237, 0.2);
    color: inherit;
}

/* ============================================================
   INPUTS, SELECTS, TEXTAREAS
   ============================================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
    width: 100%;
    height: 38px;
    background-color: #ffffff;
    border: 1px solid #e4e4e7;
    color: #18181b;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

textarea {
    height: auto;
    min-height: 70px;
    padding: 10px 12px;
    resize: vertical;
}

select {
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6l6 -6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

input::placeholder,
textarea::placeholder {
    color: #a1a1aa;
    font-weight: 400;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #d4d4d8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: #f4f4f5;
    color: #71717a;
    cursor: not-allowed;
    box-shadow: none;
}

input[readonly] {
    background-color: #fafafa;
}

/* === DARK MODE INPUTS === */
.dark input[type="text"],
.dark input[type="email"],
.dark input[type="password"],
.dark input[type="number"],
.dark input[type="date"],
.dark input[type="search"],
.dark input[type="tel"],
.dark input[type="url"],
.dark select,
.dark textarea {
    background-color: #18181b;
    border-color: #3f3f46;
    color: #fafafa;
    box-shadow: none;
}

.dark select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6l6 -6'/%3e%3c/svg%3e");
}

.dark input::placeholder,
.dark textarea::placeholder {
    color: #71717a;
}

.dark input:hover,
.dark select:hover,
.dark textarea:hover {
    border-color: #52525b;
}

.dark input:focus,
.dark select:focus,
.dark textarea:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.20);
}

.dark input:disabled,
.dark select:disabled,
.dark textarea:disabled {
    background-color: #27272a;
    color: #71717a;
}

.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(0.6);
}

/* === CHECKBOXES === */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    height: auto;
    cursor: pointer;
    accent-color: #7c3aed;
}

/* ============================================================
   BOTONES — Jerarquía clara
   ============================================================ */

/* === PRIMARIO (Crear, Guardar, Confirmar) === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    background-color: #7c3aed;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid #7c3aed;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(124, 58, 237, 0.15);
    white-space: nowrap;
}
.btn-primary:hover {
    background-color: #6d28d9;
    border-color: #6d28d9;
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.25);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(124, 58, 237, 0.15);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* === SECUNDARIO (Cancelar, Filtros) === */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    background-color: #ffffff;
    border: 1px solid #e4e4e7;
    color: #3f3f46;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    white-space: nowrap;
}
.btn-secondary:hover {
    background-color: #f4f4f5;
    border-color: #d4d4d8;
}
.btn-secondary:active {
    background-color: #e4e4e7;
}

.dark .btn-secondary {
    background-color: #27272a;
    border-color: #3f3f46;
    color: #e4e4e7;
}
.dark .btn-secondary:hover {
    background-color: #3f3f46;
    border-color: #52525b;
}

/* === DESTRUCTIVO (Eliminar, Anular) === */
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    background-color: #dc2626;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid #dc2626;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.15);
    white-space: nowrap;
}
.btn-danger:hover {
    background-color: #b91c1c;
    border-color: #b91c1c;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}

/* === BOTON SMALL === */
.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 0.8125rem;
}

/* === BOTON GHOST (terciario, sin border) === */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    color: #71717a;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-ghost:hover {
    background-color: #f4f4f5;
    color: #18181b;
}
.dark .btn-ghost { color: #a1a1aa; }
.dark .btn-ghost:hover {
    background-color: #27272a;
    color: #fafafa;
}

/* ============================================================
   BADGE
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    white-space: nowrap;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    background-color: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
}
.dark .card {
    background-color: #1c1c1f;
    border-color: #27272a;
    box-shadow: none;
}

.kpi-card {
    border-radius: 12px;
    padding: 18px;
    border: 1px solid;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

/* ============================================================
   SIDEBAR COLAPSABLE
   ============================================================ */
aside.sidebar { transition: width 0.2s ease; }

/* En modo colapsado: solo íconos */
aside.sidebar[data-colapsado="true"] {
    width: 64px !important;
}
aside.sidebar[data-colapsado="true"] .sidebar-label,
aside.sidebar[data-colapsado="true"] .sidebar-seccion,
aside.sidebar[data-colapsado="true"] .sidebar-badge,
aside.sidebar[data-colapsado="true"] .sidebar-marca-texto {
    display: none !important;
}
aside.sidebar[data-colapsado="true"] .sidebar-item {
    justify-content: center;
    padding: 8px;
}
aside.sidebar[data-colapsado="true"] .sidebar-marca {
    justify-content: center;
}

/* Tooltip nativo al hover en modo colapsado */
aside.sidebar[data-colapsado="true"] .sidebar-item {
    position: relative;
}

/* ============================================================
   TABLAS
   ============================================================ */
table.tabla-data {
    width: 100%;
    font-size: 0.875rem;
}
table.tabla-data thead {
    background-color: #fafafa;
    border-bottom: 1px solid #e4e4e7;
}
.dark table.tabla-data thead {
    background-color: rgba(39, 39, 42, 0.4);
    border-bottom-color: #27272a;
}
table.tabla-data th {
    padding: 10px 16px;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
table.tabla-data td {
    padding: 12px 16px;
    border-bottom: 1px solid #f4f4f5;
}
.dark table.tabla-data td {
    border-bottom-color: rgba(39, 39, 42, 0.6);
}
table.tabla-data tbody tr:hover {
    background-color: #fafafa;
}
.dark table.tabla-data tbody tr:hover {
    background-color: rgba(39, 39, 42, 0.3);
}
table.tabla-data .tabular {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ============================================================
   ANIMACIONES
   ============================================================ */
@keyframes nexo-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nexo-fade-in {
    animation: nexo-fade-in 0.2s ease-out;
}

@keyframes nexo-slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* === TOAST === */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    min-width: 280px;
    max-width: 380px;
    animation: nexo-slide-in 0.2s ease-out;
    background-color: #ffffff;
    font-size: 0.875rem;
}
.dark .toast {
    background-color: #18181b;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.4);
}

/* === SPINNER === */
.spinner {
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-top-color: #7c3aed;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Indicador "Filtrando..." */
.filtro-cargando {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #71717a;
}
