/* ============================================
    BASE.CSS - Variables globales y layout
    ============================================ */

/* Fuente del sistema (sin Google Fonts) */

/* ============================================
   VARIABLES GLOBALES
   ============================================ */
:root {
    /* Colores por módulo */
    --color-ventas: #0d6efd;
    --color-ventas-dark: #0a58ca;
    --color-compras: #198754;
    --color-compras-dark: #146c43;
    --color-finanzas: #ffc107;
    --color-finanzas-dark: #ff9800;
    --color-stock: #6f42c1;
    --color-stock-dark: #5a32a3;

    /* Colores semánticos */
    --color-danger: #dc3545;
    --color-danger-dark: #c82333;
    --color-success: #198754;
    --color-success-dark: #146c43;
    --color-info: #3498db;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #fde68a;
    --color-warning-text: #92400e;
    --color-warning-text-dark: #78350f;

    /* Grises */
    --color-gray-50: #f7f9fb;
    --color-gray-100: #f8f9fa;
    --color-gray-200: #e9ecef;
    --color-gray-300: #dee2e6;
    --color-gray-400: #ced4da;
    --color-gray-500: #6c757d;
    --color-gray-600: #495057;
    --color-gray-700: #495057;
    --color-gray-800: #343a40;
    --color-gray-900: #212529;

    /* Tipografia */
    --font-family-base: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-family-mono: 'Courier New', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.85rem;
    --font-size-base: 0.95rem;
    --font-size-lg: 1.1rem;
    --font-size-xl: 1.25rem;
    --line-height-tight: 1.3;
    --line-height-base: 1.5;
    --line-height-relaxed: 1.65;

    /* Border radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-hover: 0 6px 16px rgba(0,0,0,0.1);
    --shadow-focus: 0 0 0 3px rgba(13, 110, 253, 0.2);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
}

/* ============================================
   LAYOUT GLOBAL
   ============================================ */
html {
    scroll-behavior: smooth;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--color-gray-900);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
}


/* ============================================
   TIPOGRAFIA GLOBAL
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight);
    font-weight: 600;
    color: var(--color-gray-900);
}

small, .text-sm {
    font-size: var(--font-size-sm);
}

/* ============================================
   BOTONES GLOBALES - Estados mejorados
   ============================================ */
.btn {
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: auto;
}

.btn-primary {
    box-shadow: 0 1px 3px rgba(13, 110, 253, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35);
    transform: translateY(-1px);
}

.btn-danger {
    box-shadow: 0 1px 3px rgba(220, 53, 69, 0.3);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.35);
}

.btn-outline-secondary:hover:not(:disabled) {
    background-color: var(--color-gray-100);
    border-color: var(--color-gray-400);
    color: var(--color-gray-800);
}

.btn-outline-primary:hover:not(:disabled) {
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

/* ============================================
   FOCUS VISIBLE - Accesibilidad
   ============================================ */
:focus-visible {
    outline: 2px solid var(--color-ventas);
    outline-offset: 2px;
}

.btn:focus-visible {
    box-shadow: var(--shadow-focus);
    outline: none;
}

.form-control:focus {
    border-color: var(--color-ventas);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.btn-check:focus-visible + .btn {
    box-shadow: var(--shadow-focus);
}

/* ============================================
   FORM CONTROLS - Inputs mejorados
   ============================================ */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-label {
    font-size: var(--font-size-sm);
    margin-bottom: 6px;
}

/* ============================================
   SPINNERS - Animacion mas suave
   ============================================ */
.spinner-border {
    animation: spinner-border 0.8s linear infinite;
}

/* ============================================
   ALERTS - Transiciones
   ============================================ */
.alert {
    border-radius: var(--radius-md);
    animation: fadeInStep 0.25s ease-out;
}

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

/* ============================================
   MODALES - Entrada mas fluida
   ============================================ */
.modal.fade .modal-dialog {
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

.modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    overflow: hidden;
}

.modal-footer {
    border-top: 1px solid var(--color-gray-200);
    background: var(--color-gray-50);
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    height: 60px;
}

.navbar-brand {
    flex: 1;
    min-width: 0;
}

.navbar-brand p {
    margin: 0;
    line-height: 1.2;
}

.logout-button {
    white-space: nowrap;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    font-size: 1rem;
}

footer .container {
    min-height: auto;
}

footer img {
    filter: brightness(1.1);
}

/* ============================================
   MODULE TABS
   ============================================ */
.module-tab {
    padding: 12px 8px;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    cursor: pointer;
}

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

.module-tab.active {
    font-weight: bold;
    box-shadow: var(--shadow-lg);
}

.module-tab.active i {
    color: inherit;
}

.module-tab i {
    font-size: 1.5rem;
}

/* Estados por módulo (habilitado) */
.module-ventas-enabled {
    border-color: var(--color-ventas) !important;
    color: var(--color-ventas) !important;
    background: rgba(13,110,253,0.04);
    font-weight: 600;
}

.module-compras-enabled {
    border-color: var(--color-compras) !important;
    color: var(--color-compras) !important;
    background: rgba(25,135,84,0.04);
    font-weight: 600;
}

.module-finanzas-enabled {
    border-color: var(--color-finanzas) !important;
    color: #856404 !important;
    background: rgba(255,193,7,0.04);
    font-weight: 600;
}

.module-stock-enabled {
    border-color: var(--color-stock) !important;
    color: var(--color-stock) !important;
    background: rgba(111,66,193,0.04);
    font-weight: 600;
}

/* Estados por módulo (activo) */
.module-tab.active.module-ventas-enabled {
    background-color: var(--color-ventas) !important;
    color: white !important;
    border-color: var(--color-ventas) !important;
}

.module-tab.active.module-compras-enabled {
    background-color: var(--color-compras) !important;
    color: white !important;
    border-color: var(--color-compras) !important;
}

.module-tab.active.module-finanzas-enabled {
    background-color: var(--color-finanzas) !important;
    color: #000 !important;
    border-color: var(--color-finanzas) !important;
}

.module-tab.active.module-stock-enabled {
    background-color: var(--color-stock) !important;
    color: white !important;
    border-color: var(--color-stock) !important;
}

/* ============================================
   HOVER CARDS
   ============================================ */
.hover-card {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hover-card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   MODAL Z-INDEX (para modales apilados)
   ============================================ */
#modalAlerta {
    z-index: 1070 !important;
}

.modal-backdrop.modal-alerta-backdrop {
    z-index: 1065 !important;
}

#modalErrorBloqueante {
    z-index: 1080 !important;
}

.modal-backdrop.modal-error-backdrop {
    z-index: 1075 !important;
}

/* ============================================
   RESPONSIVE - MÓVILES
   ============================================ */
@media (max-width: 768px) {
    .navbar {
        height: 50px;
        padding: 5px 10px;
    }

    .navbar-brand {
        font-size: 0.85rem;
    }

    .logout-button {
        padding: 6px 12px !important;
        font-size: 0.85rem;
    }

    .logout-button span {
        display: none !important;
    }

    .logout-button i {
        margin: 0 !important;
    }

    footer {
        padding: 8px 0;
        font-size: 0.75rem;
    }

    footer .container {
        gap: 12px !important;
        padding: 0 10px;
    }

    footer img[alt="Isologo Cormons"] {
        width: 30px !important;
        height: 30px !important;
        margin-right: 5px !important;
    }

    footer img[alt="Logo WhatsApp"] {
        width: 18px !important;
        height: 18px !important;
        margin-right: 4px !important;
    }

    .module-tab i {
        font-size: 1.2rem;
    }

    .module-tab small {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 0.75rem;
    }

    footer {
        padding: 6px 0;
        font-size: 0.7rem;
    }

    footer .container {
        gap: 8px !important;
    }

    footer img[alt="Isologo Cormons"] {
        width: 24px !important;
        height: 24px !important;
    }

    footer img[alt="Logo WhatsApp"] {
        width: 16px !important;
        height: 16px !important;
    }
}

@media (max-width: 324px) {
    .navbar {
        height: 45px;
    }

    .navbar-brand {
        font-size: 0.65rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .logout-button {
        padding: 4px 8px !important;
        font-size: 0.75rem;
        min-width: 32px;
    }

    .logout-button i {
        font-size: 0.9rem;
    }
}
