/* ============================================
   FARMAGEST 2026 - SISTEMA DE DISEÑO PREMIUM
   ============================================ */

/* === IMPORTAR FUENTES === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@600;700;800&display=swap');

/* === VARIABLES CSS === */
:root {
    /* Colores Principales */
    --primary-emerald: #10b981;
    --primary-emerald-dark: #059669;
    --primary-emerald-darker: #047857;
    --primary-blue: #3b82f6;
    --primary-blue-dark: #2563eb;

    /* Colores de Acento */
    --accent-gold: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;

    /* Colores Semánticos */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Grises */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-medical: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);

    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.3);

    /* Espaciado */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Transiciones */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Tipografía */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* === MODO OSCURO === */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
}

/* === RESET Y BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

/* === FORM CONTROLS & PLACEHOLDERS (40% de transparencia) === */
::placeholder {
    opacity: 0.3 !important;
}

::-webkit-input-placeholder {
    opacity: 0.3 !important;
}

::-moz-placeholder {
    opacity: 0.3 !important;
}

:-ms-input-placeholder {
    opacity: 0.3 !important;
}

input::placeholder,
textarea::placeholder,
.form-control::placeholder {
    opacity: 0.3 !important;
}

/* === UTILIDADES Y BOTONES EMERALD === */
.btn-emerald {
    background-color: var(--primary-emerald, #10b981) !important;
    border-color: var(--primary-emerald, #10b981) !important;
    color: #ffffff !important;
}
.btn-emerald:hover, .btn-emerald:focus, .btn-emerald:active {
    background-color: var(--primary-emerald-dark, #059669) !important;
    border-color: var(--primary-emerald-dark, #059669) !important;
    color: #ffffff !important;
}
.text-emerald {
    color: #10b981 !important;
}
.text-emerald-900 {
    color: #064e3b !important;
}
.bg-emerald {
    background-color: #10b981 !important;
}
.bg-emerald-light {
    background-color: rgba(16, 185, 129, 0.12) !important;
}

/* === TABLA COMPACTA INVENTARIO === */
.table-inventory {
    font-size: 0.84rem;
}
.table-inventory th {
    font-size: 0.73rem;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.45rem !important;
    white-space: nowrap;
}
.table-inventory td {
    padding: 0.45rem 0.45rem !important;
    vertical-align: middle;
}
.table-inventory .badge {
    font-size: 0.75rem;
    font-weight: 600;
}

/* === SIDEBAR === */
.sidebar {
    background: var(--gradient-medical);
    box-shadow: var(--shadow-xl);
    width: 280px;
    height: calc(100vh - 70px);
    position: fixed;
    left: 0;
    top: 70px;
    z-index: 1000;
    transition: transform var(--transition-base);
    overflow-y: auto;
}

.sidebar-heading {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: white !important;
    padding: var(--spacing-lg);
    margin: 0;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.9);
    padding: var(--spacing-md) var(--spacing-lg);
    margin: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-lg);
    font-weight: 500;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transition: left var(--transition-base);
}

.sidebar .nav-link:hover::before {
    left: 0;
}

.sidebar .nav-link:hover {
    color: white;
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.15);
}

.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.sidebar .nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

/* === MAIN CONTENT === */
main.main-content {
    margin-left: 280px;
    margin-top: 70px;
    min-height: calc(100vh - 70px);
    background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
    padding: var(--spacing-2xl);
}

/* Ajuste para responsive */
@media (max-width: 768px) {
    main.main-content {
        margin-left: 0;
        padding: var(--spacing-md);
    }
}

/* === CARDS === */
.card {
    background: white;
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    overflow: hidden;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-medical);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-bottom: 1px solid var(--gray-200);
    padding: var(--spacing-lg);
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-lg);
}

/* === CARDS DE ESTADÍSTICAS === */
.stat-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-2xl);
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    position: relative;
    overflow: hidden;
}

.stat-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    filter: blur(20px);
    opacity: 0.5;
}

.stat-icon i {
    position: relative;
    z-index: 1;
}

/* Variantes de colores para stats */
.stat-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stat-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.stat-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stat-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.stat-purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* === GLASSMORPHISM === */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* === BOTONES === */
.btn {
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width var(--transition-base), height var(--transition-base);
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-medical);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-success {
    background: var(--gradient-primary);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-warning {
    background: var(--gradient-gold);
    color: white;
}

.btn-info {
    background: var(--gradient-blue);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-emerald);
    color: var(--primary-emerald);
}

.btn-outline:hover {
    background: var(--primary-emerald);
    color: white;
}

/* === BADGES === */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.badge-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.badge-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.badge-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

/* === INPUTS === */
.form-control,
.form-select {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    transition: all var(--transition-base);
    font-family: var(--font-body);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    outline: none;
}

.form-label {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--spacing-sm);
}

/* === TABLAS === */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    color: var(--gray-700);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border: none;
}

.table tbody tr {
    transition: all var(--transition-base);
}

.table tbody tr:hover {
    background: rgba(16, 185, 129, 0.05);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

/* === ANIMACIONES === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.animate-fadeIn {
    animation: fadeIn var(--transition-base) ease-out;
}

.animate-slideInLeft {
    animation: slideInLeft var(--transition-base) ease-out;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* === UTILIDADES === */
.text-gradient {
    background: var(--gradient-medical);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: var(--gradient-medical);
}

.shadow-glow {
    box-shadow: var(--shadow-glow);
}

/* === SCROLLBAR PERSONALIZADA === */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-medical);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-emerald-dark);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        top: 70px;
        height: calc(100vh - 70px);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    main.main-content {
        margin-left: 0;
        padding: var(--spacing-md);
    }

    .stat-card {
        margin-bottom: var(--spacing-md);
    }

    /* Ocultar búsqueda en móvil */
    .navbar .input-group {
        display: none !important;
    }
}

/* Botón hamburguesa para móvil */
.navbar-toggler-custom {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-700);
    cursor: pointer;
}

@media (max-width: 768px) {
    .navbar-toggler-custom {
        display: block;
    }
}

/* === LOADING STATES === */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* === TOOLTIPS === */
.tooltip-custom {
    position: relative;
}

.tooltip-custom::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 0.5rem 1rem;
    background: var(--gray-900);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
}

.tooltip-custom:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* === MODALES === */
.modal-content {
    border: none;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
}

.modal-header {
    background: var(--gradient-medical);
    color: white;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    padding: var(--spacing-lg);
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* === ALERTAS === */
.alert {
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border-left: 4px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--success);
    color: var(--primary-emerald-darker);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--info);
    color: #1e40af;
}

/* === PROGRESS BARS === */
.progress {
    height: 12px;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    overflow: hidden;
}

.progress-bar {
    background: var(--gradient-medical);
    transition: width var(--transition-slow);
}

/* === DROPDOWN === */
.dropdown-menu {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-sm);
}

.dropdown-item {
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary-emerald);
}

/* === CHARTS === */
canvas {
    max-height: 400px;
}

/* === CUSTOM UTILITIES === */
.text-emerald-700 {
    color: var(--primary-emerald-darker) !important;
}

.text-emerald-900 {
    color: #064e3b !important;
}

.bg-emerald {
    background-color: var(--primary-emerald) !important;
}

.bg-emerald-700 {
    background-color: var(--primary-emerald-darker) !important;
}

.border-emerald {
    border-color: var(--primary-emerald) !important;
}

/* === HOVER EFFECTS === */
.hover-lift {
    transition: all var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* === RESPONSIVE UTILITIES === */
@media (max-width: 992px) {
    .stat-card h3 {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

    .stat-card h3 {
        font-size: 1.25rem;
    }
}

/* === ASISTENTE DE REGISTRO CON INTELIGENCIA ARTIFICIAL === */
.ai-assistant-card {
    background: #fdfaff;
    border: 1.5px dashed #c084fc !important;
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}
.ai-assistant-card:hover {
    border-color: #a855f7 !important;
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.12);
}
.text-purple {
    color: #9333ea !important;
}
.text-purple-dark {
    color: #581c87 !important;
}
.bg-purple-subtle {
    background-color: #f3e8ff !important;
    color: #7e22ce !important;
}
.btn-purple-pill {
    background-color: #9333ea !important;
    color: #ffffff !important;
    border-radius: 9999px !important;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem !important;
    transition: all var(--transition-fast);
}
.btn-purple-pill:hover {
    background-color: #7e22ce !important;
    color: #ffffff !important;
    transform: scale(1.02);
}
.btn-purple-gradient {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%) !important;
    border: none !important;
    transition: all var(--transition-fast);
}
.btn-purple-gradient:hover {
    background: linear-gradient(135deg, #9333ea 0%, #6d28d9 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.ai-textarea {
    border: 1px solid #e9d5ff !important;
    background-color: #ffffff !important;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.45;
}
.ai-textarea:focus {
    border-color: #a855f7 !important;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18) !important;
}
.ai-recording-pulse {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: pulse-red 1.2s infinite;
}
@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Efecto de resaltado cuando la IA rellena los campos */
.ai-field-highlight {
    animation: ai-glow 2.5s ease-out;
    border-color: #10b981 !important;
}
@keyframes ai-glow {
    0% { background-color: rgba(16, 185, 129, 0.25); box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }
    50% { background-color: rgba(16, 185, 129, 0.15); box-shadow: 0 0 6px rgba(16, 185, 129, 0.3); }
    100% { background-color: transparent; }
}