/* --- Paleta de Colores Kalua ---
    Marrón Chocolate: #6D3D2A
    Rosa Vibrante:    #F55D93
    Amarillo Crema:   #FCEE9F
    Azul Pastel:      #C2E4F4
    Gris Suave:       #f8f9fa
    Texto Oscuro:     #343a40
*/

/* --- Reseteo y Fuentes Globales --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #fdfdfd;
    color: #343a40;
    line-height: 1.6;
}

/* --- Estilos de Login y Registro --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #6D3D2A, #8a5a49);
}

.auth-form-wrapper {
    background-color: #fff;
    padding: 2.5rem 3rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.auth-form-wrapper h2 {
    color: #6D3D2A;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #F55D93;
}

.btn-auth {
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: 8px;
    background-color: #F55D93;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-auth:hover {
    background-color: #e04a7e;
}

.auth-switch-link {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-switch-link a {
    color: #F55D93;
    text-decoration: none;
    font-weight: 600;
}

.alert {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* --- Layout del Dashboard --- */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: #6D3D2A;
    color: #fff;
    position: fixed;
    height: 100%;
    z-index: 1000;
    transition: left 0.3s ease-in-out; /* Animación suave */
}

.main-wrapper {
    flex-grow: 1;
    margin-left: 260px; /* Margen fijo para la sidebar */
    transition: margin-left 0.3s ease-in-out;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
}

.page-title {
    margin: 0;
    font-size: 1.5rem;
}

.btn-header-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 5px;
    color: white;
    text-decoration: none;
    transition: background-color 0.3s ease;
    border: none;
    font-size: 1rem;
}

.btn-header-action i {
    margin-right: 8px;
}

.btn-header-action.btn-back {
    background-color: #6c757d; /* Un color gris para "Atrás" */
}

.btn-header-action.btn-logout {
    background-color: #dc3545; /* Un color rojo para "Cerrar Sesión" */
}

.btn-header-action:hover {
    background-color: #f8f9fa;
    color: var(--color-secundario, #F55D93);
    transform: scale(1.1);
}

/* Estilo específico para el botón de logout */
.btn-logout {
    color: #dc3545; /* Rojo para indicar una acción destructiva */
    background-color: #fff;
}

.btn-logout:hover {
    background-color: #dc3545;
    color: #fff;
    transform: scale(1.1);
}

.top-header .sidebar-toggle {
    display: none; /* Se elimina permanentemente */
}

/* --- Vista de Escritorio (Ajustes) --- */
@media (min-width: 769px) {
    .sidebar {
        left: 0;
    }
}

/* --- Vista de Móvil (Ajustes) --- */
@media (max-width: 768px) {
    .sidebar {
        left: 0; /* Siempre visible */
        width: 260px;
    }
    body.dashboard-page {
      padding-left: 0; /* Evitar doble padding si existiera */
    }
    .main-wrapper {
        margin-left: 0; /* El contenido principal ocupa todo el espacio */
        padding-left: 1rem; /* Espacio para que no se pegue al borde */
    }
    .top-header {
        position: sticky;
        top: 0;
        z-index: 999;
    }
    /* Ajuste para que el contenido principal no se oculte detrás de la sidebar en móvil */
    .dashboard-layout {
        display: block;
    }
    .main-wrapper {
        width: 100%;
        margin-left: 0;
    }
    .sidebar {
        height: auto; /* Altura automática en móvil */
        position: relative;
        width: 100%;
    }
}

.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    color: #FCEE9F;
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-nav {
    flex-grow: 1;
}

.sidebar-nav ul {
    list-style: none;
    padding-top: 1rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: #C2E4F4;
    text-decoration: none;
    transition: background-color 0.3s, color 0.3s;
    border-left: 4px solid transparent;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background-color: rgba(0, 0, 0, 0.2);
    color: #fff;
    border-left-color: #F55D93;
}

.sidebar-nav a i {
    margin-right: 1rem;
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info .user-name {
    display: block;
    font-weight: 600;
}

.user-info .user-role {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* --- Responsive Sidebar & Layout --- */

/* Estado base para el sidebar y el contenido */
.sidebar {
    width: 260px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #6D3D2A;
    z-index: 1020; /* Mayor z-index para estar sobre el overlay */
    transition: left 0.3s ease-in-out;
}

.main-wrapper {
    transition: margin-left 0.3s ease-in-out;
}

.top-header .sidebar-toggle {
    display: none; /* Oculto por defecto */
    z-index: 1030; /* Asegura que el botón esté por encima de todo */
}

/* --- Vista de Escritorio (más de 768px) --- */
@media (min-width: 769px) {
    .main-wrapper {
        margin-left: 260px;
    }

    /* Cuando el menú se oculta en escritorio */
    body.sidebar-toggled .sidebar {
        left: -260px;
    }

    body.sidebar-toggled .main-wrapper {
        margin-left: 0;
    }
}

/* --- Vista Móvil (hasta 768px) --- */
@media (max-width: 768px) {
    .sidebar {
        left: -260px; /* Oculto por defecto */
    }

    .main-wrapper {
        margin-left: 0;
    }

    .top-header .sidebar-toggle {
        display: block; /* Visible en móvil */
    }

    /* Cuando el menú se muestra en móvil */
    body.sidebar-toggled .sidebar {
        left: 0;
    }

    /* Overlay para el fondo */
    body.sidebar-toggled .main-wrapper::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1010; /* Detrás del sidebar pero sobre el contenido */
    }
}

/* --- Fin de Responsive --- */


/* --- Estilos de la Tienda --- */
.card {
    background-color: #fff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
    margin-bottom: 2rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    background-color: transparent;
    border-bottom: 1px solid #eee;
    font-size: 1.2rem;
    font-weight: 600;
    color: #6D3D2A;
}

.card-header .fas {
    color: #F55D93;
    margin-right: 0.75rem;
}

.card-body {
    padding: 1.5rem;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    border-collapse: separate;
    border-spacing: 0 10px;
}

.table thead th {
    background-color: #6D3D2A;
    color: #fff;
    border: none;
    padding: 1rem 1.5rem;
    text-align: left;
}

.table thead th:first-child { border-top-left-radius: 8px; }
.table thead th:last-child { border-top-right-radius: 8px; }

.table tbody tr {
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.table tbody tr:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.table td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    border: none;
    border-top: 1px solid #f0f0f0;
}

.table td:first-child { border-left: 1px solid #f0f0f0; border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.table td:last-child { border-right: 1px solid #f0f0f0; border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
    border-radius: 6px;
}

.btn-warning {
    background-color: #FCEE9F;
    border-color: #FCEE9F;
    color: #6D3D2A;
}

.btn-danger {
    background-color: #F55D93;
    border-color: #F55D93;
}

.btn-primary {
    background-color: #6D3D2A;
    border-color: #6D3D2A;
    color: #fff;
}

.btn-secondary {
    background-color: #ccc;
    border-color: #ccc;
}

/* --- Responsividad --- */
@media (max-width: 768px) {
    .sidebar {
        margin-left: -260px;
    }

    .sidebar.is-open {
        margin-left: 0;
    }

    .main-wrapper {
        width: 100%;
    }
}

/* Estilos de la Galería de Productos */
.search-bar-container {
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-bar-container .form-control {
    border-left: none;
    border-radius: 0 30px 30px 0;
    height: 48px;
}

.search-bar-container .form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
}

.search-icon {
    background-color: white;
    border-right: none;
    border-radius: 30px 0 0 30px;
    color: #6c757d;
}

.product-card {
    border: 1px solid #e0e0e0;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 150px;
    object-fit: contain;
    padding: 10px;
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* --- Estilos para Accesos Rápidos del Dashboard --- */
.shortcut-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: #343a40;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}

.shortcut-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    color: var(--color-primario, #6D3D2A);
}

.shortcut-card i {
    margin-bottom: 1rem;
    color: var(--color-primario, #6D3D2A);
    opacity: 0.8;
    transition: color 0.2s ease;
}

.shortcut-card:hover i {
    color: var(--color-primario, #F55D93);
}

.shortcut-card span {
    font-weight: 600;
    font-size: 1.1rem;
}

.info-card h4 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

/* --- Estilos de Accesos Rápidos Mejorados --- */
.shortcut-section {
    padding: 2rem;
    background-color: #fdfdfd;
    border-radius: 15px;
    margin-top: 2rem;
    border: 1px solid #f0f0f0;
}

.shortcut-section h3 {
    color: #6D3D2A; /* Marrón Chocolate */
    margin-bottom: 2rem;
    text-align: center;
    font-weight: 700;
}

.shortcut-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.8rem;
}

.shortcut-buttons a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.8rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: none;
}

.shortcut-buttons a:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
}

/* Asignación de colores de la paleta */
.shortcut-buttons a:nth-child(4n+1) {
    background: linear-gradient(135deg, #F55D93, #e04a7e);
}

.shortcut-buttons a:nth-child(4n+2) {
    background: linear-gradient(135deg, #6D3D2A, #8a5a49);
}

.shortcut-buttons a:nth-child(4n+3) {
    background: linear-gradient(135deg, #FCEE9F, #eacb6d);
    color: #6D3D2A; /* Texto oscuro para fondo claro */
}

.shortcut-buttons a:nth-child(4n+4) {
    background: linear-gradient(135deg, #C2E4F4, #a9d4e7);
    color: #343a40; /* Texto oscuro para fondo claro */
}

.shortcut-buttons i {
    font-size: 2.8rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.shortcut-buttons span {
    font-weight: 600;
    font-size: 1rem;
}

/* --- Estilos para la visibilidad del carrito en la galería (MÉTODO NUEVO) --- */
#sales-container.cart-hidden #cart-view-col {
    display: none;
}

#sales-container.cart-hidden #product-gallery-col {
    flex: 0 0 100%;
    max-width: 100%;
}

.cart-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: #F55D93; /* Rosa Vibrante */
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    text-decoration: none;
    transition: transform 0.3s ease, background-color 0.3s ease;
    z-index: 1050;
}

.cart-fab:hover {
    transform: scale(1.1);
    background-color: #e04a7e;
    color: #fff;
}

.cart-item-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #6D3D2A; /* Marrón Chocolate */
    color: #fff;
    border-radius: 50%;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid #fff;
}

/* --- Fin de Estilos FAB --- */

/* --- Fin de Accesos Rápidos --- */

/* --- Estilos de la Tienda --- */
.product-gallery {
    border: 1px solid #e0e0e0;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-gallery:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 150px;
    object-fit: contain;
    padding: 10px;
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}