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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    padding: 15px;
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
}

.contenedor-principal {
    max-width: 100%;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 8px;
    font-size: 2.5em;
    font-weight: 700;
    flex-shrink: 0;
}

.descripcion {
    text-align: center;
    color: #666;
    margin-bottom: 15px;
    font-size: 1.2em;
    flex-shrink: 0;
}

.configuracion {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.configuracion label {
    font-weight: 600;
    color: #333;
    font-size: 1.4em;
}

.configuracion select {
    padding: 12px 20px;
    border: 3px solid #ddd;
    border-radius: 10px;
    font-size: 1.3em;
    cursor: pointer;
    transition: border-color 0.3s;
    min-width: 200px;
    touch-action: manipulation;
}

.configuracion select:hover {
    border-color: #667eea;
}

.configuracion select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primario {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    font-size: 1.3em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    min-height: 50px;
}

.btn-primario:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.contenedor-columnas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.columna-izquierda {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.columna-izquierda h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.8em;
    text-align: center;
    font-weight: 700;
    flex-shrink: 0;
}

.columna-derecha {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0;
    overflow: hidden;
}

.fila-superior {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.fila-superior h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.8em;
    text-align: center;
    font-weight: 700;
    flex-shrink: 0;
}

.fila-inferior {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 15px;
    border-top: 2px solid #eee;
    min-height: 0;
    overflow-y: auto;
}

.fila-inferior.oculto {
    display: none;
}

.tabla-contenedor {
    overflow: auto;
    flex: 1;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

th, td {
    padding: 6px 10px;
    text-align: center;
    border: 2px solid #ddd;
    font-size: 1em;
}

th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    font-size: 1.1em;
    padding: 8px 10px;
}

.header-variable {
    cursor: text;
    transition: background-color 0.2s;
}

.header-variable:hover {
    background: linear-gradient(135deg, #7c8ef0 0%, #855fb3 100%) !important;
}

.header-variable:focus {
    outline: 2px solid #fff;
    outline-offset: -2px;
    background: linear-gradient(135deg, #8a9df5 0%, #9369be 100%) !important;
}

.header-salida {
    cursor: text;
    transition: background-color 0.2s;
}

.header-salida:hover {
    background: linear-gradient(135deg, #7c8ef0 0%, #855fb3 100%) !important;
}

.header-salida:focus {
    outline: 2px solid #fff;
    outline-offset: -2px;
    background: linear-gradient(135deg, #8a9df5 0%, #9369be 100%) !important;
}

tr:nth-child(even) {
    background: #f8f9fa;
}

tr:hover {
    background: #e9ecef;
}

.celda-variable {
    cursor: default;
    user-select: none;
    transition: all 0.2s;
    font-weight: 700;
    font-size: 1.2em;
    touch-action: manipulation;
}

/* Las celdas de variables no son interactivas, no hay hover ni active */

.celda-variable[data-valor="1"] {
    background-color: #ff9800 !important;
    color: white;
}

.celda-variable[data-valor="0"] {
    background-color: #fff !important;
    color: #333;
}

.celda-salida {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    font-weight: 700;
    font-size: 1.2em;
    touch-action: manipulation;
}

.celda-salida:hover {
    background-color: #e3f2fd !important;
    transform: scale(1.05);
}

.celda-salida:active {
    transform: scale(0.95);
}

.celda-salida[data-valor="1"] {
    background-color: #4caf50 !important;
    color: white;
}

.celda-salida[data-valor="0"] {
    background-color: #fff !important;
    color: #333;
}

/* Estilos para resultados movidos a fila-inferior */

.resultado-item {
    margin-bottom: 15px;
}

.resultado-item h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.5em;
    font-weight: 700;
}

#mapa-karnaugh {
    overflow: auto;
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

#mapa-karnaugh.oculto {
    display: none;
}

.karnaugh-table {
    border-collapse: collapse;
    margin: 10px auto;
    font-size: 1.1em;
}

.karnaugh-table td {
    width: 70px;
    height: 70px;
    border: 3px solid #333;
    background: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
    font-weight: 700;
    font-size: 1.3em;
    touch-action: manipulation;
}

.karnaugh-table td:hover {
    background: #e9ecef;
}

/* Los grupos ahora se muestran con rectángulos SVG, no con fondo de color */

.karnaugh-table .header-col,
.karnaugh-table .header-row {
    background: #667eea;
    color: white;
    font-weight: 700;
    padding: 10px;
    font-size: 1.2em;
}

.funcion {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.5em;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #333;
    border-left: 5px solid #667eea;
    margin-top: 10px;
}

.grupo-info {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 5px solid #667eea;
}

.grupo-info h4 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.3em;
    font-weight: 700;
}

.grupo-info .termino {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #333;
    font-size: 1.2em;
}

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

@media (max-width: 768px) {
    .contenedor-principal {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

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

    .configuracion select,
    .btn-primario {
        width: 100%;
    }
}

