/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --dark-bg: #1a1a2e;
    --darker-bg: #16213e;
    --light-text: #ffffff;
    --gray-text: #a0a0a0;
    --button-bg: rgba(255, 255, 255, 0.1);
    --button-hover: rgba(255, 255, 255, 0.2);
    --operator-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-light: 0 8px 32px rgba(102, 126, 234, 0.2);
    --shadow-dark: 0 4px 16px rgba(0, 0, 0, 0.3);
    --border-radius: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Efectos de fondo animados */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: backgroundMove 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes backgroundMove {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(1deg); }
}

/* Enlace de navegación */
.nav-link {
    display: inline-block;
    margin: 20px 0 30px;
    padding: 12px 30px;
    background: rgba(26, 26, 46, 0.9);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    color: var(--light-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--operator-bg);
    transition: var(--transition);
    z-index: -1;
}

.nav-link:hover {
    color: var(--light-text);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.nav-link:hover::before {
    left: 0;
}

.nav-link:active {
    transform: translateY(0);
}

/* Container principal de la calculadora */
.calculadora {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 
        var(--shadow-light),
        var(--shadow-dark),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    max-width: 400px;
    width: 100%;
    margin-bottom: 40px;
}

.calculadora::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    animation: borderGlow 3s ease-in-out infinite;
}

@keyframes borderGlow {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Display */
.display {
    margin-bottom: 25px;
    position: relative;
}

#result {
    width: 100%;
    height: 80px;
    background: rgba(22, 33, 62, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    color: var(--light-text);
    font-size: 2.5rem;
    font-weight: 300;
    text-align: right;
    padding: 0 20px;
    letter-spacing: 1px;
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.3),
        0 4px 16px rgba(102, 126, 234, 0.1);
    transition: var(--transition);
}

#result:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(102, 126, 234, 0.3);
}

/* Grid de botones */
.botones {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 15px;
    height: 400px;
}

/* Estilos base de botones */
.btn {
    background: var(--button-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    color: var(--light-text);
    font-size: 1.4rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: var(--transition);
}

.btn:hover::before {
    left: 100%;
    transition: left 0.5s ease;
}

.btn:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

/* Botones de operadores */
.operador {
    background: var(--operator-bg);
    color: var(--light-text);
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.operador:hover {
    background: linear-gradient(135deg, #7c8ff0 0%, #8b5bb8 100%);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(118, 75, 162, 0.4);
}

/* Botón del cero (más ancho) */
.zero {
    grid-column: span 2;
}

/* Botón igual (más alto) */
.btn[data-value="="] {
    grid-row: span 2;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn[data-value="="]:hover {
    background: linear-gradient(135deg, #f5a3ff 0%, #f7677c 100%);
    box-shadow: 0 10px 30px rgba(240, 147, 251, 0.4);
}

/* Footer */
footer {
    width: 100%;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--light-text);
    padding: 40px 20px 20px;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    align-items: start;
}

.footer-logo {
    text-align: center;
}

.footer-logo p {
    margin: 10px 0;
    color: var(--gray-text);
    font-size: 0.9rem;
}

.footer-logo img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.footer-logo img:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.footer-links h3,
.footer-social h3 {
    color: var(--light-text);
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 8px;
}

.footer-links a {
    color: var(--gray-text);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.footer-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: var(--primary-color);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--light-text);
}

.footer-links a:hover::after {
    width: 100%;
}

.social-icons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.social-icons a {
    color: var(--gray-text);
    font-size: 1.5rem;
    transition: var(--transition);
    padding: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.social-icons a:hover {
    color: var(--light-text);
    background: var(--operator-bg);
    transform: translateY(-3px);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .nav-link {
        padding: 10px 25px;
        font-size: 0.9rem;
        margin: 15px 0 25px;
    }
    
    .calculadora {
        padding: 20px;
        max-width: 350px;
    }
    
    #result {
        height: 70px;
        font-size: 2rem;
        padding: 0 15px;
    }
    
    .botones {
        gap: 12px;
        height: 350px;
    }
    
    .btn {
        font-size: 1.2rem;
        min-height: 50px;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .nav-link {
        padding: 8px 20px;
        font-size: 0.85rem;
        margin: 10px 0 20px;
    }
    
    .calculadora {
        padding: 15px;
        max-width: 320px;
    }
    
    #result {
        height: 60px;
        font-size: 1.8rem;
    }
    
    .botones {
        gap: 10px;
        height: 320px;
    }
    
    .btn {
        font-size: 1.1rem;
        min-height: 45px;
        border-radius: 12px;
    }
    
    footer {
        padding: 30px 15px 15px;
    }
}

/* Animaciones adicionales */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.btn:focus {
    animation: pulse 0.3s ease-in-out;
    outline: none;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--operator-bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c8ff0 0%, #8b5bb8 100%);
}