:root {
    --brand-teal: #247171;
    --brand-aqua: #8BCBCB;
    --bg-light: #FBF9F7;
    --text-primary: #1F2D2D;
    --text-secondary: #5F7171;
    --pure-white: #FFFFFF;
    
    --shadow-soft: 0 10px 30px rgba(36, 113, 113, 0.08);
    --shadow-deep: 0 20px 50px rgba(0, 0, 0, 0.12);
    --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.02);
    --radius-l: 28px;
    --radius-m: 18px;
    --fluid: cubic-bezier(0.16, 1, 0.3, 1);
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
    background: var(--bg-light);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.4;
}

.luxury-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #F8EFE7; /* Brand Bone White */
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 203, 203, 0.2) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(36, 113, 113, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 203, 203, 0.1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(36, 113, 113, 0.08) 0px, transparent 50%);
    z-index: -1;
}

.luxury-bg::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0.15;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

.app-container {
    width: 100%;
    max-width: 480px; /* Better for modern phones */
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 40px) 24px 40px; /* Enhanced PWA Safety (V48) */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.social-row {
    display: flex;
    justify-content: center;
    gap: 16px; /* Tighter gap */
    margin-bottom: 20px; /* Elevated for better mobile balance (V46) */
}

/* Main Central Card - CLEAN on mobile (no frame) */
.boutique-card {
    width: 100%;
    position: relative;
    overflow: hidden;
    animation: cardEntrance 0.8s var(--fluid);
}

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

/* Card Header Internal Nav */
.card-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5px; /* Tighter */
    margin-bottom: 0;
}

.action-trigger {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--pure-white);
    border: none;
    color: var(--brand-teal);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--spring);
}

/* Grid Layout */
.card-content-grid {
    display: flex;
    flex-direction: column;
    padding: 0 20px 20px;
}

.identity-col {
    text-align: center;
    margin-bottom: 0px; /* V38: Zeroed to avoid double-gap with profession */
}

.profile-frame {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 20px;
}

.profile-frame {
    position: relative;
    width: 130px; /* Enlarged as requested */
    height: 130px;
    margin: 0 auto 12px; /* Tighter */
}

.profile-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 35%; /* Fixed: Lowered to center face and avoid head cut */
    border: 4px solid var(--pure-white);
    box-shadow: var(--shadow-deep);
    position: relative;
    z-index: 2;
    transition: var(--spring);
}

.profile-img:active {
    transform: scale(0.94);
}

.profile-ripple {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%; height: 100%;
    border: 2px solid rgba(139, 203, 203, 0.4);
    border-radius: 50%;
    animation: ripplePulse 3s infinite;
    z-index: 1;
}

@keyframes ripplePulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
}

.badge-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 42px;
    height: 42px;
    background: var(--pure-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 15px rgba(0,0,0,0.12);
    z-index: 10;
    border: 1px solid rgba(0,0,0,0.03);
}

.badge-icon img { 
    width: 85%; /* Larger and centered */
    height: 85%;
    object-fit: contain;
    display: block;
}

.id-name {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem; /* V37: Fitting full name in one line */
    font-weight: 500; /* Sophisticated medium weight */
    color: var(--brand-teal);
    letter-spacing: -0.01em;
    margin-bottom: 2px;
}

.id-profession {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 20px; /* Reduced to connect with buttons (V40) */
}

.social-row-wrap {
    display: none; /* Hidden on mobile */
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
}

/* Redux for old footer socials */
.social-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 25px;
}

.social-row a {
    width: 44px;
    height: 44px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-teal);
    box-shadow: var(--shadow-soft);
    transition: var(--spring);
}

.social-row svg { width: 20px; height: 20px; }

.actions-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    padding: 0; /* V42: Ensure zero offset for centering */
}

.contact-actions {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Increased separation (V40) */
    width: 100%;
}

.contact-btn {
    width: 100%;
    background: var(--pure-white);
    text-decoration: none;
    padding: 15px 20px; /* Balanced pill (V40) */
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(36, 113, 113, 0.04);
    border: 1px solid rgba(0,0,0,0.01);
    transition: transform 0.4s var(--spring), box-shadow 0.4s var(--fluid);
    color: var(--text-primary);
    position: relative;
    overflow: hidden; /* Prevent text bleeding */
}

.contact-btn.revealed {
    opacity: 1;
    transform: translateY(0);
}

.contact-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.4), transparent);
    pointer-events: none;
}

.contact-btn i {
    width: 24px;
    text-align: center;
    color: var(--brand-teal);
    font-size: 1.1rem;
    transition: var(--spring);
}

.contact-btn span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Handle redundant long text */
}

.save-contact-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--brand-teal) 0%, #3FB4B4 100%);
    color: var(--pure-white);
    border: none;
    border-radius: 18px;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(36, 113, 113, 0.15);
    transition: all 0.4s var(--spring);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 5px;
}


.tab-scroller {
    display: flex;
    justify-content: center;
    align-items: center;
    align-self: center; /* V42: Absolute centering force */
    margin: 5px auto 5px auto; /* Tighter V47 */
    gap: 8px;
    padding: 6px 8px;
    background: rgba(248, 239, 231, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    width: fit-content;
    max-width: 100%; /* V42: Safety against shift */
    border: 1px solid rgba(36, 113, 113, 0.1);
    box-shadow: 
        inset 0 1px 1px rgba(255,255,255,0.6),
        0 2px 10px rgba(0,0,0,0.03);
}

.tab-trigger {
    background: var(--pure-white);
    border: 1px solid rgba(139, 203, 203, 0.15);
    color: var(--brand-teal);
    padding: 10px 18px; /* Slightly larger for touch */
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.02);
}

.tab-trigger i {
    font-size: 0.85rem; /* Smaller icons */
    opacity: 0.7;
}


.tab-trigger:active i {
    opacity: 1;
    transform: scale(1.1);
}

/* Modal Bottom Sheets */
.modal-sheet {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(31, 45, 45, 0.4);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: none;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 0.2s ease; /* Accelerated V50 for instant clearing */
}

.modal-sheet.active { 
    display: flex;
    opacity: 1;
}

.sheet-content {
    background: var(--pure-white);
    width: 100%;
    border-radius: 30px 30px 0 0;
    padding: 30px 20px 40px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s var(--fluid); /* Accelerated V49 */
}

.modal-sheet.active .sheet-content { transform: translateY(0); }

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #F5F2EF;
}

.sheet-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    color: var(--brand-teal);
    font-weight: 600;
}

.sheet-close {
    background: #F8F6F4;
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
}

.action-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-item {
    background: var(--pure-white);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 6px 15px rgba(0,0,0,0.04);
    transition: var(--spring);
    border: 1px solid rgba(0,0,0,0.01);
    opacity: 1 !important; /* Force visibility */
    overflow: hidden;
}

.action-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

.item-main {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    cursor: pointer;
}

.item-detail {
    max-height: 0;
    opacity: 0;
    padding: 0 20px;
    transition: all 0.5s var(--fluid);
    background: #FAFAFA;
}

.action-item.expanded {
    box-shadow: 0 15px 35px rgba(36, 113, 113, 0.12);
}

.action-item.expanded .item-detail {
    max-height: 80px;
    opacity: 1;
    padding: 10px 20px 20px;
}

.action-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.expand-icon {
    color: #D1CEC9;
    font-size: 0.8rem;
    transition: transform 0.4s var(--spring);
}

.expand-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--brand-teal);
    color: var(--pure-white);
    text-align: center;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(36, 113, 113, 0.15);
}

.surface.active .action-item {
    animation: eliteSlideUp 0.6s var(--fluid) forwards;
}

.surface.active .action-item:nth-child(2) { animation-delay: 0.1s; }
.surface.active .action-item:nth-child(3) { animation-delay: 0.2s; }

@keyframes eliteSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); filter: blur(4px); }
    to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.action-item.primary { border-left: 4px solid var(--brand-teal); }

.item-icon {
    width: 38px;
    height: 38px;
    background: #F8F6F4;
    border-radius: 50%; /* Rounded for delicacy */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-teal);
    font-size: 1rem;
    transition: var(--fluid);
}

.action-item.primary .item-icon { background: rgba(139, 203, 203, 0.15); }

.item-label { flex: 1; }
.item-label h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 2px; }
.item-label span { font-size: 0.75rem; color: var(--text-secondary); }

.action-item > i:last-child { color: #D1CEC9; font-size: 0.8rem; }
.action-item:active { transform: translateX(4px); background: #fdfdfd; }

/* Location Box */
.location-box {
    background: var(--pure-white);
    padding: 16px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

.map-placeholder {
    height: 140px;
    background: #F0EDE8 url('https://maps.googleapis.com/maps/api/staticmap?center=Mayaguez,Puerto+Rico&zoom=15&size=400x200&sensor=false') center/cover no-repeat;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--brand-teal);
    margin-bottom: 20px;
    position: relative;
    border: 1px solid rgba(0,0,0,0.05);
}

.location-btn {
    display: block;
    width: 100%;
    padding: 15px;
    background: var(--brand-teal);
    color: var(--pure-white);
    text-align: center;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--fluid);
}

/* Footer Section */
.main-footer {
    padding-top: 0; /* Elevated V47 */
    text-align: center;
    margin-top: 0;
}

.social-row {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px; /* Compacter V47 */
}

.social-row a { 
    color: var(--brand-teal);
    transition: all 0.4s var(--spring); 
    width: 46px;
    height: 46px;
    background: var(--pure-white);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    border: 1px solid rgba(139, 203, 203, 0.1);
    padding: 0;
}

.social-row a svg {
    width: 22px;
    height: 22px;
    display: block; /* Eliminate line-height issues */
}

.social-row a:active, .social-row a:hover { 
    transform: scale(1.12) translateY(-3px); 
    background: var(--brand-teal);
    color: var(--pure-white);
    box-shadow: 0 8px 25px rgba(36, 113, 113, 0.2);
}

.footer-logo-box {
    opacity: 0.6;
    transform: scale(0.85); /* Slightly smaller to fit */
}

.brand-logo { 
    max-width: 110px; /* More delicate scaling (V33) */
}

/* Modal Design */
.modal {
    display: none;
    position: fixed;
    top:0; left:0; width:100%; height:100%;
    background: rgba(31, 45, 45, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: var(--pure-white);
    width: 100%;
    max-width: 340px;
    border-radius: 30px;
    padding: 35px 25px;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow-deep);
    animation: modalPop 0.4s var(--fluid);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: var(--bg-light);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
}

#qrcode { margin: 25px auto; padding: 12px; background: white; display: inline-block; border: 1px solid #eee; border-radius: 12px;}
.modal-title { font-family: 'Outfit', sans-serif; font-size: 1.4rem; color: var(--brand-teal); margin-bottom: 12px; }
.modal-desc { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

/* --- V25 REFINED HOVER ENGINE (FINAL SPECIFICITY) --- */

/* Master Hover State: All interactive elements react on mouse over */
.contact-btn:hover, 
.nav-btn:hover, 
.save-contact-btn:hover, 
.tab-trigger:hover, 
.social-row a:hover,
.social-row-wrap a:hover,
.expand-btn:hover {
    transform: scale(1.05) translateY(-5px) !important; /* Elevate and Scale Up */
    background: var(--brand-teal) !important;
    color: var(--pure-white) !important;
    border-color: var(--brand-teal) !important;
    box-shadow: 0 15px 35px rgba(36, 113, 113, 0.3) !important;
    z-index: 100 !important;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; /* Faster response */
}

/* Inner elements color override on hover - Corrected for SVG integrity */
.contact-btn:hover i,
.contact-btn:hover span,
.tab-trigger:hover i,
.tab-trigger:hover span,
.save-contact-btn:hover i,
.save-contact-btn:hover span,
.nav-btn:hover i,
.social-row a:hover svg,
.social-row-wrap a:hover svg {
    color: var(--pure-white) !important;
}

.social-row a:hover svg path,
.social-row a:hover svg rect,
.social-row a:hover svg circle,
.social-row-wrap a:hover svg path,
.social-row-wrap a:hover svg rect,
.social-row-wrap a:hover svg circle {
    stroke: var(--pure-white) !important;
    fill: none !important; /* Prevent solid blob for outline icons */
}

/* Facebook specific as it uses fill */
.social-row a[aria-label="Facebook"]:hover svg path,
.social-row-wrap a[aria-label="Facebook"]:hover svg path {
    fill: var(--pure-white) !important;
    stroke: none !important;
}

/* Click/Active State: Subtle press feedback */
.contact-btn:active, 
.nav-btn:active, 
.save-contact-btn:active, 
.tab-trigger:active, 
.social-row a:active,
.social-row-wrap a:active {
    transform: scale(0.95) translateY(2px) !important;
    transition: transform 0.1s !important;
}

/* Force override for JS-driven states if needed */
html body .is-pressed {
    transform: scale(0.95) translateY(2px) !important;
    background: var(--brand-teal) !important;
}

/* --- V29 PRECISION DESKTOP POLISH --- */
@media (min-width: 1024px) {
    .app-container {
        max-width: 1000px;
        padding: 60px 20px;
    }

    .boutique-card {
        padding: 40px 60px;
        background: #FDF9F6;
        border-radius: 40px;
        box-shadow: 
            30px 30px 80px rgba(0, 0, 0, 0.04),
            -20px -20px 60px rgba(255, 255, 255, 0.9);
    }

    .card-content-grid {
        display: grid;
        grid-template-columns: 1fr 1.2fr;
        gap: 60px;
        align-items: center;
        padding-top: 45px; /* V41: Healthy gap for nav icons */
    }

    .identity-col {
        border-right: 1px solid rgba(0,0,0,0.05);
        padding-right: 60px;
        margin-bottom: 0;
        text-align: center; /* Centralized as requested */
    }

    .profile-frame {
        width: 250px;
        height: 250px;
        margin: 0 auto 25px auto; /* Ensure centering */
    }

    /* Enlarge Badge on Desktop (V29) */
    .badge-icon {
        width: 70px;
        height: 70px;
        bottom: 10px;
        right: 10px;
        padding: 10px;
    }

    .id-name { 
        font-size: 1.75rem; /* V39: Standardized for grid safety */
        white-space: nowrap; 
        text-align: center;
    }
    
    .id-profession { 
        font-size: 1rem; 
        text-align: center;
        margin-bottom: 8px; /* Compact desktop transition (V39) */
    }

    .social-row-wrap {
        display: flex; /* Show only on desktop */
        justify-content: center; /* Centralized under name/profession */
        margin-top: 15px; /* Tighter for V39 */
    }

    .social-row-wrap a {
        width: 40px; height: 40px;
        border-radius: 50%;
        background: var(--pure-white);
        display: flex; align-items: center; justify-content: center;
        color: var(--brand-teal);
        box-shadow: 0 4px 10px rgba(0,0,0,0.05);
        transition: var(--spring);
    }

    .social-row-wrap svg { width: 18px; height: 18px; }

    .main-footer .social-row {
        display: none; /* Hide footer socials on desktop */
    }

    .actions-col {
        gap: 15px;
        padding-left: 20px;
    }

    .contact-btn {
        padding: 16px 20px;
        border-radius: 18px;
    }

    .save-contact-btn {
        padding: 20px;
        font-size: 1.1rem;
        margin-top: 5px;
    }

    .tab-scroller {
        margin-top: 15px;
        justify-content: center; /* Centering consistently (V39) */
        align-self: center;
    }

    .card-nav {
        position: absolute;
        top: 20px; left: 0; width: 100%;
        padding: 0 60px;
    }

    .main-footer {
        margin-top: 30px;
        border-top: 1px solid rgba(0,0,0,0.05);
        padding-top: 20px;
    }
}

/* Address text styling for V30 */
.address-text {
    margin-top: 5px;
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: center;
}

.address-text p {
    margin: 2px 0;
    color: var(--brand-teal);
    font-weight: 500;
}

.bcard-label {
    font-size: 0.55rem; /* Micro size for credits (V34) */
    color: var(--text-secondary);
    opacity: 0.25; /* Very subtle */
    margin-top: 15px;
    letter-spacing: 0.02em;
}

.bcard-label a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.bcard-label a:hover {
    opacity: 1;
    color: var(--brand-teal);
}
