/* Variables de color para modo claro (por defecto) */
:root {
    --color-primario: #72B42C;
    --color-secundario: #818385;
    --color-texto: #000;
    --color-fondo: #f3f3f3;
    --color-borde: #ddd;
    --color-sombra: #0000001a;
    --color-error: #e74c3c;
    --color-fondo-header: #00000069;
    --color-texto-header: #fff;
    --color-fondo-formulario: #fff;
    --color-fondo-tabla: #fff;
    --color-fila-alternativa: #72b42c38;
    --color-boton-hover: #000000;
}

/* Variables de color para modo oscuro */
[data-theme="dark"] {
    --color-primario: #8bc34a;
    --color-secundario: #9e9e9e;
    --color-texto: #e0e0e0;
    --color-fondo: #121212;
    --color-borde: #424242;
    --color-sombra: #00000080;
    --color-error: #ef5350;
    --color-fondo-header: #000000cc;
    --color-texto-header: #e0e0e0;
    --color-fondo-formulario: #1e1e1e;
    --color-fondo-tabla: #1e1e1e;
    --color-fila-alternativa: #72b42c20;
    --color-boton-hover: #72B42C;
}

/* Interruptor de tema */
.theme-switch {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    width: 50px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-secundario);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--color-primario);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Reset y estilos base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    line-height: 1;
    transition: background-color 0.3s, color 0.3s;
}

/* ----------------- HEADER ----------------- */
header {
    position: relative;
    height: 300px;
    overflow: hidden;
    color: var(--color-texto-header);
    display: flex;
    flex-direction: column;
}

/* Logo en la parte superior */
.logo-container {
    padding: 15px;
    z-index: 10;
    display: flex;
    justify-content: center;
    background: linear-gradient(to bottom, #00000066, transparent);
}

.logo {
    max-width: 200px;
    height: auto;
}

/* Carrusel de fondo */
#carrusel-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#carrusel {
    display: flex;
    width: 100%;
    height: 100%;
}

#carrusel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 500px;
    background-color: var(--color-fondo-header);
}

/* Contenido inferior del header */
.header-bottom {
    position: relative;
    z-index: 5;
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px;
    background: linear-gradient(to top, #0000004d, transparent);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
}

.header-content h1 {
    margin: 0 0 15px 0;
    font-size: 1.8rem;
    text-shadow: 1px 1px 3px #00000080;
    text-align: center;
}

/* Checkboxes */
.checkboxes {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    backdrop-filter: blur(2px);
}

.checkbox-item label {
    font-size: 0.95rem;
    color: var(--color-texto-header);
    text-shadow: 1px 1px 1px #00000080;
    cursor: pointer;
    order: 2;
}

.checkbox-item input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-texto-header);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    order: 1;
}

.checkbox-item input[type="checkbox"]:checked {
    background-color: var(--color-texto-header);
    border-color: var(--color-texto-header);
}

.checkbox-item input[type="checkbox"]:checked::after {
    content: "✓";
    display: block;
    color: var(--color-primario);
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    line-height: 16px;
}

/* Botón V */
.boton-derecha {
    padding: 10px 20px;
    background-color: var(--color-primario);
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: flex-end;
    margin-left: 20px;
}

.boton-derecha:hover {
    background-color: var(--color-boton-hover);
    transform: scale(1.05);
}

/* ----------------- MAIN CONTENT ----------------- */
main {
    padding: 25px;
    max-width: 3000px;
    margin: 0 auto;
}

/* Formulario */
.formulario {
    background: var(--color-fondo-formulario);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 2px 10px var(--color-sombra);
    margin-bottom: 30px;
}

.fila {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.campo {
    display: flex;
    flex-direction: column;
}

.campo label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--color-texto);
    font-size: 1rem;
}

.campo input,
.campo select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-primario);
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border 0.1s ease;
    background-color: var(--color-fondo-formulario);
    color: var(--color-texto);
}

.campo input:focus,
.campo select:focus {
    outline: none;
    border-color: var(--color-primario);
    box-shadow: 0 0 0 5px rgba(114, 180, 44, 0.2);
}

.campo input[readonly] {
    background-color: rgba(128, 128, 128, 0.1);
}

/* Selectores */
.campo select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23818385'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 15px;
    padding-right: 30px;
}

[data-theme="dark"] .campo select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239e9e9e'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
}

/* Contenedores especiales */
#aMedidaContainer,
#tiraRetiraContainer,
#preciosPersonalizadosContainer {
    background: rgba(114, 180, 44, 0.1);
    padding: 15px;
    border-radius: 20px;
    border-left: 10px solid var(--color-primario);
    margin-top: 10px;
    grid-column: 1 / -1;
}

/* Botones */
.botones {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.botones button {
    flex: 1 1 150px;
    padding: 12px;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.botones button:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
}

#registrar {
    background-color: var(--color-primario);
    color: white;
}

#descuento {
    background-color: var(--color-secundario);
    color: white;
}

#eliminar {
    background-color: #e9e6e6;
    color: var(--color-error);
}

#calcular {
    background-color: var(--color-primario);
    color: white;
}

/* Resultados */
.resultados {
    margin-top: 20px;
    padding: 15px;
    background: rgba(114, 180, 44, 0.2);
    border-radius: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.resultados input {
    font-weight: bold;
    color: var(--color-primario);
    font-size: 1.5rem;
    padding: 8px 12px;
    border: 1px solid var(--color-primario);
    border-radius: 30px;
    background: var(--color-fondo-formulario);
    min-width: 150px;
    text-align: center;
}

/* ----------------- TABLA MEJORADA ----------------- */
.tabla {
    background: var(--color-fondo-tabla);
    border-radius: 20px;
    box-shadow: 0 2px 10px var(--color-sombra);
    overflow-x: auto;
    margin-top: 20px;
    max-height: 500px;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

table th {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 10px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
}

table td {
    padding: 10px 7px;
    border-bottom: 1px solid var(--color-borde);
    background-color: inherit;
    color: var(--color-texto);
}

table tr:nth-child(even) {
    background-color: var(--color-fila-alternativa);
}

table tr:hover {
    background-color: var(--color-primario);
    color: #ffffff;
}

/* ----------------- LOGIN ----------------- */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background: var(--color-fondo-formulario);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--color-sombra);
    text-align: center;
}

.login-logo {
    max-width: 200px;
    margin-bottom: 20px;
}

.login-container h2 {
    color: var(--color-primario);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-primario);
    border-radius: 20px;
    font-size: 16px;
    background-color: var(--color-fondo-formulario);
    color: var(--color-texto);
}

.login-button button {
    width: 100%;
    padding: 12px;
    background-color: var(--color-primario);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--color-boton-hover);
}

#error-message {
    color: var(--color-error);
    margin-top: 15px;
    display: none;
}

/* ----------------- RESPONSIVE ----------------- */
@media (max-width: 768px) {
    header {
        height: 400px;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .checkboxes {
        gap: 10px;
    }

    .boton-derecha {
        padding: 8px 15px;
    }

    .fila {
        grid-template-columns: 1fr;
    }

    .botones button {
        flex: 1 1 100%;
    }
    
    /* Tabla responsive */
    .tabla {
        max-height: 400px;
    }
    
    table th, table td {
        padding: 8px 10px;
        font-size: 0.5rem;
    }
}

@media (max-width: 480px) {
    header {
        height: 400px;
    }

    .logo {
        max-width: 140px;
    }

    .header-content h1 {
        font-size: 1.3rem;
    }

    .header-bottom {
        flex-direction: column;
        align-items: center;
    }

    .checkboxes {
        flex-direction: column;
        width: 100%;
    }

    .boton-derecha {
        margin-top: 15px;
        width: 100%;
    }
    
    /* Tabla responsive */
    .tabla {
        max-height: 350px;
    }
    
    table th, table td {
        padding: 6px 8px;
        font-size: 0.8rem;
    }
}

/* Estilos para el recuadro de incentivo */
.incentivo-container {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    max-width: 150px;
    pointer-events: none;
}

.incentivo-borde {
    position: relative;
    border-radius: 100px;
    overflow: hidden;
    padding: 3px;
    animation: cambioColorBorde 5s infinite alternate;
    animation-timing-function: ease-in-out;
    transition: background 0.5s ease-in-out;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

@keyframes cambioColorBorde {
    0% { background: linear-gradient(45deg, #FF5E5E, #FF2525);}
    10% { background: linear-gradient(45deg, #FF8C42, #FF5E00);}
    20% { background: linear-gradient(45deg, #FFD166, #FFB627);}
    30% { background: linear-gradient(45deg, #06D6A0, #04A777);}
    40% { background: linear-gradient(45deg, #118AB2, #0A5E7D);}
    50% { background: linear-gradient(45deg, #073B4C, #052D39);}
    60% { background: linear-gradient(45deg, #7209B7, #560BAD);}
    70% { background: linear-gradient(45deg, #F72585, #B5179E);}
    80% { background: linear-gradient(45deg, #3A0CA3, #4361EE);}
    90% { background: linear-gradient(45deg, #4CC9F0, #4895EF);}
    100% { background: linear-gradient(45deg, #F72585, #7209B7);}
}

.incentivo-imagen {
    width: 100%;
    display: block;
    border-radius: 8px;
}

.incentivo-texto {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 5px 5px 20px #000000;
    text-align: center;
    pointer-events: auto;
}

/* Responsive para el incentivo */
@media (max-width: 768px) {
    .incentivo-container {
        top: 10px;
        left: 10px;
        max-width: 120px;
    }
    
    .incentivo-texto {
        font-size: 2.3rem;
    }
}

@media (max-width: 480px) {
    .incentivo-container {
        max-width: 100px;
    }
    
    .incentivo-texto {
        font-size: 2rem;
    }
}

#modificar {
    background-color: #f39c12;
    color: white;
}