:root {
    --bg-dark: #040a16;
    --bg-card-dark: rgba(6, 15, 30, 0.82);
    --cyan: #00a2ff; /* Azul eléctrico / cian harmonizado con el escudo y la 'AI' del logo */
    --cyan-dark: #0077c2;
    --cyan-glow: rgba(0, 162, 255, 0.25);
    --cyan-glow-intense: rgba(0, 162, 255, 0.5);
    --silver: #a0aec0;
    --white: #ffffff;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(0, 162, 255, 0.35);
    --font-outfit: 'Outfit', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --card-width: 350px;
    --card-height: 615px; /* Altura incrementada para acomodar el cargo detallado y la frase final */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--white);
    font-family: var(--font-outfit);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Glowing Orbs */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(130px);
    z-index: 1;
    pointer-events: none;
    opacity: 0.45;
}

.bg-glow-1 {
    background: radial-gradient(circle, var(--cyan-glow-intense) 0%, rgba(4, 10, 22, 0) 70%);
    top: -200px;
    left: -200px;
}

.bg-glow-2 {
    background: radial-gradient(circle, rgba(0, 82, 204, 0.3) 0%, rgba(4, 10, 22, 0) 70%);
    bottom: -200px;
    right: -200px;
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2;
    width: 100%;
}

/* 3D Card Container */
.card-container {
    width: var(--card-width);
    height: var(--card-height);
    max-width: 90vw;
    max-height: 85vh;
    perspective: 1500px;
    outline: none;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 24px;
    /* Identity transforms to establish stacking context */
    translate: 0px;
    rotate: 0deg;
    scale: 1;
}

/* Flipped state */
.card-inner.flipped {
    transform: rotateY(180deg);
}

/* Card Faces */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    background: var(--bg-card-dark);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-container:hover .card-face,
.card-container:focus-within .card-face {
    border-color: var(--border-hover);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7),
                0 0 15px var(--cyan-glow);
}

/* Tech Grid Pattern on both faces */
.tech-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 30px 30px;
    background-image: 
        linear-gradient(to right, rgba(0, 242, 254, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 242, 254, 0.02) 1px, transparent 1px);
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
    z-index: 1;
    pointer-events: none;
}

.card-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 35px 25px 25px 25px;
}

/* CARD FRONT STYLES */
.card-front {
    transform: rotateY(0deg);
}

/* Logo Area */
.logo-container,
.back-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px;
    width: 100%;
    height: 65px; /* Altura fija para coincidir con la presencia visual del nombre */
    flex-shrink: 0;
}

.logo-img {
    max-width: 240px;
    height: auto;
    max-height: 65px;
    object-fit: contain;
    mix-blend-mode: screen; /* Mezcla el fondo oscuro del logo para hacerlo transparente */
}

/* Profile Photo Container */
.profile-container {
    position: relative;
    width: 130px;
    height: 130px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.profile-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--cyan);
    position: relative;
    z-index: 3;
}

.avatar-glow {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--cyan), transparent, var(--cyan));
    filter: blur(10px);
    animation: rotate 6s linear infinite;
    z-index: 2;
    opacity: 0.6;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* User Identity */
.user-info {
    text-align: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.user-name {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.user-title {
    font-size: 0.9rem;
    font-family: var(--font-mono);
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-subtitle {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Description block */
.company-desc {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 15px 20px;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-muted);
    max-width: 90%;
    flex-shrink: 0;
}

/* Frase de cierre en el reverso */
.final-phrase {
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 0 10px;
    flex-shrink: 0;
}

/* Flip Hints */
.flip-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--cyan);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 15px;
    opacity: 0.8;
    animation: pulse 2s infinite ease-in-out;
    flex-shrink: 0;
}

.flip-icon {
    width: 14px;
    height: 14px;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

/* CARD BACK STYLES */
.card-back {
    transform: rotateY(180deg);
}

/* El estilo de la cabecera trasera está unificado globalmente con .back-header y .logo-img */

/* QR Section */
.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.qr-border {
    padding: 10px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qr-code {
    width: 125px;
    height: 125px;
    display: block;
    flex-shrink: 0;
}

.qr-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* Contact Fast buttons */
.quick-contact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.contact-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 5px;
    color: var(--white);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.contact-btn:hover {
    background: rgba(0, 242, 254, 0.08);
    border-color: var(--cyan);
    color: var(--cyan);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.1);
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Social Grid */
.social-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    margin-bottom: 18px;
    flex-shrink: 0;
}

.social-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: all 0.3s ease;
    text-decoration: none;
}

.social-item:hover {
    background: var(--cyan);
    color: var(--bg-dark);
    border-color: var(--cyan);
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 0 15px var(--cyan-glow);
}

.social-icon {
    width: 18px;
    height: 18px;
    stroke-width: 1.5px;
}

/* Save to Contacts Button */
.save-contact-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--cyan-dark) 0%, var(--cyan) 100%);
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    color: var(--bg-dark);
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px var(--cyan-glow);
    transition: all 0.3s ease;
    margin-top: 5px;
    flex-shrink: 0;
}

.save-contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--cyan-glow-intense);
    opacity: 0.95;
}

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

.flip-back-hint {
    margin-top: 10px;
    margin-bottom: 0;
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 15px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.25);
    z-index: 2;
    margin-top: auto;
}

/* Responsive adjustments for mobile viewports */
@media (max-width: 480px) {
    :root {
        --card-width: 100vw;
        --card-height: 100dvh;
    }

    body {
        justify-content: flex-start;
        align-items: stretch;
        overflow: hidden; /* Bloquea el scroll del cuerpo para emular App nativa */
    }

    .app-container {
        padding: 0;
        height: 100dvh;
        width: 100%;
        align-items: stretch;
        justify-content: flex-start;
    }

    .card-container {
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100dvh;
    }

    .card-face {
        border-radius: 0; /* Ocupa toda la pantalla sin bordes redondeados */
        border: none;
        box-shadow: none;
    }

    .card-content {
        padding: 24px 20px 16px 20px;
        overflow-y: auto; /* Permite scroll interno si la pantalla es muy corta */
        -webkit-overflow-scrolling: touch; /* Scroll suave inercial en iOS */
    }

    .logo-container,
    .back-header {
        margin-bottom: 20px;
        height: 58px;
    }

    .logo-img {
        max-width: 210px;
        max-height: 58px;
    }

    .profile-container {
        width: 125px;
        height: 125px;
        margin-bottom: 12px;
    }

    .user-name {
        font-size: 1.65rem;
    }

    .company-desc {
        padding: 12px 16px;
        font-size: 0.8rem;
    }

    .qr-border {
        padding: 8px;
        box-shadow: 0 0 15px rgba(0, 162, 255, 0.15);
    }

    .qr-code {
        width: 115px;
        height: 115px;
    }

    .quick-contact {
        gap: 8px;
        margin-bottom: 12px;
    }

    .contact-btn {
        padding: 8px 4px;
        font-size: 0.72rem;
        border-radius: 10px;
    }

    .social-grid {
        margin-bottom: 14px;
        gap: 12px;
    }

    .social-item {
        width: 36px;
        height: 36px;
    }

    .final-phrase {
        font-size: 0.7rem;
        margin-bottom: 10px;
    }

    .save-contact-btn {
        padding: 12px 15px;
        font-size: 0.85rem;
        border-radius: 12px;
    }

    .app-footer {
        display: none; /* Oculta el footer flotante en móviles para evitar ruidos */
    }
}
