/* ==========================================================================
   DISEÑO DE MARCA EVERGREEN LOVE: PALETA DE COLORES Y TIPOGRAFÍA
   ========================================================================== */

:root {
    /* Colores Principales de Marca */
    --color-moss-green: #5F5A30;       /* Verde Musgo */
    --color-terracotta: #D09786;       /* Rosa Terracota */
    --color-light-beige: #F2E9DE;      /* Beige Claro */
    --color-olive-brown: #7A6742;      /* Marrón Oliva */
    --color-soft-black: #3E3E3E;       /* Negro Suave */
    
    /* Variaciones y Utilidades */
    --color-moss-green-light: rgba(95, 90, 48, 0.1);
    --color-moss-green-dark: #4A4625;
    --color-terracotta-light: rgba(208, 151, 134, 0.15);
    --color-terracotta-dark: #B57E6D;
    --color-white: #FFFFFF;
    --color-gray-light: #F9F7F4;
    --color-gray-border: #E5DDD0;
    
    /* Estados */
    --color-success: #4D7C0F;
    --color-warning: #C2410C;
    --color-danger: #991B1B;
    --color-info: #0369A1;

    /* Sombras y Radios */
    --shadow-sm: 0 2px 4px rgba(62, 62, 62, 0.05);
    --shadow-md: 0 4px 12px rgba(62, 62, 62, 0.08);
    --shadow-lg: 0 10px 25px rgba(62, 62, 62, 0.12);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    /* Tipografía */
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;
    
    /* Dimensiones */
    --sidebar-width: 280px;
}

/* ==========================================================================
   ESTILOS GENERALES Y RESET
   ========================================================================== */

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

body {
    font-family: var(--font-primary);
    background-color: var(--color-light-beige);
    color: var(--color-soft-black);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* ==========================================================================
   ESTRUCTURA DE LA APLICACIÓN (LAYOUT SPA)
   ========================================================================== */

.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* --- BARRA LATERAL (SIDEBAR) --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-moss-green);
    color: var(--color-light-beige);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.logo-container {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-white);
}

.logo-subtitle {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-terracotta);
    font-weight: 500;
    margin-top: 2px;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-white);
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 15px;
    color: rgba(242, 233, 222, 0.8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item i {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.nav-item:hover {
    color: var(--color-white);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item:hover i {
    transform: translateX(3px);
}

.nav-item.active {
    color: var(--color-moss-green);
    background-color: var(--color-light-beige);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--color-moss-green);
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid rgba(242, 233, 222, 0.1);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(242, 233, 222, 0.7);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: #A3E635;
    box-shadow: 0 0 8px #A3E635;
}

.status-indicator.offline {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

/* --- CONTENIDO PRINCIPAL --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 40px;
    transition: margin-left 0.3s ease;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

#page-title {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 700;
    color: var(--color-soft-black);
    position: relative;
}

#page-title::after {
    content: '';
    display: block;
    width: 45px;
    height: 3px;
    background-color: var(--color-terracotta);
    margin-top: 8px;
    border-radius: 2px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* --- NAVEGACIÓN SPA VISTAS (SECCIONES) --- */
.tab-view {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tab-view.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   COMPONENTES DE DISEÑO COMUNES
   ========================================================================== */

/* --- BOTONES PREMIUM --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.btn i {
    width: 16px;
    height: 16px;
}

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

.btn-primary:hover {
    background-color: var(--color-terracotta-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--color-white);
    color: var(--color-moss-green);
    border: 1px solid var(--color-gray-border);
}

.btn-secondary:hover {
    background-color: var(--color-gray-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

/* --- TARJETAS (CARDS) --- */
.card {
    background-color: var(--color-white);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-gray-border);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-title {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    color: var(--color-soft-black);
    margin-bottom: 16px;
}

/* --- METRICAS / INDICADORES (KPI) --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.kpi-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon.moss {
    background-color: var(--color-moss-green-light);
    color: var(--color-moss-green);
}

.kpi-icon.terracotta {
    background-color: var(--color-terracotta-light);
    color: var(--color-terracotta);
}

.kpi-icon.blue {
    background-color: rgba(3, 105, 161, 0.1);
    color: var(--color-info);
}

.kpi-icon.olive {
    background-color: rgba(122, 103, 66, 0.15);
    color: var(--color-olive-brown);
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 13px;
    font-weight: 500;
    color: #8C8270;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-soft-black);
    margin-top: 4px;
}

/* --- SECCIONES DE GRID --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* --- ALERTAS Y AVISOS --- */
.alert-card {
    background: #FEF2F2;
    border-left: 4px solid var(--color-danger);
    color: #991B1B;
    padding: 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.alert-card i {
    flex-shrink: 0;
}

.alert-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-desc {
    font-size: 13px;
    opacity: 0.9;
}

/* --- ESTADOS DE CARGA (SPINNER) --- */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #8C8270;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3.5px solid rgba(95, 90, 48, 0.1);
    border-top: 3.5px solid var(--color-moss-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   TABLAS Y LISTADOS PREMIUM
   ========================================================================== */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-gray-border);
    margin-top: 16px;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background-color: var(--color-white);
}

.custom-table th {
    background-color: var(--color-gray-light);
    color: var(--color-olive-brown);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-gray-border);
}

.custom-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-gray-border);
    font-size: 14.5px;
    color: var(--color-soft-black);
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: rgba(242, 233, 222, 0.15);
}

/* INSIGNIAS DE ESTADO (BADGES) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-pending { background-color: #FEF3C7; color: #D97706; }
.badge-progress { background-color: #E0F2FE; color: #0369A1; }
.badge-success { background-color: #DCFCE7; color: #15803D; }
.badge-danger { background-color: #FEE2E2; color: #B91C1C; }

/* ==========================================================================
   DISEÑO RESPONSIVO (MÓVILES - IPHONE)
   ========================================================================== */

@media (max-width: 768px) {
    /* --- BARRA LATERAL EN MÓVIL --- */
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
        max-width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-toggle {
        display: block;
    }
    
    /* --- CONTENIDO PRINCIPAL EN MÓVIL --- */
    .main-content {
        margin-left: 0;
        padding: 24px 16px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    #page-title {
        font-size: 26px;
    }
}

/* ==========================================================================
   MICROANIMACIONES Y EFECTOS PREMIUM (EVERGREEN LOVE)
   ========================================================================== */

/* Animación de entrada suave */
.animate-fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Efecto hover interactivo en tarjetas */
.card {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(95, 90, 48, 0.25);
}

/* Efectos de Hover Premium en Botones */
.btn-primary {
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    background-color: var(--color-terracotta-dark);
    box-shadow: 0 4px 12px rgba(208, 151, 134, 0.3);
}

.btn-secondary:hover {
    box-shadow: 0 4px 12px rgba(62, 62, 62, 0.05);
    background-color: var(--color-gray-light);
}

/* Transición suave para cambiar de pestaña en la SPA */
.tab-view {
    display: none;
    opacity: 0;
    transform: scale(0.99) translateY(4px);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-view.active {
    display: block;
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Animación de pulso para estado de la API y cargas */
.status-indicator.online {
    animation: statusPulse 2s infinite ease-in-out;
}

@keyframes statusPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(163, 230, 53, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(163, 230, 53, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(163, 230, 53, 0);
    }
}

/* Tabla de Materia Prima compactada */
.materia-prima-table th {
    font-size: 11.5px;
    padding: 10px 14px;
}

.materia-prima-table td {
    font-size: 12.5px;
    padding: 10px 14px;
}

