/* ============== Estructura principal ============== */
/* 🎯 Valores por defecto (modo claro) */
:root {
    --bg-color: #ffffff;
    --text-color: #212529;
    --accent-color: #0d6efd;
    --card-bg: #f8f9fa;
    --border-color: #ced4da;
    --bottom-bg: #f8f9fa; /* Fondo claro para la parte inferior en modo claro */
}

    /* 🌙 Modo oscuro */
    :root[data-theme='dark'] {
        --bg-color: #1e1e1e;
        --text-color: #e9ecef;
        --accent-color: #3794ff;
        --card-bg: #2a2a2a;
        --border-color: #444;
        --bottom-bg: #2a2a2a; /* Fondo oscuro para la parte inferior en modo oscuro */
    }

/* ============== Estructura principal del contenedor ============== */
#main-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ============== Top section ============== */
.top-section {
    flex: 1 1 50%;
    background-color: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

    .top-section img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

/* ============== Parte inferior (botonera) ============== */
.bottom-section {
    flex: 1 1 50%;
    display: flex;
    padding: 20px 40px;
    background-color: var(--bottom-bg); /* Usamos la variable de fondo */
    justify-content: center;
    align-items: center;
    gap: 30px;
    position: relative;
    flex-wrap: wrap;
    max-height: 100%;
    overflow-y: auto;
}

/* ============== Teclado Numerico ============== */
.keypad-container {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    grid-gap: 12px;
    justify-content: center;
}

/* Fondo de los botones (modo claro) */
.key-btn {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
    font-size: 24px;
    padding: 0;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background-color: white; /* Fondo blanco por defecto (modo claro) */
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    color: #333;
}
    .zero-btn {
        grid-column: 2 / span 1; /* Lo coloca en la segunda columna, osea centrado*/
    }


/* 🌙 Modo oscuro: Fondo de los botones en modo oscuro */
:root[data-theme='dark'] .key-btn {
    background-color: #333; /* Fondo oscuro para modo oscuro */
    border: 1px solid #555; /* Bordes más oscuros */
    color: #e9ecef; /* Texto claro en modo oscuro */
}

/* ============== Botonera derecha ============== */
.buttons-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
}

.btn-enter,
.btn-clear {
    height: 60px;
    font-size: 20px;
    border-radius: 10px;
    border: none;
    color: white;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 120px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.25);
    transition: background 0.3s ease;
}

.btn-enter {
    background: linear-gradient(135deg, #28a745, #1e7e34);
}

.btn-clear {
    background: linear-gradient(135deg, #dc3545, #a71d2a);
}

    .btn-enter svg,
    .btn-clear svg {
        width: 24px;
        height: 24px;
        fill: white;
        margin-right: 8px;
    }

/* ============== Móvil por ancho (≤ 768px) ============== */
@media (max-width: 768px) {
    .top-section img {
        height: auto;
        object-fit: contain;
    }

    .top-section {
        flex: 0 0 auto;
    }

    .keypad-container {
        grid-template-columns: repeat(3, 70px);
        grid-gap: 14px;
    }

    .key-btn {
        width: 70px;
        height: 70px;
        font-size: 26px;
    }

    .btn-enter,
    .btn-clear {
        height: 70px;
        font-size: 22px;
        width: 140px;
    }

    .buttons-right {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        width: 100%;
        justify-content: center;
        align-items: center;
    }
}

/* ============== Móvil muy estrecho (≤ 430px) ============== */
@media (max-width: 430px) {
    .bottom-section {
        flex-wrap: wrap;
        justify-content: center;
    }

    .buttons-right {
        order: 2;
    }

    .keypad-container {
        order: 1;
    }
}

/* ============== Móvil horizontal: poca altura (≤ 500px alto) ============== */
@media (max-height: 500px) {
    .top-section {
        flex: 0 0 35%;
    }

        .top-section img {
            object-fit: contain;
            height: 100%;
        }

    .bottom-section {
        flex: 1 1 auto;
        padding: 10px 20px;
        gap: 20px;
    }

    .keypad-container {
        grid-template-columns: repeat(3, 70px);
        grid-gap: 14px;
    }

    .key-btn {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }

    .btn-enter,
    .btn-clear {
        height: 70px;
        font-size: 22px;
        width: 140px;
    }
}

/* ============== MODO HORIZONTAL: imagen full con controles encima ============== */
@media (orientation: landscape) and (max-width: 768px) {
    #main-container {
        position: relative;
        height: 100vh;
        overflow: hidden;
    }

    .top-section {
        position: absolute;
        inset: 0;
        z-index: 0;
    }

        .top-section img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

    /* Controles encima */
    .bottom-section {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.45) 50%, rgba(0,0,0,.75) 100%);
        padding: 16px 20px;
        z-index: 1;
        flex-wrap: wrap;
        display: flex;
        justify-content: flex-start; /* Alinea a la izquierda */
        gap: 30px; /* Espacio entre los botones */
    }

    .keypad-container {
        display: grid;
        grid-template-columns: repeat(3, 60px);
        grid-gap: 12px;
        justify-content: center;
        flex: 1; /* Esto asegura que la keypad ocupe el espacio disponible */
    }

    /* Aseguramos que los botones Enter y Clear se mantengan a la derecha */
    .buttons-right {
        display: flex;
        flex-direction: column;
        gap: 15px;
        justify-content: flex-start;
        align-items: flex-end; /* Esto alinea los botones a la derecha */
        flex: 0; /* No ocupa espacio extra */
    }

    /* Botones y texto más claros sobre el fondo */
    .key-btn {
        background-color: rgba(255,255,255,0.9);
    }

    .btn-enter,
    .btn-clear {
        box-shadow: none;
    }
}
