/**
 * Contact Icons Frontend Styles
 * Responsive: đẹp trên PC, gọn không che nội dung trên Mobile
 */

.ktk-contact-icons-wrapper {
    position: fixed !important;
    z-index: 9990 !important;
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    bottom: 22px;
    padding: 12px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.22);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.ktk-contact-icons-wrapper.ktk-ci-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(8px);
}

body.ktk-cart-drawer-open .ktk-contact-icons-wrapper,
.mfp-wrap ~ .ktk-contact-icons-wrapper,
.mfp-bg ~ .ktk-contact-icons-wrapper,
.wd-close-side.wd-close-side-opened ~ .ktk-contact-icons-wrapper {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(8px);
}

.ktk-contact-icons-wrapper.ktk-ci-position-left {
    left: 18px;
}

.ktk-contact-icons-wrapper.ktk-ci-position-right {
    right: 18px;
}

.ktk-contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1c61e7 0%, #4a8eff 100%);
    color: #ffffff;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(28, 97, 231, 0.22);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    position: relative;
    overflow: visible;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.34);
}

.ktk-contact-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.ktk-contact-icon:hover::before {
    transform: translate(-50%, -50%) scale(1.5);
}

.ktk-contact-icon:hover {
    transform: translateX(-2px) scale(1.04);
    box-shadow: 0 14px 28px rgba(28, 97, 231, 0.28);
}

.ktk-contact-icon:active {
    transform: translateY(-2px) scale(1.02);
    transition: transform 0.1s;
}

/* Icon only - Desktop */
.ktk-ci-style-icon_only .ktk-contact-icon {
    width: 54px;
    height: 54px;
}

.ktk-ci-style-icon_only .ktk-ci-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktk-ci-style-icon_only .ktk-ci-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* Icon + Text style */
.ktk-ci-style-icon_text .ktk-contact-icon {
    width: auto;
    height: auto;
    min-width: 50px;
    min-height: 50px;
    padding: 10px 16px;
    border-radius: 50px;
    flex-direction: row;
    gap: 8px;
}

.ktk-ci-style-icon_text .ktk-ci-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ktk-ci-style-icon_text .ktk-ci-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.ktk-ci-style-icon_text .ktk-ci-label {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    color: #ffffff;
}

@media (hover: hover) and (pointer: fine) {
    .ktk-ci-style-icon_only .ktk-contact-icon::after {
        content: attr(aria-label);
        position: absolute;
        top: 50%;
        right: calc(100% + 12px);
        transform: translateY(-50%) translateX(8px);
        opacity: 0;
        visibility: hidden;
        padding: 8px 10px;
        border-radius: 10px;
        background: rgba(15, 23, 42, 0.9);
        color: #fff;
        font-size: 12px;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
        pointer-events: none;
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
    }

    .ktk-ci-style-icon_only .ktk-contact-icon:hover::after {
        opacity: 1;
        visibility: visible;
        transform: translateY(-50%) translateX(0);
    }
}

/* Specific icon colors - Official brand colors */
.ktk-ci-messenger {
    background: linear-gradient(135deg, #0084ff 0%, #0066cc 100%);
}

.ktk-ci-zalo {
    background: linear-gradient(135deg, #0068ff 0%, #0052cc 100%);
}

.ktk-ci-telegram {
    background: linear-gradient(135deg, #0088cc 0%, #006699 100%);
}

.ktk-ci-phone {
    background: linear-gradient(135deg, #1c61e7 0%, #4a8eff 100%);
}

/* Ensure SVG icons are visible and properly sized */
.ktk-ci-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Uploaded image icons - Make them stand out and larger */
.ktk-ci-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
    border-radius: 50%;
    padding: 0;
    box-sizing: border-box;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ktk-contact-icon:hover .ktk-ci-icon img {
    transform: scale(1.08);
}

/* Make background more transparent when using custom images */
.ktk-contact-icon.has-custom-image {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(12px);
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14), inset 0 0 18px rgba(255, 255, 255, 0.45) !important;
}

.ktk-contact-icon.has-custom-image:hover {
    border-color: rgba(59, 130, 246, 0.62);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18), inset 0 0 24px rgba(255, 255, 255, 0.62) !important;
}

/* Ripple effect on click */
@keyframes ktk-ripple {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

.ktk-contact-icon.ktk-ripple-effect::before {
    animation: ktk-ripple 0.5s ease-out;
}

/* Responsive - Mobile: nhỏ gọn, không che nội dung */
@media (max-width: 768px) {
    .ktk-contact-icons-wrapper {
        bottom: max(10px, env(safe-area-inset-bottom));
        gap: 8px;
        padding: 8px 7px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.7);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
    }
    
    .ktk-contact-icons-wrapper.ktk-ci-position-left {
        left: max(10px, env(safe-area-inset-left));
    }
    
    .ktk-contact-icons-wrapper.ktk-ci-position-right {
        right: max(10px, env(safe-area-inset-right));
    }
    
    .ktk-ci-style-icon_only .ktk-contact-icon {
        width: 44px;
        height: 44px;
    }
    
    .ktk-ci-style-icon_only .ktk-ci-icon {
        width: 21px;
        height: 21px;
    }
    
    .ktk-ci-style-icon_text .ktk-contact-icon {
        min-width: 44px;
        min-height: 44px;
        padding: 8px 10px;
    }
    
    .ktk-ci-style-icon_text .ktk-ci-icon {
        width: 20px;
        height: 20px;
    }
    
    .ktk-ci-style-icon_text .ktk-ci-label {
        font-size: 11px;
    }
}

/* Mobile nhỏ (< 480px): icon còn nhỏ hơn */
@media (max-width: 480px) {
    .ktk-contact-icons-wrapper {
        bottom: max(8px, env(safe-area-inset-bottom));
        gap: 7px;
        padding: 7px 6px;
    }
    
    .ktk-contact-icons-wrapper.ktk-ci-position-left {
        left: max(8px, env(safe-area-inset-left));
    }
    
    .ktk-contact-icons-wrapper.ktk-ci-position-right {
        right: max(8px, env(safe-area-inset-right));
    }
    
    .ktk-ci-style-icon_only .ktk-contact-icon {
        width: 40px;
        height: 40px;
    }
    
    .ktk-ci-style-icon_only .ktk-ci-icon {
        width: 19px;
        height: 19px;
    }
    
    .ktk-ci-style-icon_text .ktk-ci-label {
        display: none;
    }
    
    .ktk-ci-style-icon_text .ktk-contact-icon {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
        border-radius: 50%;
    }
    
    .ktk-ci-style-icon_text .ktk-ci-icon {
        width: 19px;
        height: 19px;
    }
}

/* Accessibility */
.ktk-contact-icon:focus {
    outline: 2px solid #1c61e7;
    outline-offset: 2px;
}

/* Zalo Multiple Numbers Dropdown */
.ktk-contact-icon-wrapper {
    position: relative;
}

.ktk-zalo-dropdown {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 12px;
    z-index: 9991;
    overflow: hidden;
}

.ktk-contact-icon-wrapper.ktk-dropdown-active .ktk-zalo-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.ktk-zalo-option {
    display: block;
    padding: 10px 14px;
    color: #1d1d1f;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.ktk-zalo-option:last-child {
    border-bottom: none;
}

.ktk-zalo-option:hover {
    background-color: #f9f9f9;
}

.ktk-zalo-option .ktk-zalo-number {
    font-size: 13px;
    font-weight: 500;
    display: block;
}

.ktk-contact-icon-wrapper.ktk-has-dropdown .ktk-contact-icon {
    cursor: pointer;
}

@media (max-width: 480px) {
    .ktk-zalo-dropdown {
        margin-bottom: 8px;
        min-width: 140px;
    }
    
    .ktk-zalo-option {
        padding: 12px 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Dropdown arrow */
.ktk-zalo-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

/* Print styles - hide on print */
@media print {
    .ktk-contact-icons-wrapper {
        display: none !important;
    }
}
