/**
 * SafeVitia - Global Styles
 * Estilos globales complementarios a Tailwind CSS
 */

/* === Reset y Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Evitar zoom al enfocar en móvil (iOS) y que inputs se lean bien */
input, textarea, select {
    font-size: 16px;
}
@media screen and (max-width: 768px) {
    input, textarea, select {
        font-size: max(16px, 1em);
    }
}

/* === Animaciones === */
@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-right {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slide-in-left {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Clases de animación */
.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

.animate-fade-in-up {
    animation: fade-in-up 0.5s ease-out;
}

.animate-fade-in-down {
    animation: fade-in-down 0.5s ease-out;
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease-out;
}

.animate-slide-in-left {
    animation: slide-in-left 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* === Scrollbar Custom === */
::-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;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Para Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dark * {
    scrollbar-color: #475569 transparent;
}

/* Scrollbar hide utility */
.scrollbar-hide {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Custom scrollbar (vertical y horizontal) */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #475569;
}

/* Barra horizontal visible en timeline */
.timeline-h-scroll {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dark .timeline-h-scroll {
    scrollbar-color: #475569 transparent;
}

/* Barra de desplazamiento del timeline: flotante, siempre visible al hacer scroll */
.timeline-scroll-bar-floating {
    position: sticky;
    top: 0;
}
/* Debajo del header de la app (h-16 = 4rem) cuando el scroll es del documento */
body:has(header.sticky) .timeline-scroll-bar-floating {
    top: 4rem;
}

/* === Transiciones Globales === */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* === Inputs y Forms === */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="month"],
input[type="search"],
textarea,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* === Focus States === */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* === Buttons === */
button {
    cursor: pointer;
    user-select: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* === Cards y Containers === */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}

.dark .card {
    background: #1e293b;
    box-shadow: none;
    border: 1px solid #334155;
}

/* === Gradients === */
.gradient-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.gradient-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.gradient-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.gradient-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.gradient-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* === Backdrop Blur === */
.backdrop-blur {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* === Glass Effect === */
.glass {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

/* === Shadows === */
.shadow-soft {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.shadow-medium {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.shadow-hard {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* === Hover Effects === */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.hover-scale {
    transition: transform 0.2s ease;
}

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

/* === Loading States === */
.skeleton {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
}

/* === Utility Classes === */
.text-balance {
    text-wrap: balance;
}

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === Print Styles === */
@media print {
    body {
        background: white;
    }

    .no-print {
        display: none !important;
    }

    * {
        color-adjust: exact;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* === Responsive Typography === */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }
}

/* === Custom Components === */

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-primary {
    background: #ede9fe;
    color: #6366f1;
}

.dark .badge-primary {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.badge-success {
    background: #d1fae5;
    color: #059669;
}

.dark .badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

.dark .badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.dark .badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

/* Divider */
.divider {
    height: 1px;
    background: #e5e7eb;
    margin: 1rem 0;
}

.dark .divider {
    background: #334155;
}

/* Avatar */
.avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
}

/* === Z-Index Layers === */
.z-base {
    z-index: 0;
}

.z-dropdown {
    z-index: 1000;
}

.z-sticky {
    z-index: 1020;
}

.z-fixed {
    z-index: 1030;
}

.z-modal-backdrop {
    z-index: 1040;
}

.z-modal {
    z-index: 1050;
}

.z-popover {
    z-index: 1060;
}

.z-tooltip {
    z-index: 1070;
}

/* === Accessibility === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* === Dark Mode Adjustments === */
.dark {
    color-scheme: dark;
}

.dark img {
    opacity: 0.9;
}

/* === Selection === */
::selection {
    background: #6366f1;
    color: white;
}

.dark ::selection {
    background: #8b5cf6;
    color: white;
}

/* === SortableJS: feedback visual al arrastrar (fluido e intuitivo) === */
.sortable-ghost {
    opacity: 0.45;
    background: rgb(224 231 255 / 0.6) !important;
    border: 2px dashed rgb(99 102 241) !important;
    border-radius: 0.5rem;
    transition: none !important;
    pointer-events: none;
}
.dark .sortable-ghost {
    background: rgb(67 56 202 / 0.4) !important;
    border-color: rgb(129 140 248) !important;
}
/* Tarjeta que estás agarrando: se eleva y se ve clara */
.sortable-chosen {
    opacity: 0.85;
    transition: none !important;
    pointer-events: none;
}
.dark .sortable-chosen {
    box-shadow: 0 0 0 2px rgb(129 140 248 / 0.4);
}
/* Clon que sigue al cursor: muy visible y fluido */
.sortable-drag {
    opacity: 1 !important;
    box-shadow: 0 20px 40px -10px rgb(0 0 0 / 0.3);
    transform: scale(1.02) rotate(-0.5deg);
    cursor: grabbing !important;
    transition: none !important;
    will-change: transform;
    pointer-events: none;
}
.dark .sortable-drag {
    box-shadow: 0 20px 40px -10px rgb(0 0 0 / 0.6);
}
/* Transición suave al soltar para que la tarjeta “encaje” en su nueva posición */
.order-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Eliminación: colapso + fade para que el resto se recorra suavemente */
.order-card-removing {
    transition: height 0.25s ease-out, opacity 0.2s ease-out, margin 0.25s ease-out, padding 0.25s ease-out !important;
    overflow: hidden !important;
}