/* Loader container */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* Logo */
#loader-logo {
    width: 100px;
    height: auto;
    margin-bottom: 20px;
}

/* Rainbow spinner */
.rainbow-spinner {
    width: 50px;
    height: 50px;
    border: 6px solid transparent;
    border-top: 6px solid red;
    border-radius: 50%;
    animation: spin 1s linear infinite, rainbow 3s linear infinite;
}


/* Adjust logo size for portrait orientation */
@media (orientation: portrait) {
    #loader-logo {
        width: 50vw; /* 50% of the viewport width */
    }
}


body {
    background:#f4f7fb;
    font-family: "Roboto", Arial, sans-serif;
}

.vcard-wrapper {
    max-width: 380px;
    margin: 40px auto;
}

.vcard-card {
    border: none;
    border-radius: 24px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    background: #ffffff;
            position: relative; /* para ubicar la topbar absoluta sobre el header */
}

/* Topbar blanco para la marca */
.vcard-topbar {
    background: #ffffff;
    padding: 4px 10px;            /* menos espacio arriba/abajo */
    display: flex;
    justify-content: space-between; /* logo izquierda, acciones derecha */
    align-items: center;
    border-bottom: 1px solid #edf0f5;
    position: absolute;           /* sobrepone al header para ver el banner debajo */
    top: 0; left: 0; right: 0;
    z-index: 3;
    box-shadow: 0 4px 10px -6px rgba(0,0,0,0.25); /* ligera sombra inferior */
}
/* Variante glass si hay opacidad */
.vcard-topbar.glass {
    -webkit-backdrop-filter: saturate(160%) blur(8px);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom-color: rgba(0,0,0,.08);
}
.topbar-left { display:flex; align-items:center; }
.topbar-right { display:flex; align-items:center; gap:8px; }
.icon-btn {
    border: none;
    background: transparent;
    color: #57606a;
    width: 34px; height: 34px;
    border-radius: 8px;
    display: inline-flex; align-items:center; justify-content:center;
}
.icon-btn:hover { background: rgba(0,0,0,0.06); color:#111827; }

/* Switch de tema ON/OFF 3D */
.theme-switch { display:inline-flex; align-items:center; }
.theme-switch input { position:absolute; opacity:0; pointer-events:none; }
.theme-switch .switch {
    position: relative;
    width: 64px;
    height: 30px;
    border-radius: 999px;
    background: linear-gradient(180deg,#f2f4f8 0%, #e5e9f0 100%);
    border: 1px solid #d5dbe6;
    box-shadow: inset 0 2px 4px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    display: inline-flex; align-items:center; justify-content:center;
    cursor: pointer;
    transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
    padding: 0 10px;
}
.theme-switch .icon { position:absolute; font-size: 13px; opacity:.8; transition: opacity .25s ease, transform .25s ease; }
.theme-switch .icon.left { left: 10px; color:#f59e0b; }
.theme-switch .icon.right { right: 10px; color:#94a3b8; }
.theme-switch .knob {
    position: absolute; top: 2px; left: 2px;
    width: 26px; height: 26px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffffff, #e9eef6 65%, #d4dbe7);
    box-shadow: 0 3px 8px rgba(0,0,0,.18), inset 0 -2px 4px rgba(0,0,0,.08);
    transition: transform .25s ease;
}
/* Checked (oscuro) */
.theme-switch input:checked + .switch {
    background: linear-gradient(180deg,#1f2937 0%, #0f172a 100%);
    border-color: #0b1220;
    box-shadow: inset 0 2px 6px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
}
.theme-switch input:checked + .switch .knob { transform: translateX(34px); }
.theme-switch input:checked + .switch .icon.left { opacity:.35; }
.theme-switch input:checked + .switch .icon.right { opacity:1; color:#e5e7eb; }

/* Header con gradiente (o banner) */
.vcard-header {
    position: relative;
    padding: 20px 20px 110px 20px;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, #467ef9, #32d3b0);
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: var(--hdr-curve-radius-bl, 50%);
    border-bottom-right-radius: var(--hdr-curve-radius-br, 50%);
    overflow: visible;
}

/* Si hay banner, se sobrescribe el gradiente */
.vcard-header.has-banner {
    background-blend-mode: overlay;
}

.vcard-header::after {
    content: "";
    position: absolute;
    left: -40px;
    right: -40px;
    bottom: -35px;
    height: 0; /* curva trasladada al body */
    background: transparent;
    border: none;
    z-index: 1;
}

.vcard-header > * {
    position: relative;
    z-index: 2;
}

/* Capa para banner con opacidad y blend */
.vcard-header .banner-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: var(--hdr-curve-radius-bl, 50%);
    border-bottom-right-radius: var(--hdr-curve-radius-br, 50%);
    pointer-events: none;
}

/* Curva ahora en el inicio del body */
.vcard-body {
    position: relative;
    padding-top: 52px;
}

.vcard-body::before {
    content: "";
    position: absolute;
    left: -40px;
    right: -40px;
    top: calc(-1 * var(--hdr-curve-height, 80px));
    height: var(--hdr-curve-height, 80px);
    background: var(--hdr-curve-bg, #fff);
    border-radius: 100% 100% 0 0;
    z-index: 0;
    pointer-events: none;
}

.vcard-body > * {
    position: relative;
    z-index: 1;
}

/* Curva en modo oscuro: iguala al fondo oscuro */
body.dark-mode .vcard-body::before {
    background: #121721;
}

/* Brand/logo superior en el header */
.vcard-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;               /* sin espacio extra abajo */
}
.vcard-brand img {
    height: 72px;            /* reduce alto del logo */
    max-height: 72px;
    max-width: 75%;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}

/* Modo oscuro */
body.dark-mode { background: #0f1216; }
body.dark-mode .vcard-topbar { background:#0f1216; border-bottom-color:#1f2730; box-shadow: 0 6px 16px -8px rgba(0,0,0,.55); }
body.dark-mode .icon-btn { color:#cbd5e1; }
body.dark-mode .icon-btn:hover { background: rgba(255,255,255,.08); color:#fff; }
body.dark-mode .vcard-card { background:#121721; color:#e5e7eb; }
body.dark-mode .info-label { color:#9aa5b1; }
body.dark-mode .info-text { color:#e5e7eb; }
body.dark-mode .info-icon { background:#1e293b; color:#cbd5e1; }
body.dark-mode .divider { background:#273343; }
/* Pie curvo del header en modo oscuro */
body.dark-mode .vcard-header::after { background:#0f1216; }
/* Ajustes extra: info blocks y social container en oscuro */
body.dark-mode .info-block {
    background:#121721; /* contenedor oscuro */
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
body.dark-mode .info-text a { color:#93c5fd; }
body.dark-mode .info-text a:hover { color:#bfdbfe; }
body.dark-mode .social-item {
    background:#121721;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    color:#e5e7eb;
}
body.dark-mode .social-type { color:#9aa5b1; }

.vcard-avatar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -30px;
    width: 130px;   /* +35% */
    height: 130px;  /* +35% */
    border-radius: 50%;
    border: 6px solid #fff;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
    background: #fff;
    z-index: 2;
}

.vcard-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vcard-name {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.vcard-role {
    font-size: 0.95rem;
    opacity: 0.9;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.vcard-company {
    font-size: 0.85rem;
    opacity: 0.9;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.vcard-body {
    padding: 52px 22px 24px; 
}

.vcard-summary {
    font-size: 0.9rem;
    color: #6c757d;
    text-align: center;
    margin-bottom: 20px;
}

.vcard-actions {
    display:flex;
    justify-content:center;
    margin-bottom: 18px;
}

.vcard-actions .btn-circle {
    width:52px;
    height:52px;
    border-radius:50%;
    margin:0 6px;
    box-shadow:0 10px 25px rgba(0,0,0,.08);
    border: none;
}

/* Bloques de info */
.info-block {
    background:#ffffff;
    border-radius:14px;
    padding:14px 16px;
    margin-bottom: 8px;
    display:flex;
    align-items:flex-start;
}

/* Añadir un borde superior a cada bloque de info excepto el primero */
.info-block + .info-block {
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
}

.info-icon {
    width:32px;
    height:32px;
    border-radius:50%;
    background:#f5f7fb;
    display:flex;
    align-items:center;
    justify-content:center;
    margin-right:12px;
    flex-shrink:0;
    color:#6c757d;
}

.info-label {
    font-size: 0.70rem;
    text-transform: uppercase;
    color:#a0a8b3;
    margin-bottom: 0;
}

.info-text {
    font-size: 0.90rem;
    color:#212529;
    margin-bottom: 0;
    word-break: break-word;
}

.divider {
    height:1px;
    background:#edf0f5;
    margin:18px 0 12px;
}

.section-title {
    font-size: 1.0rem;
    font-weight:600;
    margin-bottom:10px;
    color:#131d29;
}

/* Social cards */
.social-item {
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:9px 12px;
    border-radius:10px;
    background:#ffffff;
    box-shadow:0 4px 18px rgba(0,0,0,.05);
    margin-bottom:8px;
    cursor:pointer;
    text-decoration:none !important;
    color:inherit;
}

.social-left {
    display:flex;
    align-items:center;
}

.social-icon {
    width:38px;
    height:38px;
    border-radius:10px;
    display:flex;
    align-items:center;
    justify-content:center;
    margin-right:10px;
    color:#fff;
    font-size:1.1rem;
}

.social-name {
    font-size:0.95rem;
    font-weight:500;
}

.social-type {
    font-size:0.72rem;
    color:#9aa1ae;
}

/* Ajuste de tamaño para íconos de redes */
.social-item .social-icon-img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    margin-right: 10px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.btn-add-contact {
    width:100%;
    margin-top:10px;
    border-radius:20px;
    font-weight:500;
}

/* Colores dinámicos (se sobrescriben desde JS) */
.bg-primary-gradient {
    background: linear-gradient(135deg, #467ef9, #32d3b0);
}

.btn-main {
    background:#467ef9;
    border-color:#467ef9;
}

.btn-main:hover {
    background:#2f61d8;
    border-color:#2f61d8;
}

@media (max-width: 575.98px) {
    .vcard-wrapper {
        max-width: none;
        width: 100%;
        margin: 12px 0 16px;
        padding: 0 12px 16px;
    }

    .vcard-card {
        border-radius: 16px;
        box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    }

    /* Loader styles */
    #loader {
        position: fixed;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background: rgba(255,255,255,0.95);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        z-index: 9999;
    }
    #loader-logo {
        width: 120px;
        max-width: 40%;
        margin-bottom: 18px;
    }
    /* Ocultar el logo del loader hasta definir el correcto */
    #loader-logo.loader-logo-hidden {
        opacity: 0;
        visibility: hidden;
    }
    #loader-logo.loader-logo-show {
        opacity: 1;
        visibility: visible;
        transition: opacity .2s ease;
    }
    .rainbow-spinner {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: conic-gradient(#467ef9,#32d3b0,#f9c946,#c76f27,#467ef9);
        animation: rotate 1.2s linear infinite;
    }
    @keyframes rotate {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }

    /* Utility to hide loader */
    .loader-hidden { display: none !important; }

    /* Avatar hover / touch bounce effect */
    .vcard-avatar { transition: transform 700ms cubic-bezier(0.2,0.8,0.2,1); }
    .vcard-avatar img#cardAvatar {
        transition: transform 700ms cubic-bezier(0.2,0.8,0.2,1), box-shadow 700ms cubic-bezier(0.2,0.8,0.2,1);
        transform-origin: center center;
        cursor: pointer;
    }
    .vcard-avatar:hover img#cardAvatar { transform: scale(1.12); box-shadow: 0 18px 40px rgba(0,0,0,0.18); }

    /* For smaller devices, keep the effect gentler */
    @media (max-width: 575.98px) {
        .vcard-avatar:hover img#cardAvatar { transform: scale(1.08); }
    }

    /* QR containers clickable */
    #qrcodeDisplay, #qrcodePreview, #shareQRCode { cursor: pointer; }

    .vcard-header {
        padding: 20px 16px 110px 20px;
    }

    .vcard-name {
        /* Tamaño de fuente fluido: se ajusta al 3.8% del ancho del viewport,
            con un máximo de 1.1rem para no ser demasiado grande en pantallas anchas. */
        font-size: clamp(0.8rem, 3.8vw, 1.1rem);
        white-space: normal; /* Permitir que el texto se ajuste si es necesario */
        line-height: 1.2;
    }            .vcard-role {
        font-size: 0.8rem;
    }

    .vcard-company {
        font-size: 0.75rem;
    }

    .vcard-body {
        padding: 48px 16px 20px;
    }
}

/* Utilidades para controlar la visibilidad del contenido durante la carga */
.vcard-wrapper.content-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.98); /* Ligero zoom para el efecto de entrada */
    transition: opacity 300ms ease-out, transform 300ms ease-out, visibility 300ms;
}

.vcard-wrapper.content-visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}
