
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
}

.app-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    grid-template-areas: "content sidebar";
    min-height: 100vh;
    width: 100%;
}

.main-content {
    grid-area: content;
    display: flex;
    justify-content: center;
    padding-top: 10vh;
}

.sidebar {
    grid-area: sidebar;
    background: var(--white);
    border-left: 1px solid var(--border);
    padding: 2rem;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.search-container {
    width: 95%;
    max-width: 550px;
    background: var(--white);
    padding: 2.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    height: fit-content;
}

h1 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--primary);
    font-weight: 800;
}

.search-group {
    display: flex;
    gap: 0.75rem;
    position: relative;
}

/* Suggestions List */
.suggestions-list {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.suggestion-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: #f8fafc;
}

.suggestion-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.suggestion-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

button {
    padding: 0.8rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--primary-hover);
}

/* Modal */
dialog {
    border: none;
    border-radius: 1.25rem;
    padding: 0;
    width: 90%;
    max-width: 600px;
    height: auto;
    max-height: 85vh; /* Limitamos la altura al 85% de la pantalla */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    display: flex;
    flex-direction: column;
    max-height: 85vh; /* Aseguramos que el contenido no supere el modal */
}

.modal-header {
    padding: 1.25rem 2rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Evita que la cabecera se encoja */
}

.modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto; /* Activa el scroll vertical */
    flex-grow: 1;    /* Toma el espacio disponible */
    background: white;
}

/* Card de Producto */
.promo-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.promo-title {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    margin-bottom: 1rem;
    line-height: 1.3;
}

.price-tag {
    display: block;
    background: #eff6ff;
    color: var(--primary);
    padding: 1rem;
    border-radius: 0.75rem;
    font-weight: 800;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    text-align: center;
    border: 2px solid #dbeafe;
}

.detail-row {
    margin-bottom: 0.75rem;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.detail-value {
    font-size: 0.95rem;
    margin-top: 0.2rem;
}

.store-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.store-tag {
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
}

#loading-overlay {
    display: none;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Camera Scanner Styles */
.camera-container {
    margin-top: 20px;
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    width: 100%;
}

.camera-container.active {
    display: block;
}

#video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px 12px 0 0;
    max-height: 400px;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-region {
    width: 250px;
    height: 150px;
    border: 3px solid #00ff00;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    position: relative;
}

.scan-instruction {
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 15px;
    border-radius: 20px;
    margin-top: 15px;
    font-size: 13px;
}

.camera-controls {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #1e293b;
}

.btn-control {
    flex: 1;
    padding: 0.6rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    background: #475569;
    color: white;
}

.btn-control:hover {
    background: #334155;
}

.btn-control.btn-danger {
    background: #ef4444;
}

.btn-control.btn-danger:hover {
    background: #dc2626;
}

.flash-active {
    background: #eab308 !important;
    color: #000;
}

#cameraBtn {
    background: #0ea5e9;
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
}

#cameraBtn:hover {
    background: #0284c7;
}

/* History Section Styles */
.history-section {
    text-align: left;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-action {
    background: #f1f5f9;
    color: var(--text);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
}

.btn-action:hover {
    background: #e2e8f0;
}

.btn-clear {
    background: none;
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-clear:hover {
    background: #fee2e2;
    color: #ef4444 !important;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
    position: relative;
    padding-right: 3rem; /* Espacio para el botón de eliminar */
}

.history-item:hover {
    background: #f1f5f9;
    border-color: var(--border);
}

.btn-remove-item {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    color: var(--text-muted);
    border-radius: 50%;
    padding: 0;
    font-size: 1.2rem;
    opacity: 0;
    transition: all 0.2s;
}

.history-item:hover .btn-remove-item {
    opacity: 1;
}

.btn-remove-item:hover {
    background: #fee2e2;
    color: #ef4444;
}

.history-item-info {
    display: flex;
    flex-direction: column;
}

.history-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.history-item-sku {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-item-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

/* Responsive Improvements */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr 300px;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "content"
            "sidebar";
    }
    
    .sidebar {
        height: auto;
        position: static;
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 1.5rem;
    }
    
    .main-content {
        padding: 1.5rem 1rem;
        padding-top: 2rem;
    }

    .search-container {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .price-tag {
        font-size: 1.5rem;
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .search-group {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.5rem;
    }

    .search-group input {
        grid-column: 1 / -1;
        width: 100%;
        box-sizing: border-box;
    }

    .search-group button:not(#cameraBtn) {
        grid-column: 1 / 2;
        padding: 0.75rem;
    }

    #cameraBtn {
        grid-column: 2 / 3;
        padding: 0.75rem 1rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .promo-card {
        padding: 1rem;
    }

    .scan-region {
        width: 80%;
        height: 120px;
    }
    
    .history-item {
        padding: 0.5rem 0.75rem;
        padding-right: 2.5rem;
    }
    
    .history-item-name {
        font-size: 0.85rem;
    }

    /* Bottom Sheet Modal for Mobile */
    dialog {
        width: 100%;
        max-width: none;
        margin: 0;
        top: auto;
        bottom: 0;
        border-radius: 1.5rem 1.5rem 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        display: block; /* Necesario para la transición */
        visibility: hidden;
    }

    dialog[open] {
        transform: translateY(0);
        visibility: visible;
    }

    .modal-content {
        max-height: 90vh;
    }

    .modal-header {
        padding: 1rem 1.5rem;
    }

    .modal-body {
        padding: 1rem 1.5rem 2rem 1.5rem;
    }

    h1 {
        font-size: 1.75rem;
        margin-top: 1rem;
    }
}
