/* ═══════════════════════════════════════════════════════════
   MERCADO ABASTOS — Sistema de Gestión
   Tema Premium Moderno (Glassmorphism & Vibrant)
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;       /* Indigo vibrant */
    --primary-dark: #3730a3;
    --primary-darker: #312e81;
    --primary-light: #e0e7ff;
    --primary-50: #f5f3ff;
    --secondary: #0f172a;     /* Slate */
    --background: #f8fafc;
    --surface: rgba(255, 255, 255, 0.85); /* Glass surface */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: rgba(226, 232, 240, 0.6);
    --border-light: rgba(241, 245, 249, 0.5);
    
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #f43f5e;       /* Rose vibrant */
    --danger-light: #ffe4e6;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #0ea5e9;
    --info-light: #e0f2fe;
    
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
    --shadow-md: 0 8px 20px -4px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 15px 30px -5px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.15);
    --shadow-primary: 0 8px 20px 0 rgba(79, 70, 229, 0.35);

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-w: 270px;
    --topbar-h: 72px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    /* Modern Mesh Gradient Background */
    background: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    background-color: #f4f6f8; /* fallback light */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(79, 70, 229, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(244, 63, 94, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.05) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ── Animaciones ──────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}
.animate-fade  { animation: fadeIn .4s ease-out; }
.animate-scale { animation: fadeInScale .3s ease-out; }

/* ═══════════════════════════════════════════════════════════
   AUTH / LOGIN
   ═══════════════════════════════════════════════════════════ */
.auth-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #0c4a6e 40%, #0ea5e9 100%);
    position: relative;
    overflow: hidden;
}
.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14,165,233,.15) 0%, transparent 70%);
    top: -200px; right: -100px;
}
.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14,165,233,.1) 0%, transparent 70%);
    bottom: -100px; left: -50px;
}
.auth-card {
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(20px);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255,255,255,.2);
    animation: fadeInScale .5s ease-out;
    position: relative;
    z-index: 2;
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: .75rem;
    display: inline-block;
    background: var(--primary-light);
    width: 72px; height: 72px;
    border-radius: 50%;
    line-height: 72px;
}
.auth-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--secondary); }
.auth-header p  { color: var(--text-muted); font-size: .875rem; margin-top: .4rem; }

/* ═══════════════════════════════════════════════════════════
   FORMULARIOS
   ═══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: .5rem;
    color: var(--gray-700);
    font-size: .85rem;
}
.form-control {
    width: 100%;
    padding: .75rem 1rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    transition: var(--transition);
    background-color: rgba(255,255,255,0.8);
    color: var(--text-main);
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15), inset 0 1px 2px rgba(0,0,0,0.02);
    background-color: #fff;
}
select.form-control { cursor: pointer; appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Grupo de inputs inline */
.form-row {
    display: flex;
    gap: 1rem;
}
.form-row .form-group { flex: 1; }

/* ═══════════════════════════════════════════════════════════
   BOTONES
   ═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: .65rem 1.4rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: .88rem;
    font-family: 'Outfit', sans-serif;
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: .02em;
}
.btn:active { transform: scale(.95); }
.btn i { font-size: .95rem; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}
.btn-success:hover { box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); transform: translateY(-2px); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #e11d48 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.2);
}
.btn-danger:hover { box-shadow: 0 6px 20px rgba(244, 63, 94, 0.4); transform: translateY(-2px); }

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-800);
    border: 1px solid rgba(0,0,0,0.05);
}
.btn-secondary:hover { background: var(--gray-200); transform: translateY(-2px); }

.btn-sm { padding: .45rem .85rem; font-size: .8rem; border-radius: 50px; }
.btn-lg { padding: .85rem 1.75rem; font-size: 1rem; border-radius: 50px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 50%; }

/* ═══════════════════════════════════════════════════════════
   ALERTAS
   ═══════════════════════════════════════════════════════════ */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    animation: slideDown .3s ease-out;
}
.alert i { font-size: 1rem; flex-shrink: 0; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light);    color: #3730a3; border: 1px solid #c7d2fe; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(170deg, #0f172a 0%, #1e293b 80%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header i { font-size: 1.4rem; color: var(--primary); }
.sidebar-header h2 { font-size: 1.05rem; color: #fff; font-weight: 700; letter-spacing: -.01em; }
.sidebar-menu {
    list-style: none;
    padding: .75rem .75rem;
    flex: 1;
}
.sidebar-menu li { margin-bottom: 2px; }
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1rem;
    color: var(--gray-400);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-weight: 500;
    font-size: .85rem;
}
.sidebar-menu a:hover {
    background: rgba(255,255,255,.06);
    color: #e2e8f0;
}
.sidebar-menu a.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: var(--shadow-primary);
}
.sidebar-menu a i { width: 20px; text-align: center; font-size: .95rem; }

.sidebar-section {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--gray-500);
    padding: 1rem 1rem .5rem;
}

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT & TOPBAR
   ═══════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}
.topbar-title { font-size: 1.15rem; font-weight: 700; color: var(--secondary); font-family: 'Outfit', sans-serif; letter-spacing: -0.01em;}
.topbar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.topbar-user span {
    font-weight: 600;
    color: var(--gray-700);
    font-size: .88rem;
}

.page-content {
    padding: 1.75rem;
    flex: 1;
    animation: fadeIn .3s ease-out;
}

/* ═══════════════════════════════════════════════════════════
   PAGE HEADER (encabezado de módulo)
   ═══════════════════════════════════════════════════════════ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--secondary);
}
.page-header-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
}

/* ═══════════════════════════════════════════════════════════
   CARDS / PANELES
   ═══════════════════════════════════════════════════════════ */
.card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.04);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover {
    box-shadow: 0 10px 40px rgba(31, 38, 135, 0.08);
}
.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.4);
}
.card-header h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary);
    font-family: 'Outfit', sans-serif;
}
.card-body { padding: 1.5rem; }
.card-body.no-padding { padding: 0; }

/* ═══════════════════════════════════════════════════════════
   STATS GRID (Dashboard)
   ═══════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: var(--transition-slow);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; right: 0; width: 150px; height: 150px;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%);
    opacity: 0; transition: var(--transition-slow); transform: translate(50%, -50%);
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(79, 70, 229, 0.1);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.5), 0 4px 10px rgba(0,0,0,0.05);
}
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: var(--info-light);    color: var(--info); }
.stat-info h3 { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.stat-info p  { font-size: 1.4rem; font-weight: 700; color: var(--secondary); margin-top: .15rem; }

/* ═══════════════════════════════════════════════════════════
   TABLAS
   ═══════════════════════════════════════════════════════════ */
.table-container {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}
.table-container table { width: 100%; border-collapse: collapse; }
.table-container thead th {
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.4);
    color: var(--secondary);
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-family: 'Outfit', sans-serif;
    text-align: left;
    border-bottom: 2px solid rgba(0,0,0,0.05);
    white-space: nowrap;
}
.table-container tbody td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    font-size: .88rem;
    vertical-align: middle;
    transition: var(--transition);
}
.table-container tbody tr { transition: var(--transition); }
.table-container tbody tr:last-child td { border-bottom: none; }
.table-container tbody tr:hover td { background: rgba(255, 255, 255, 0.6); }
.table-container .empty-row td {
    text-align: center;
    color: var(--gray-500);
    padding: 3rem 1rem;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   BADGES / STATUS
   ═══════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .75rem;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: .02em;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #d97706; }
.badge-info    { background: var(--info-light);    color: var(--primary-dark); }
.badge-primary { background: var(--primary-50); color: var(--primary); }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); border: 1px solid rgba(0,0,0,0.05); }

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.2);
    width: 100%;
    max-width: 480px;
    animation: fadeInScale .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-box::-webkit-scrollbar { width: 6px; }
.modal-box::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }
.modal-header {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.5);
}
.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--secondary);
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
}
.modal-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.04);
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1rem;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); transform: rotate(90deg); }
.modal-body { padding: 1.75rem; }
.modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    background: rgba(255,255,255,0.3);
}

/* ═══════════════════════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════════════════════ */
.search-box {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}
.search-box .form-group { flex: 1; margin-bottom: 0; }

/* ═══════════════════════════════════════════════════════════
   WELCOME BANNER (Dashboard)
   ═══════════════════════════════════════════════════════════ */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary-50) 0%, #fff 100%);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--primary-light);
}
.welcome-banner h3 { color: var(--secondary); margin-bottom: .5rem; font-size: 1rem; }
.welcome-banner p  { color: var(--text-muted); line-height: 1.6; font-size: .875rem; }

/* ═══════════════════════════════════════════════════════════
   DIVIDER
   ═══════════════════════════════════════════════════════════ */
.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

/* ═══════════════════════════════════════════════════════════
   AMOUNT DISPLAY
   ═══════════════════════════════════════════════════════════ */
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.amount-lg { font-size: 1.15rem; }
.amount-danger { color: var(--danger); }
.amount-success { color: var(--success); }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; color: var(--gray-300); margin-bottom: 1rem; display: block; }
.empty-state p { font-size: .9rem; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .search-box { flex-direction: column; align-items: stretch; }
    .modal-box { margin: .5rem; max-width: 100%; }
}
