/**
 * Estilos principales del sistema
 * Sistema de Supermercados y Tiendas V3.0
 */

/* Variables CSS */
:root {
    --color-primary: #4CAF50;
    --color-secondary: #2196F3;
    --color-success: #4CAF50;
    --color-danger: #f44336;
    --color-warning: #ff9800;
    --color-info: #2196F3;
    --color-light: #f5f5f5;
    --color-dark: #333;
    --color-border: #ddd;
    --color-text: #333;
    --color-text-light: #666;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-light);
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-dark);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p { margin-bottom: 1rem; }

/* Contenedores */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Logo */
.logo {
    max-width: 200px;
    height: auto;
}

.logo-small {
    max-width: 40px;
    height: auto;
}

/* Botones */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

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

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #757575;
    color: white;
}

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

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

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

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

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-lg {
    padding: 15px 30px;
    font-size: 18px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Formularios */
.form-control {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-control-lg {
    padding: 15px;
    font-size: 18px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-dark);
}

.form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 14px;
    color: var(--color-text-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Alertas */
.alert {
    padding: 15px 20px;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    border-left: 4px solid;
}

.alert-success {
    background-color: #d4edda;
    border-color: var(--color-success);
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: var(--color-danger);
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: var(--color-info);
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: var(--color-warning);
    color: #856404;
}

/* Página de Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.logo-container {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-container h1 {
    color: var(--color-primary);
    margin-top: 1rem;
}

.subtitle {
    color: var(--color-text-light);
    font-size: 14px;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 14px;
    color: var(--color-text-light);
}

.admin-link {
    text-align: center;
    margin-top: 1.5rem;
}

.admin-link a {
    color: white;
    text-decoration: none;
    font-size: 14px;
}

/* Página de Registro */
.registro-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 40px 20px;
}

.registro-container {
    max-width: 600px;
    margin: 0 auto;
}

.registro-card {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.cedula-info {
    background-color: var(--color-light);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Página de Bienvenida */
.bienvenida-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bienvenida-container {
    width: 100%;
    max-width: 700px;
    padding: 20px;
}

.bienvenida-card {
    background: white;
    padding: 50px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.bienvenida-header h1 {
    color: var(--color-primary);
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.bienvenida-header h2 {
    color: var(--color-text);
    font-weight: 400;
}

.mensaje-bienvenida {
    margin: 2rem 0;
}

.mensaje-principal {
    font-size: 1.2rem;
    color: var(--color-text);
}

.mensaje-secundario {
    color: var(--color-text-light);
}

.recomendaciones {
    background-color: var(--color-light);
    padding: 20px;
    border-radius: var(--border-radius);
    margin: 2rem 0;
    text-align: left;
}

.lista-promociones,
.lista-recomendaciones {
    list-style-position: inside;
    margin-top: 1rem;
}

.lista-promociones li,
.lista-recomendaciones li {
    margin-bottom: 0.5rem;
}

.contador-redireccion {
    margin-top: 2rem;
}

.contador-redireccion p {
    margin-bottom: 1rem;
    color: var(--color-text-light);
}

#contador {
    font-weight: bold;
    color: var(--color-primary);
    font-size: 1.2rem;
}

/* Dashboard del Cliente */
.dashboard-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.dashboard-header {
    background-color: white;
    box-shadow: var(--shadow);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.store-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
}

.user-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-size: 14px;
}

.dashboard-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    padding: 20px;
    max-height: calc(100vh - 80px);
    overflow: hidden;
}

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

.panel-principal {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    height: calc(100vh - 120px);
    position: relative;
}

.panel-carrito {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    position: sticky;
    top: 20px;
}

.scanner-section {
    text-align: center;
    margin-bottom: 2rem;
}

.scanner-container {
    max-width: 100%;
    margin: 0 auto 1rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--border-radius);
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.scanner-status {
    margin-top: 1rem;
    font-size: 14px;
    color: var(--color-text-light);
}

.producto-preview {
    background: var(--color-light);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.producto-imagen img {
    max-width: 200px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.producto-info {
    text-align: center;
    margin: 1rem 0;
}

.producto-precio {
    font-size: 2rem;
    font-weight: bold;
    color: var(--color-primary);
    margin: 1rem 0;
}

.producto-acciones {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.cantidad-selector {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.promociones-area {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    min-height: 150px;
    margin-bottom: 1rem;
}

.promocion-slide h3 {
    color: white;
    margin-bottom: 1rem;
}

.ultima-compra-section {
    margin-top: 2rem;
}

.carrito-header {
    padding: 15px;
    border-bottom: 2px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-light);
}

.items-count {
    font-size: 14px;
    color: var(--color-text-light);
}

.carrito-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    max-height: calc(100vh - 400px);
}

.carrito-vacio {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-light);
}

.carrito-item {
    background: var(--color-light);
    padding: 10px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 13px;
}

/* Nuevo diseño horizontal del carrito con imagen */
.carrito-item-horizontal {
    background: white;
    padding: 12px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: var(--transition);
}

.carrito-item-horizontal:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.item-imagen {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.item-detalles {
    flex: 1;
    min-width: 0;
}

.item-nombre {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-precio-unit {
    font-size: 12px;
    color: var(--color-text-light);
    margin: 0;
}

.item-controles {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.item-info h4 {
    font-size: 14px;
    margin-bottom: 0.25rem;
}

.item-precio {
    font-size: 12px;
    color: var(--color-text-light);
}

.item-cantidad {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-cantidad {
    width: 32px;
    height: 32px;
    border: none;
    background-color: var(--color-primary);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-cantidad:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

.btn-cantidad:active {
    transform: scale(0.95);
}

.cantidad {
    min-width: 35px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    color: var(--color-dark);
}

.item-subtotal {
    font-weight: bold;
    font-size: 15px;
    color: var(--color-primary);
    text-align: right;
    white-space: nowrap;
}

.btn-eliminar {
    background: var(--color-danger);
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-eliminar:hover {
    background-color: #d32f2f;
    transform: scale(1.05);
}

.btn-eliminar:active {
    transform: scale(0.95);
}

.carrito-footer {
    padding: 15px;
    border-top: 2px solid var(--color-border);
    background: white;
}

.total-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: bold;
}

.total-monto {
    color: var(--color-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 600px;
    position: relative;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--color-text-light);
}

.modal-close:hover {
    color: var(--color-dark);
}

/* Compra Finalizada */
.compra-finalizada-page {
    background: var(--color-light);
    min-height: 100vh;
    padding: 40px 20px;
}

.compra-finalizada-container {
    max-width: 800px;
    margin: 0 auto;
}

.compra-finalizada-card {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    background-color: var(--color-success);
    color: white;
    font-size: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
}

.compra-resumen {
    margin: 2rem 0;
    text-align: left;
}

.resumen-header {
    background-color: var(--color-light);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.tabla-compra {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.tabla-compra th,
.tabla-compra td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.tabla-compra th {
    background-color: var(--color-light);
    font-weight: 600;
}

.tabla-compra tfoot {
    font-size: 1.2rem;
}

.total-row td {
    border-top: 2px solid var(--color-dark);
    padding-top: 15px;
}

.instrucciones {
    background-color: #fff3cd;
    padding: 20px;
    border-radius: var(--border-radius);
    margin: 2rem 0;
}

.nota {
    font-size: 14px;
    color: var(--color-text-light);
    margin-top: 0.5rem;
}

.acciones {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Utilidades */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        max-height: none;
        padding: 10px;
        gap: 15px;
    }
    
    .panel-principal {
        order: 1;
        padding: 15px;
        max-height: none;
    }
    
    .panel-carrito {
        order: 2;
        max-height: 600px;
        position: sticky;
        bottom: 0;
    }
    
    .dashboard-header {
        padding: 10px 15px;
        flex-wrap: wrap;
    }
    
    .store-name {
        font-size: 1.2rem;
    }
    
    .user-name {
        font-size: 12px;
    }
    
    .scanner-container {
        min-height: 200px;
        max-width: 100%;
    }
    
    .producto-preview {
        padding: 15px;
    }
    
    .producto-imagen img {
        max-width: 150px;
    }
    
    .producto-precio {
        font-size: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .carrito-item {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 8px;
    }
    
    .carrito-item-horizontal {
        flex-wrap: nowrap;
        padding: 10px;
        gap: 10px;
    }
    
    .item-imagen {
        width: 50px;
        height: 50px;
    }
    
    .item-nombre {
        font-size: 13px;
    }
    
    .item-precio-unit {
        font-size: 11px;
    }
    
    .item-controles {
        gap: 6px;
    }
    
    .item-subtotal {
        font-size: 13px;
    }
    
    .btn-cantidad {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .cantidad {
        font-size: 14px;
        min-width: 30px;
    }
    
    .btn-eliminar {
        width: 28px;
        height: 28px;
        font-size: 20px;
    }
    
    .item-cantidad {
        justify-content: center;
    }
    
    .producto-acciones {
        flex-direction: column;
        gap: 8px;
    }
    
    .producto-acciones .btn {
        width: 100%;
    }
    
    .cantidad-selector {
        flex-direction: column;
        gap: 8px;
    }
    
    .promociones-area {
        padding: 20px;
        min-height: 150px;
    }
    
    .total-section {
        font-size: 1.2rem;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.3rem;
    }
}

/* ========================================
   MENSAJES EMERGENTES / POPUPS
   ======================================== */

.mensaje-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    animation: popupSlideIn 0.4s ease-out;
    max-width: 90%;
    width: 500px;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.popup-content {
    background: white;
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    position: relative;
    border: 3px solid;
}

.popup-oferta .popup-content {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
}

.popup-promocion .popup-content {
    border-color: #4CAF50;
    background: linear-gradient(135deg, #f0fff4 0%, #ffffff 100%);
}

.popup-anuncio .popup-content {
    border-color: #2196F3;
    background: linear-gradient(135deg, #f0f8ff 0%, #ffffff 100%);
}

.popup-alerta .popup-content {
    border-color: #ff9800;
    background: linear-gradient(135deg, #fff8f0 0%, #ffffff 100%);
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.popup-close:hover {
    color: #333;
    transform: scale(1.2);
}

.popup-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: popupIconBounce 0.6s ease-out;
}

@keyframes popupIconBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.popup-content h3 {
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.popup-oferta h3 {
    color: #ff6b6b;
}

.popup-promocion h3 {
    color: #4CAF50;
}

.popup-anuncio h3 {
    color: #2196F3;
}

.popup-alerta h3 {
    color: #ff9800;
}

.popup-content p {
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 25px;
    color: #333;
}

.popup-content .btn {
    min-width: 150px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Overlay oscuro detrás del popup */
.mensaje-popup::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .mensaje-popup {
        width: 90%;
        max-width: 400px;
    }
    
    .popup-content {
        padding: 30px 20px;
    }
    
    .popup-icon {
        font-size: 48px;
    }
    
    .popup-content h3 {
        font-size: 20px;
    }
    
    .popup-content p {
        font-size: 16px;
    }
    
    .popup-close {
        font-size: 28px;
        top: 10px;
        right: 15px;
    }
}
