/**
 * Custom Styles - CRM 2.0
 * Overrides y estilos personalizados del proyecto
 */

/* ==================================================
   TIPOGRAFÍA GLOBAL - Outfit
   ================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Colores primarios */
    --crm-primary: #3b82f6;
    --crm-primary-dark: #1d4ed8;
    --crm-primary-light: #60a5fa;

    /* Colores secundarios */
    --crm-success: #10b981;
    --crm-warning: #f59e0b;
    --crm-danger: #ef4444;
    --crm-info: #8b5cf6;

    /* Neutros */
    --crm-dark: #0f172a;
    --crm-text: #1e293b;
    --crm-text-muted: #64748b;
    --crm-border: #e2e8f0;
    --crm-bg: #f8fafc;
    --crm-surface: #ffffff;

    /* Sombras */
    --crm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --crm-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --crm-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body,
.page,
.wrapper,
.content,
.menu-title,
.card-title,
h1, h2, h3, h4, h5, h6,
.fs-1, .fs-2, .fs-3, .fs-4, .fs-5, .fs-6,
.fw-bold, .fw-bolder,
.btn,
.form-control,
.form-select,
input, select, textarea {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

/* ==================================================
   ANIMACIONES GLOBALES
   ================================================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* ==================================================
   FORM CONTROLS - Inputs personalizados
   ================================================== */

.form-control {
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid var(--crm-border);
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.form-control:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control:hover:not(:focus) {
    border-color: #cbd5e1;
}

/* Textarea debe mantener su altura natural */
.form-control[rows],
textarea.form-control {
    height: auto;
    min-height: 80px;
}

/* Input con iconos (prepend/append) */
.input-group .form-control {
    border-radius: 0 8px 8px 0;
}

.input-group .input-group-text {
    border-radius: 8px 0 0 8px;
    background-color: #f8fafc;
    border-color: var(--crm-border);
    height: 38px;
}

/* ==================================================
   SELECT - Mejorados
   ================================================== */

.form-select,
select.form-control,
select {
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid var(--crm-border);
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-select:focus,
select.form-control:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Select2 mejorado */
.select2-container--bootstrap5 .select2-selection {
    height: 38px !important;
    border-radius: 8px !important;
    border: 1.5px solid var(--crm-border) !important;
    transition: all 0.2s ease;
}

.select2-container--bootstrap5.select2-container--focus .select2-selection {
    border-color: var(--crm-primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.select2-container--bootstrap5 .select2-selection__rendered {
    line-height: 36px !important;
}

.select2-dropdown {
    border-radius: 8px;
    box-shadow: var(--crm-shadow-lg);
    border: 1px solid var(--crm-border);
}

/* ==================================================
   VALIDACIÓN - Estados visuales
   ================================================== */

.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--crm-success);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2310b981' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--crm-danger);
}

/* ==================================================
   CARDS - Contenedores
   ================================================== */

.card {
    border-radius: 12px;
    box-shadow: var(--crm-shadow-sm);
    border: 1px solid var(--crm-border);
    transition: all 0.25s ease;
    background: var(--crm-surface);
}

.card:hover {
    box-shadow: var(--crm-shadow);
}

.card-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 1.25rem 1.5rem;
    background: transparent;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    border-top: 1px solid #f1f5f9;
    background-color: #fafbfc;
    padding: 1rem 1.5rem;
}

/* Card con efecto hover para acciones */
.card-hoverable {
    cursor: pointer;
}

.card-hoverable:hover {
    transform: translateY(-3px);
    box-shadow: var(--crm-shadow-lg);
}

/* ==================================================
   BUTTONS - Mejorados con iconos prominentes
   ================================================== */

.btn {
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-primary-dark) 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--crm-primary-dark) 0%, #1e40af 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, var(--crm-success) 0%, #059669 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, var(--crm-danger) 0%, #dc2626 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, var(--crm-warning) 0%, #d97706 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
    color: white;
}

.btn-warning:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    color: white;
}

.btn-light {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--crm-text);
}

.btn-light:hover {
    background: #e2e8f0;
    color: var(--crm-text);
}

/* Botones con iconos - VISIBLES */
.btn i,
.btn .bi {
    font-size: 1.15em;
    line-height: 1;
}

.btn-sm i,
.btn-sm .bi {
    font-size: 1.1em;
}

.btn-lg i,
.btn-lg .bi {
    font-size: 1.25em;
}

/* Light buttons - iconos con color */
.btn-light i,
.btn-light .bi,
.btn-light-primary i,
.btn-light-primary .bi {
    color: var(--crm-primary);
}

.btn-light-success i,
.btn-light-success .bi {
    color: var(--crm-success);
}

.btn-light-danger i,
.btn-light-danger .bi {
    color: var(--crm-danger);
}

.btn-light-warning i,
.btn-light-warning .bi {
    color: #b45309;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.btn-icon i,
.btn-icon .bi {
    font-size: 1.2em;
}

/* ==================================================
   TABLES - DataTables mejoradas
   ================================================== */

.table {
    border-radius: 8px;
    overflow: hidden;
}

.table thead th {
    background-color: #f8fafc;
    border-bottom: 2px solid var(--crm-border);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--crm-text-muted);
    padding: 1rem 0.75rem;
}

.table tbody tr {
    transition: all 0.15s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

.table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.table tbody tr:nth-child(even):hover {
    background-color: #f1f5f9;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.85rem 0.75rem;
    color: var(--crm-text);
}

/* Acciones en tablas */
.table .btn-group .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
}

/* ==================================================
   BADGES - Estados y etiquetas
   ================================================== */

.badge {
    border-radius: 6px;
    font-weight: 600;
    padding: 0.4em 0.7em;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-primary,
.badge.bg-primary {
    background: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-primary-dark) 100%) !important;
}

.badge-success,
.badge.bg-success {
    background: linear-gradient(135deg, var(--crm-success) 0%, #059669 100%) !important;
}

.badge-danger,
.badge.bg-danger {
    background: linear-gradient(135deg, var(--crm-danger) 0%, #dc2626 100%) !important;
}

.badge-warning,
.badge.bg-warning {
    background: linear-gradient(135deg, var(--crm-warning) 0%, #d97706 100%) !important;
    color: white !important;
}

.badge-info,
.badge.bg-info {
    background: linear-gradient(135deg, var(--crm-info) 0%, #7c3aed 100%) !important;
}

.badge-secondary,
.badge.bg-secondary {
    background: #94a3b8 !important;
}

/* Light badges */
.badge-light-primary {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--crm-primary) !important;
}

.badge-light-success {
    background: rgba(16, 185, 129, 0.1) !important;
    color: var(--crm-success) !important;
}

.badge-light-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--crm-danger) !important;
}

.badge-light-warning {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #b45309 !important;
}

.badge-light-info {
    background: rgba(139, 92, 246, 0.1) !important;
    color: var(--crm-info) !important;
}

/* ==================================================
   MODALS - Diálogos mejorados
   ================================================== */

.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 1rem 1.5rem;
}

/* ==================================================
   ALERTS - Notificaciones
   ================================================== */

.alert {
    border-radius: 10px;
    border: none;
    border-left: 4px solid;
    padding: 1rem 1.25rem;
    font-weight: 500;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.08);
    border-left-color: var(--crm-success);
    color: #065f46;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.08);
    border-left-color: var(--crm-danger);
    color: #991b1b;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.08);
    border-left-color: var(--crm-warning);
    color: #92400e;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.08);
    border-left-color: var(--crm-primary);
    color: #1e40af;
}

/* ==================================================
   FLOATING LABELS - Labels flotantes
   ================================================== */

.form-floating > .form-control {
    height: calc(3.5rem + 2px);
    padding: 1rem 0.75rem;
}

.form-floating > label {
    padding: 1rem 0.75rem;
    color: var(--crm-text-muted);
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* ==================================================
   UTILITIES - Utilidades generales
   ================================================== */

/* Cursor pointer para elementos interactivos */
.cursor-pointer {
    cursor: pointer;
}

/* Transiciones suaves */
.transition {
    transition: all 0.2s ease;
}

/* Sombras personalizadas */
.shadow-sm {
    box-shadow: var(--crm-shadow-sm) !important;
}

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

.shadow-lg {
    box-shadow: var(--crm-shadow-lg) !important;
}

/* Separador visual */
.separator {
    height: 1px;
    background-color: #f1f5f9;
    margin: 1.5rem 0;
}

/* Text colors */
.text-primary {
    color: var(--crm-primary) !important;
}

.text-muted {
    color: var(--crm-text-muted) !important;
}

/* ==================================================
   SIDEBAR - Menú activo
   ================================================== */

/* Estilo para menú activo en sidebar oscuro */
.aside-dark .menu .menu-item .menu-link.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.08) 100%);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.aside-dark .menu .menu-item .menu-link.active .menu-icon,
.aside-dark .menu .menu-item .menu-link.active .menu-icon i {
    color: var(--crm-primary-light) !important;
}

.aside-dark .menu .menu-item .menu-link.active .menu-title {
    color: #ffffff !important;
    font-weight: 600;
}

.aside-dark .menu .menu-item .menu-link.active .menu-bullet .bullet {
    background-color: var(--crm-primary-light) !important;
}

/* Barra lateral indicadora en menú activo */
.aside-dark .menu .menu-item .menu-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, var(--crm-primary) 0%, var(--crm-primary-light) 100%);
    border-radius: 0 3px 3px 0;
}

/* Hover en menú */
.aside-dark .menu .menu-item .menu-link:hover:not(.active) {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

/* Asegurar posición relativa para el pseudo-elemento */
.aside-dark .menu .menu-item .menu-link {
    position: relative;
    transition: all 0.2s ease;
}

/* ==================================================
   RESPONSIVE - Ajustes móviles
   ================================================== */

@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }
}

/* ==================================================
   OVERRIDES ESPECÍFICOS
   ================================================== */

.input-group .input-group-text {
    height: 38px;
}

.card .card-header {
    min-height: 50px;
}

.btn-group-sm > .btn, .btn-sm {
    --bs-btn-font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
}

#leadDetailOffcanvas {
    width: 40% !important;
}

.badge.badge-circle, .badge.badge-square.badge-circle {
    line-height: 2rem !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    padding: 0px !important;
}

#kt_header_nav h5 {
    color: #fff !important;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Page loading animation */
.page-loading {
    animation: fadeIn 0.3s ease-out;
}

/* Smooth scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==================================================
   PRO INTEGRATION HELPERS
   ================================================== */

/* Pro button sizes for existing buttons */
.btn.pro-btn-sm {
    padding: 6px 14px;
    font-size: 0.825rem;
}

/* Smooth page transitions */
.content {
    animation: fadeIn 0.25s ease-out;
}

/* Enhanced focus states */
.form-control:focus,
.form-select:focus,
.btn:focus {
    outline: none;
}

/* Better link transitions */
a {
    transition: color 0.2s ease;
}

/* Card entrance animation on page load */
.card {
    animation: fadeInUp 0.4s ease-out;
    animation-fill-mode: both;
}

.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 50ms; }
.card:nth-child(3) { animation-delay: 100ms; }
.card:nth-child(4) { animation-delay: 150ms; }

/* Pro card overrides for consistency */
.pro-card .card-body {
    padding: 1.5rem;
}

/* Empty state improvements */
.alert-info {
    border-left: 4px solid var(--crm-primary);
}

/* Improved table row hover */
.table tbody tr {
    cursor: default;
}

.table tbody tr.clickable-row {
    cursor: pointer;
}

/* Avatar group spacing */
.symbol-group .symbol {
    transition: transform 0.2s ease;
}

.symbol-group .symbol:hover {
    transform: translateY(-2px);
    z-index: 1;
}
