/* =========================================
   1. VARIABLES GLOBALES Y RESET
========================================= */
:root {
    --ap-gold: #d4a373;
    --wa-bg: #e5ddd5;
    --wa-gray: #f0f2f5;
    --wa-white: #ffffff;
    --wa-green: #dcf8c6;
    --sidebar-nav: #54656f;
    --text-dark: #111b21;
}

body, html { 
    margin: 0; 
    padding: 0;
    height: 100vh; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    overflow: hidden; /* Evita el scroll global, scrollean los contenedores */
    background: var(--wa-gray);
}

.main-container { 
    display: flex; 
    height: 100vh; 
    width: 100vw; 
    overflow: hidden;
}

/* =========================================
   2. NAVEGACIÓN (SIDEBAR Y MÓVIL)
========================================= */
/* Sidebar (PC) */
.nav-sidebar { 
    width: 80px; 
    background: var(--wa-white); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding-top: 20px; 
    border-right: 1px solid #ddd; 
    z-index: 10; 
}
.nav-sidebar .nav-item { 
    margin-bottom: 30px; 
    text-decoration: none; 
    padding: 10px; 
    border-radius: 10px; 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    justify-content: center;
}
.nav-sidebar .nav-item:hover { background: #f0f2f5; }
.nav-sidebar .nav-item span { color: var(--sidebar-nav); }
.nav-sidebar .nav-item.active span { color: var(--ap-gold); }

/* Barra Móvil (Celulares) */
.mobile-nav { 
    display: none; 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    background: var(--wa-white); 
    border-top: 1px solid #ddd; 
    justify-content: space-around; 
    padding: 10px 0; 
    z-index: 1000; 
}
.mobile-nav a { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    text-decoration: none; 
    color: var(--sidebar-nav); 
    font-size: 11px; 
}
.mobile-nav a.active { color: var(--ap-gold); font-weight: bold; }
.mobile-nav a.active span { color: var(--ap-gold); }

/* =========================================
   3. ESTILOS DEL DASHBOARD (INICIO)
========================================= */
.content-wrapper {
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    background: var(--wa-gray); 
    overflow-y: auto; 
    padding-bottom: 20px; /* Margen inferior normal en PC */
}

/* Tarjetas de Estadísticas (Numeritos arriba) */
.stat-card {
    background: var(--wa-white);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.stat-card h3 { margin: 5px 0; font-size: 1.5rem; color: var(--text-dark); }
.stat-card p { margin: 0; font-size: 0.8rem; color: #667781; font-weight: bold;}

/* Cajas de Contenido (Últimos Pedidos, etc) */
.dash-box {
    background: var(--wa-white);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    overflow: hidden;
    margin-bottom: 20px;
}
.box-header { padding: 15px; font-weight: bold; border-bottom: 1px solid #eee; background: #fafafa; }
.box-content { padding: 15px; flex-grow: 1; }
.box-footer { padding: 10px; text-align: center; font-size: 13px; color: var(--ap-gold); text-decoration: none; border-top: 1px solid #eee; font-weight: bold; background: #fafafa; display: block;}
.box-footer:hover { background: #f0f0f0; }

/* Ítems dentro de las cajas (Lista de pedidos) */
.activity-item {
    padding: 10px 0;
    border-bottom: 1px solid #f9f9f9;
    display: flex;
    flex-direction: column;
}
.activity-item:last-child { border-bottom: none; }
.activity-item strong { font-size: 14px; color: var(--text-dark); }
.activity-item span { font-size: 13px; color: #27ae60; font-weight: bold; margin-top: 2px;}
.activity-item small { font-size: 11px; color: #999; margin-top: 3px; }


/* =========================================
   4. ESTILOS DEL CHAT (WHATSAPP CLON)
========================================= */
/* Lista de Contactos a la izquierda */
.chats-list { 
    width: 350px; 
    background: var(--wa-white); 
    border-right: 1px solid #ddd; 
    display: flex; 
    flex-direction: column; 
    height: 100%;
}
.chats-header { padding: 15px; background: var(--wa-gray); font-weight: bold; font-size: 1.1rem; border-bottom: 1px solid #ddd; }
.chat-item { padding: 12px 15px; display: flex; align-items: center; border-bottom: 1px solid #f2f2f2; cursor: pointer; transition: 0.3s; }
.chat-item:hover { background: #f5f6f6; }
.chat-item.active { background: #ebebeb; }
.avatar { width: 45px; height: 45px; background: #ddd; border-radius: 50%; margin-right: 12px; }

/* Ventana Derecha del Chat */
.chat-window { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    background: var(--wa-bg) url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); 
    height: 100%;
}
.chat-header { background: var(--wa-gray); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.1); z-index: 10; }
.chat-messages { 
    flex-grow: 1; 
    padding: 20px 7%; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
}

/* Burbujas de Chat */
.message { 
    max-width: 75%; 
    padding: 8px 12px; 
    border-radius: 8px; 
    position: relative; 
    font-size: 14px; 
    line-height: 1.4; 
    box-shadow: 0 1px 1px rgba(0,0,0,0.1); 
    display: flex; 
    flex-direction: column; 
}
/* Entrantes (Izquierda Blanca) */
.message.user, .mensaje-entrada { 
    align-self: flex-start; 
    background-color: var(--wa-white); 
    border-top-left-radius: 0; 
}
/* Salientes (Derecha Verde) */
.message.bot, .message.admin, .mensaje-salida { 
    align-self: flex-end; 
    background-color: var(--wa-green); 
    border-top-right-radius: 0; 
}
.message .time { 
    font-size: 10px; 
    color: #667781; 
    align-self: flex-end; 
    margin-top: 4px; 
    margin-left: 15px; 
}

/* Input Area (Donde Ayelen escribe) */
.chat-input-area { background: var(--wa-gray); padding: 10px 15px; display: flex; align-items: center; gap: 15px; }
.chat-input-area input { flex-grow: 1; border: none; padding: 10px 15px; border-radius: 8px; outline: none; font-size: 15px; }
.btn-send { background: none; border: none; color: var(--sidebar-nav); cursor: pointer; display: flex; align-items: center; }


/* =========================================
   5. RESPONSIVE MÓVIL (Menos de 768px)
========================================= */
@media (max-width: 768px) {
    /* Ocultar barra lateral PC y mostrar inferior Celular */
    .nav-sidebar { display: none; }
    .mobile-nav { display: flex; }
    
    /* Levantar el contenido para que la barra no tape */
    .content-wrapper { padding-bottom: 80px !important; }

    /* Achicar cuadritos de estadísticas */
    .stats-grid { grid-template-columns: 1fr 1fr !important; }

    /* Adaptación del Chat para celular */
    .chats-list {
        width: 100%;
        position: absolute;
        left: 0;
        z-index: 20;
        height: calc(100% - 60px); /* Restamos la barra inferior */
        transition: transform 0.3s ease;
    }
    .chat-window {
        width: 100%;
        position: absolute;
        left: 0;
        z-index: 10;
        height: calc(100% - 60px);
    }
    .chats-list.hidden { transform: translateX(-100%); }
    .chat-messages { padding: 15px 15px; }
    .message { max-width: 85%; }
    
    .chat-header { padding: 8px 10px; }
    .back-button { display: block !important; margin-right: 10px; cursor: pointer; color: var(--sidebar-nav); }
}

/* Botón volver oculto en PC */
.back-button { display: none; }