:root {
    --primary-h: 210;
    --primary-s: 100%;
    --primary-l: 50%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-dark: hsl(var(--primary-h), var(--primary-s), 40%);
    --bg-color: #f0f2f5;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #1a1a1a;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(at 0% 0%, hsla(210, 100%, 90%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 100%, 90%, 1) 0, transparent 50%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 25px;
    background: var(--glass);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

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

.lang-select {
    width: auto !important;
    padding: 5px 10px !important;
    margin-bottom: 0 !important;
    background: var(--glass) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px !important;
    font-size: 0.9rem !important;
    cursor: pointer;
}

header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* Botones */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #219150;
    transform: translateY(-2px);
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #219150;
    transform: translateY(-2px);
}

/* Formularios */
form {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

input,
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #3498db;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Secciones */
section {
    margin-bottom: 30px;
}

.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Venue Selector */
.venue-selector {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.venue-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.venue-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.venue-card:hover {
    border-color: #3498db;
    transform: translateY(-2px);
}

.venue-card h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.venue-card p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Venue Form */
.venue-form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Main Content */
.main-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.main-nav {
    display: flex;
    background: #2c3e50;
    padding: 0;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    flex: 1;
}

.nav-btn:hover {
    background-color: #34495e;
}

.nav-btn.active {
    background-color: #3498db;
}

.section {
    padding: 30px;
}

.section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #3498db;
}

.stat-card h3 {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Lists */
.products-list,
.inventory-list,
.invoices-list {
    display: grid;
    gap: 15px;
}

.product-card,
.inventory-card,
.invoice-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.product-card h4,
.inventory-card h4,
.invoice-card h4 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.product-card p,
.inventory-card p,
.invoice-card p {
    color: #7f8c8d;
    margin-bottom: 5px;
}

/* Upload Section */
.upload-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.upload-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

/* Analytics */
.analytics-controls {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.analytics-controls label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: bold;
    color: #2c3e50;
}

.analytics-controls input {
    width: auto;
    margin-bottom: 0;
}

/* Botella Interactiva Táctil */
.bottle-container {
    padding: 20px;
    background: #fdfdfd;
    border-radius: 15px;
    border: 1px solid #eee;
    margin: 20px 0;
    text-align: center;
}

.bottle-visual-wrapper {
    position: relative;
    width: 140px;
    height: 350px;
    /* Reducido un poco de 380 */
    max-height: 45vh;
    /* Se adapta a pantallas pequeñas */
    margin: 0 auto;
    cursor: crosshair;
    user-select: none;
    touch-action: none;
}

.bottle-silhouette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://cdn-icons-png.flaticon.com/512/3121/3121801.png') no-repeat center bottom;
    background-size: contain;
    z-index: 10;
    pointer-events: none;
    opacity: 0.7;
    /* Más transparente para que se vea el video detrás */
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
    /* Borde blanco para que resalte sobre fondos oscuros */
}

/* AR CAMERA STYLES */
.camera-container {
    position: relative;
    width: 100%;
    height: 400px;
    /* Altura fija para el área de cámara */
    background: #000;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* El wrapper de la botella debe flotar ENCIMA del video */
.bottle-visual-wrapper {
    position: absolute;
    /* Cambiado de relative a absolute para flotar sobre el video si se activa AR */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 350px;
    z-index: 20;
    /* Encima del video */
}

/* Cuando NO hay cámara activa, el wrapper se comporta normal */
.bottle-visual-wrapper.static-mode {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin: 0 auto;
}

.camera-overlay-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 15px;
    z-index: 30;
}

.bottle-liquid {
    position: absolute;
    bottom: 45px;
    /* Ajuste para la base de la imagen de botella */
    left: 15px;
    right: 15px;
    height: 0%;
    background: linear-gradient(to right, #e67e22, #d35400);
    /* Color ámbar/whisky por defecto */
    border-radius: 0 0 10px 10px;
    transition: height 0.3s ease-out;
    z-index: 1;
}

.bottle-liquid::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.bottle-marker {
    position: absolute;
    left: -10px;
    right: -10px;
    height: 2px;
    background: #e74c3c;
    z-index: 3;
    pointer-events: none;
}

.bottle-marker::before {
    content: '▲';
    position: absolute;
    left: -15px;
    top: -8px;
    color: #e74c3c;
    font-size: 12px;
}

.bottle-marker::after {
    content: attr(data-label);
    position: absolute;
    right: -60px;
    top: -10px;
    background: #e74c3c;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.bottle-stats {
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
    background: #2c3e50;
    color: white;
    padding: 10px;
    border-radius: 8px;
    flex-wrap: wrap;
    /* Para pantallas muy estrechas */
    gap: 10px;
}

.bottle-stats div {
    display: flex;
    flex-direction: column;
}

.bottle-stats span {
    font-size: 1.2rem;
    font-weight: bold;
}

.bottle-stats label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.7;
}

/* Modales */
.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 95vh;
    overflow-y: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .main-nav {
        flex-direction: column;
    }

    .venue-list {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

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

    .form-actions {
        flex-direction: column;
    }
}