/* ==================== RESET Y BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --transition-speed: 0.3s;
    --border-radius: 16px;
    --key-radius: 12px;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Poppins', 'Roboto Mono', monospace;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ==================== LOADER ==================== */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.calc-icon {
    font-size: 4rem;
    animation: bounce 1s ease infinite;
}

.loader-text {
    color: white;
    font-size: 1.2rem;
    margin-top: 1rem;
    animation: pulse 1.5s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== CALCULADORA ==================== */
.calculator {
    width: 100vw;
    height: 100vh;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    padding: 15px;
    position: relative;
    overflow: hidden;
}

/* ==================== SELECTOR DE TEMAS ==================== */
.theme-selector {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-bottom: 10px;
}

.theme-selector::-webkit-scrollbar {
    display: none;
}

.theme-btn {
    min-width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.theme-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.theme-btn:active {
    transform: scale(0.95);
}

.theme-btn.active {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8);
}

/* ==================== DISPLAY ==================== */
.display-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin-bottom: 15px;
    backdrop-filter: blur(10px);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.display-history {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    text-align: right;
    min-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.display {
    width: 100%;
    background: transparent;
    border: none;
    color: white;
    font-size: 2.8rem;
    font-family: 'Roboto Mono', monospace;
    text-align: right;
    outline: none;
    font-weight: 500;
    letter-spacing: 1px;
}

.display-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

#mode-indicator {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    letter-spacing: 2px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== TECLADO ==================== */
.keypad {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.keypad.hidden {
    display: none;
}

.key-row {
    display: flex;
    gap: 10px;
    flex: 1;
}

.key {
    flex: 1;
    border: none;
    border-radius: var(--key-radius);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

.key:active {
    transform: scale(0.95);
}

.key-number {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(5px);
}

.key-number:hover {
    background: rgba(255, 255, 255, 0.25);
}

.key-operator {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    backdrop-filter: blur(5px);
}

.key-operator:hover {
    background: rgba(255, 255, 255, 0.35);
}

.key-function {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
}

.key-function:hover {
    background: rgba(255, 255, 255, 0.2);
}

.key-equals {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.4);
}

.key-equals:hover {
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.6);
}

/* ==================== TECLADO CIENTÍFICO ==================== */
.scientific {
    flex: none;
    margin-bottom: 10px;
}

.sci-row {
    display: flex;
    gap: 8px;
}

.key-sci {
    flex: 1;
    padding: 12px 5px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
}

.key-sci:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==================== INPUT SECRETO ==================== */
.secret-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    padding: 25px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h2 {
    color: #fff;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
    transform: rotate(90deg);
}

.modal-body {
    text-align: center;
}

.access-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.section-title {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#qr-code {
    border-radius: 10px;
    background: white;
    padding: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.qr-info {
    color: rgba(255, 255, 255, 0.7);
    margin-top: 10px;
    font-size: 0.85rem;
}

/* Hipervínculo principal para PC */
.chat-hyperlink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    text-decoration: none;
    padding: 14px 25px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.chat-hyperlink:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    background: linear-gradient(135deg, #7c8ff0 0%, #8b5fb8 100%);
}

.chat-hyperlink:active {
    transform: translateY(0);
}

/* Sección para copiar link */
.link-copy-section {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.link-copy-section input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
    color: #fff;
    font-size: 0.8rem;
}

.hint-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    margin-top: 10px;
}

.divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 15px 0;
}

.chat-info {
    margin-top: 15px;
}

.link-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.link-container input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    color: #fff;
    font-size: 0.85rem;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 10px;
    padding: 10px 15px;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.start-chat-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 15px;
}

.start-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.warning-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    margin-top: 15px;
}

/* ==================== CHAT WINDOW ==================== */
.chat-window {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #0f0f1a 0%, #1a1a2e 100%);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

.chat-window.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-title {
    color: #fff;
    font-weight: 600;
}

.chat-timer {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 5px 12px;
    border-radius: 20px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
    animation: pulse-timer 1s ease infinite;
}

@keyframes pulse-timer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.chat-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.system-message {
    text-align: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.system-message .warning {
    color: #fbbf24;
    margin-top: 5px;
    font-size: 0.75rem;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    animation: messageSlide 0.2s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 5px;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.message-file:hover {
    background: rgba(0, 0, 0, 0.3);
}

.message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.attach-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.attach-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#message-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    color: white;
    font-size: 1rem;
    outline: none;
}

#message-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.1);
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 0.9rem;
    z-index: 2000;
    animation: toastSlide 0.3s ease;
}

.toast.hidden {
    display: none;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 500px) {
    .calculator {
        border-radius: 25px;
        box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    }
}

@media (max-height: 700px) {
    .display-container {
        min-height: 90px;
        padding: 10px 15px;
    }

    .display {
        font-size: 2.2rem;
    }

    .key {
        font-size: 1.3rem;
    }

    .key-sci {
        padding: 8px 3px;
        font-size: 0.8rem;
    }
}

@media (max-width: 350px) {
    .theme-btn {
        min-width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .display {
        font-size: 2rem;
    }

    .key {
        font-size: 1.2rem;
        border-radius: 10px;
    }
}

/* ==================== EFECTOS DE DESBLOQUEO SECRETO ==================== */
@keyframes secretUnlock {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    25% {
        transform: scale(1.02);
        filter: brightness(1.2);
    }
    50% {
        transform: scale(0.98);
        filter: brightness(1.5) hue-rotate(30deg);
    }
    75% {
        transform: scale(1.01);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(102, 126, 234, 0.8), 0 0 60px rgba(118, 75, 162, 0.6);
    }
}

@keyframes secretFlash {
    0% {
        opacity: 0;
        background: transparent;
    }
    50% {
        opacity: 1;
        background: radial-gradient(circle, rgba(102, 126, 234, 0.8) 0%, transparent 70%);
    }
    100% {
        opacity: 0;
        background: transparent;
    }
}

.calculator.secret-unlocking {
    animation: secretUnlock 0.8s ease, glowPulse 1s ease 3;
}

/* Flash overlay */
.secret-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    animation: secretFlash 0.6s ease;
}

/* Efecto de partículas (CSS only) */
.secret-particles {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 998;
}

.secret-particles::before,
.secret-particles::after {
    content: '✨';
    position: absolute;
    font-size: 2rem;
    animation: particleExplode 0.8s ease forwards;
}

.secret-particles::before {
    animation-delay: 0.1s;
}

.secret-particles::after {
    animation-delay: 0.2s;
}

@keyframes particleExplode {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + 100px), calc(-50% - 80px)) scale(1.5);
        opacity: 0;
    }
}