/* ============================================
   CRM MACINDAR - ESTILOS PRINCIPALES
   Paleta sobria y profesional
   ============================================ */

/* ============================================
   RESET Y VARIABLES CSS
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


:root {
    /* Colores principales - Paleta sobria y profesional */
    --primary-color: #1a365d;
    --primary-dark: #0f2744;
    --primary-light: #2c5282;
    --secondary-color: #2d3748;
    --secondary-light: #4a5568;

    /* Estados */
    --success-color: #2f855a;
    --error-color: #c53030;
    --warning-color: #d69e2e;
    --info-color: #2c5282;

    /* Fondos */
    --bg-color: #f7fafc;
    --bg-white: #ffffff;
    --sidebar-bg: #1a202c;
    --sidebar-hover: #2d3748;

    /* Texto */
    --text-color: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --text-white: #ffffff;

    /* Bordes y separadores */
    --border-color: #e2e8f0;
    --border-light: #edf2f7;

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

    /* Espaciado */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Bordes redondeados */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    /* Transiciones */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 300ms ease-in-out;
}

/* ============================================
   ESTILOS GLOBALES
   ============================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevenir que Bootstrap rompa el layout */
body > .container,
body > .container-fluid {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    max-width: none;
}

.dashboard-wrapper ~ .container,
.dashboard-wrapper .container {
    max-width: none !important;
}

/* ============================================
   PÁGINA DE LOGIN
   ============================================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    /* background movido a body cuando hay imagen, o se mantiene por defecto */
    background: transparent;
    padding: 20px;
    position: relative;
    overflow: hidden;
    z-index: 2;
}

/* Fallback para cuando NO hay configuración personalizada */
.login-container.default-bg {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
}

/* Pseudo-elemento deshabilitado para permitir particles */
/* .login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    animation: pulse 15s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.3; }
} */

.login-box {
    background: var(--bg-white);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-light);
    font-size: 0.9375rem;
}

.login-form {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    transition: all var(--transition-base);
    background-color: var(--bg-white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

/* ============================================
   BOTONES
   ============================================ */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-white);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.2);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-white);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--secondary-light);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--text-white);
}

.btn-success:hover:not(:disabled) {
    background-color: #276749;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: var(--text-white);
}

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

.btn-block {
    width: 100%;
    display: flex;
}

.login-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.demo-info {
    background-color: #edf2f7;
    padding: 1rem;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-color);
    font-size: 0.8125rem;
    color: var(--text-color);
}

.demo-info strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

/* ============================================
   ALERTAS
   ============================================ */

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert i {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-success {
    background-color: #f0fff4;
    color: #22543d;
    border-left: 3px solid var(--success-color);
}

.alert-error,
.alert-danger {
    background-color: #fff5f5;
    color: #742a2a;
    border-left: 3px solid var(--error-color);
}

.alert-warning {
    background-color: #fffaf0;
    color: #744210;
    border-left: 3px solid var(--warning-color);
}

.alert-info {
    background-color: #ebf8ff;
    color: #2c5282;
    border-left: 3px solid var(--info-color);
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-white);
}

.sidebar-nav {
    flex: 1;
    padding: 1.25rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
    padding: 0 0.75rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all var(--transition-base);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
}

.sidebar-nav a:hover {
    background-color: var(--sidebar-hover);
    color: var(--text-white);
    transform: translateX(2px);
}

.sidebar-nav li.active a {
    background-color: var(--primary-color);
    color: var(--text-white);
    box-shadow: 0 2px 8px rgba(26, 54, 93, 0.3);
}

.sidebar-nav .icon {
    margin-right: 0.75rem;
    font-size: 1.125rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.9;
}

.sidebar-footer {
    padding: 1.25rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    font-weight: 500;
}

.logout-btn:hover {
    background-color: var(--error-color);
    color: var(--text-white);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
    min-height: 100vh;
}

.topbar {
    background: var(--bg-white);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-right {
    display: flex;
    align-items: center;
}

.topbar h1 {
    font-size: 1.5rem;
    color: var(--text-color);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 0.5rem 1rem;
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
}

.user-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9375rem;
}

.user-role {
    font-size: 0.8125rem;
    color: var(--text-light);
}

.content {
    padding: 2rem;
    flex: 1;
    background-color: var(--bg-color);
}

/* ============================================
   CARDS Y GRID
   ============================================ */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    /* padding: 1.5rem; */
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    border: 1px solid var(--border-color);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 600;
}

.card-icon {
    font-size: 1.875rem;
    opacity: 0.7;
}

.card-body {
    padding: 0;
}

.card-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* ============================================
   WELCOME SECTION
   ============================================ */

.welcome-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.welcome-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.welcome-section p {
    color: var(--text-color);
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.info-box {
    background-color: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    border: 1px solid var(--border-light);
}

.info-box h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.125rem;
    font-weight: 600;
}

.info-box ul {
    list-style: none;
}

.info-box li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.info-box li:last-child {
    border-bottom: none;
}

.info-box strong {
    color: var(--text-light);
    font-weight: 500;
}

/* ============================================
   TABLAS
   ============================================ */

.table-responsive {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    background-color: var(--bg-white);
}

.table thead th {
    border-bottom: 2px solid var(--border-color);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background-color: var(--bg-color);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
}

.badge-success {
    /* background-color: #f0fff4; */
    background-color: var(--success-color);
}

.badge-danger {
    /* background-color: #fff5f5; */
    background-color: var(--error-color);
}

.badge-warning {
    /* background-color: #fffaf0; */
    background-color: var(--warning-color);
}

.badge-info {
    /* background-color: #ebf8ff; */
    background-color: var(--info-color);
}

.badge-secondary {
    /* background-color: #edf2f7; */
    background-color: var(--text-light);
}

/* ============================================
   UTILIDADES
   ============================================ */

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

.text-small {
    font-size: 0.875rem;
}

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

/* ============================================
   BOTÓN HAMBURGUESA
   ============================================ */

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    color: var(--text-color);
    font-size: 1.5rem;
    transition: all var(--transition-fast);
}

.hamburger-btn:hover {
    color: var(--primary-color);
}

.hamburger-btn:active {
    transform: scale(0.95);
}

/* Overlay para cerrar el sidebar en móvil */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    /* Mostrar botón hamburguesa */
    .hamburger-btn {
        display: block;
    }

    /* Ocultar sidebar por defecto */
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        z-index: 1000;
    }

    /* Mostrar sidebar cuando está activo */
    .sidebar.active {
        transform: translateX(0);
    }

    /* Ajustar contenido principal */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Ajustar topbar */
    .topbar {
        padding: 1rem;
    }

    .topbar-left {
        display: flex;
        align-items: center;
    }

    .topbar h1 {
        font-size: 1.25rem;
    }

    /* Ajustar user info en móvil */
    .user-info {
        padding: 0.25rem 0.5rem;
    }

    .user-name {
        font-size: 0.875rem;
    }

    .user-role {
        font-size: 0.75rem;
    }

    /* Grid de cards en una columna */
    .cards-grid {
        grid-template-columns: 1fr;
    }

    /* Reducir padding del contenido */
    .content {
        padding: 1rem;
    }

    /* Ajustar tablas para scroll horizontal */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .card{
        margin-top: 5px;
    }
}

@media (max-width: 480px) {
    .topbar {
        flex-wrap: wrap;
    }

    .topbar-right {
        width: 100%;
        margin-top: 0.5rem;
    }

    .user-info {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 2rem 1.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }
}

/* ============================================
   SCROLLBAR PERSONALIZADO (Sidebar)
   ============================================ */

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   HEADER USER MENU - Reorganizado
   ============================================ */

.user-menu-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    position: relative;
    margin: 0;
    padding: 0;
    background-color: transparent;
}

.user-info-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-info-btn:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e0;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-info .dropdown-menu {
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.user-info .dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    transition: all var(--transition-fast);
}

.user-info .dropdown-item:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

/* ============================================
   AVATAR DE USUARIO
   ============================================ */

.user-avatar-container {
    width: 40px;
    height: 40px;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-avatar-initials {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .user-menu-container {
        gap: 0.5rem;
    }

    .user-info-btn {
        padding: 0.4rem 0.8rem;
    }

    .user-name {
        font-size: 0.85rem;
    }

    .user-role {
        font-size: 0.75rem;
    }

    
    .alert-float {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }

    .alert-float .btn-close {
        margin-top: 2px;
    }

}

.alert-float {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-right: 2.5rem; /* espacio para el botón */
}

/* Anular estilos default de Bootstrap */
.alert-float .btn-close {
    position: static;
    margin-left: auto;
    flex-shrink: 0;
}