/**
 * Direct Chat Button - Frontend Styles
 *
 * @package themevixDirectChatButton
 */

/* =============================================
   CSS CUSTOM PROPERTIES
   ============================================= */

:root {
    --dcb-green:        #25D366;
    --dcb-green-dark:   #1DA851;
    --dcb-green-deeper: #128C7E;
    --dcb-white:        #ffffff;
    --dcb-shadow-color: rgba(37, 211, 102, 0.32);
    --dcb-radius:       10px;
    --dcb-transition:   0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   WRAPPER
   ============================================= */

.directchat-button-wrapper {
    display: inline-block;
    margin: 18px 0 6px;
    vertical-align: middle;
}

.directchat-cart-button-wrapper,
.directchat-checkout-button-wrapper {
    margin: 20px 0 8px;
    text-align: center;
}

/* =============================================
   BASE BUTTON
   ============================================= */

.directchat-button {
    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    /* Spacing — optical balance: more left/right than top/bottom */
    padding: 14px 28px 14px 24px;

    /* Typography */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.3px;
    white-space: nowrap;

    /* Appearance */
    text-decoration: none !important;
    color: var(--dcb-white) !important;
    cursor: pointer;
    border: none;
    border-radius: var(--dcb-radius);
    box-sizing: border-box;

    /* Depth */
    position: relative;
    overflow: hidden;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 4px 16px var(--dcb-shadow-color),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);

    /* Animation */
    transition:
        transform  var(--dcb-transition),
        box-shadow var(--dcb-transition),
        filter     var(--dcb-transition);

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Inner diagonal gradient for richness */
.directchat-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.16) 0%,
        rgba(255, 255, 255, 0.00) 60%
    );
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* Keep icon and text above overlay */
.directchat-button > * {
    position: relative;
    z-index: 1;
}

/* ---- States ---- */

.directchat-button:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.10),
        0 8px 24px rgba(37, 211, 102, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    text-decoration: none !important;
    color: var(--dcb-white) !important;
}

.directchat-button:active {
    transform: translateY(0) scale(0.99);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.10),
        0 2px 8px var(--dcb-shadow-color),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    transition-duration: 0.08s;
}

.directchat-button:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px var(--dcb-white),
        0 0 0 5px var(--dcb-green);
}

/* =============================================
   STYLE VARIANTS
   ============================================= */

/* Default — rounded corners */
.directchat-button-default {
    border-radius: var(--dcb-radius);
}

/* Square */
.directchat-button-square {
    border-radius: 4px;
}

/* Pill */
.directchat-button-pill {
    border-radius: 100px;
    padding-left: 28px;
    padding-right: 28px;
}

/* Outline */
.directchat-button-outline {
    border-radius: var(--dcb-radius);
    border: 2px solid var(--dcb-green) !important;
    background-color: transparent !important;
    color: var(--dcb-green) !important;
    box-shadow: none;
}

.directchat-button-outline::before {
    display: none;
}

.directchat-button-outline:hover {
    background-color: rgba(37, 211, 102, 0.07) !important;
    box-shadow: none;
    transform: translateY(-1px);
}

.directchat-button-outline:hover,
.directchat-button-outline:active {
    color: var(--dcb-green) !important;
}

/* Gradient */
.directchat-button-gradient {
    background-image: linear-gradient(135deg, #25D366 0%, #128C7E 100%) !important;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.10),
        0 4px 18px rgba(37, 211, 102, 0.40),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* =============================================
   SIZES
   ============================================= */

.directchat-button-small {
    padding: 10px 20px 10px 16px;
    font-size: 13px;
    font-weight: 600;
    gap: 7px;
    border-radius: 8px;
}

.directchat-button-medium {
    padding: 14px 28px 14px 24px;
    font-size: 15px;
    gap: 9px;
}

.directchat-button-large {
    padding: 17px 34px 17px 30px;
    font-size: 17px;
    gap: 11px;
    border-radius: 12px;
    letter-spacing: 0.4px;
}

/* =============================================
   ICON
   ============================================= */

.directchat-icon,
.directchat-icon {
    flex-shrink: 0;
    display: block;
    /* Crisp on retina */
    shape-rendering: geometricPrecision;
}

.directchat-button-small  .directchat-icon,
.directchat-button-small  .directchat-icon { width: 16px; height: 16px; }

.directchat-button-medium .directchat-icon,
.directchat-button-medium .directchat-icon { width: 20px; height: 20px; }

.directchat-button-large  .directchat-icon,
.directchat-button-large  .directchat-icon { width: 22px; height: 22px; }

/* =============================================
   BUTTON TEXT
   ============================================= */

.directchat-button-text,
.directchat-button-text {
    display: inline-block;
    line-height: 1;
}

/* =============================================
   BLOCK / ALIGNMENT
   ============================================= */

.directchat-block-wrapper { margin: 12px 0; }

.directchat-align-left   { text-align: left; }
.directchat-align-center { text-align: center; }
.directchat-align-right  { text-align: right; }

/* =============================================
   WOOCOMMERCE INTEGRATION
   ============================================= */

.woocommerce .directchat-button-wrapper {
    display: block;
    margin-top: 16px;
    margin-bottom: 4px;
}

.woocommerce-cart .directchat-button-wrapper {
    margin: 24px 0 8px;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 767px) {
    .directchat-button-wrapper {
        display: block;
        width: 100%;
    }

    .directchat-button {
        width: 100%;
        justify-content: center;
        /* Slightly larger touch target on mobile */
        padding-top: 15px;
        padding-bottom: 15px;
    }

    .directchat-button-large {
        font-size: 16px;
    }
}

/* =============================================
   ERROR MESSAGE
   ============================================= */

.directchat-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #842029;
    background: #fff5f5;
    border: 1px solid #f5c2c7;
    border-left: 3px solid #dc3545;
    border-radius: 6px;
    margin: 8px 0;
}

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes dcb-pulse {
    0%   { box-shadow: 0 4px 16px var(--dcb-shadow-color), 0 0 0 0 rgba(37,211,102,0.55); }
    70%  { box-shadow: 0 4px 16px var(--dcb-shadow-color), 0 0 0 12px rgba(37,211,102,0); }
    100% { box-shadow: 0 4px 16px var(--dcb-shadow-color), 0 0 0 0  rgba(37,211,102,0); }
}

.directchat-animation-pulse {
    animation: dcb-pulse 2.2s ease-out infinite;
}

@keyframes dcb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-7px); }
    45%           { transform: translateY(-3px); }
}

.directchat-animation-bounce {
    animation: dcb-bounce 2.4s ease-in-out infinite;
}

@keyframes dcb-shake {
    0%, 100%         { transform: translateX(0); }
    15%, 45%, 75%    { transform: translateX(-4px); }
    30%, 60%, 90%    { transform: translateX(4px); }
}

.directchat-animation-shake {
    animation: dcb-shake 3.2s ease-in-out infinite;
}

@keyframes dcb-glow {
    0%, 100% { box-shadow: 0 4px 16px rgba(37,211,102,0.35), 0 0 6px rgba(37,211,102,0.30); }
    50%      { box-shadow: 0 4px 28px rgba(37,211,102,0.60), 0 0 22px rgba(37,211,102,0.55); }
}

.directchat-animation-glow {
    animation: dcb-glow 2.4s ease-in-out infinite;
}

/* =============================================
   HOVER EFFECTS
   ============================================= */

.directchat-button.directchat-hover-none:hover {
    transform: none;
    box-shadow: 0 4px 16px var(--dcb-shadow-color), inset 0 1px 0 rgba(255,255,255,0.22);
    filter: none;
}

.directchat-button.directchat-hover-darken:hover  { filter: brightness(0.88); }
.directchat-button.directchat-hover-lighten:hover { filter: brightness(1.10); }

.directchat-button.directchat-hover-scale:hover {
    transform: scale(1.045) !important;
}

.directchat-button.directchat-hover-shadow:hover {
    box-shadow: 0 10px 36px rgba(0,0,0,0.22) !important;
}

.directchat-button.directchat-hover-scale-shadow:hover {
    transform: scale(1.04) !important;
    box-shadow: 0 10px 36px rgba(0,0,0,0.22) !important;
}

/* =============================================
   RTL SUPPORT
   ============================================= */

.directchat-rtl,
.directchat-rtl-wrapper { direction: rtl; }

.directchat-rtl,
[dir="rtl"] .directchat-button {
    flex-direction: row-reverse;
    /* Mirror the optical padding for RTL */
    padding-left: 28px;
    padding-right: 24px;
}

/* =============================================
   GDPR CONSENT
   ============================================= */

.directchat-gdpr-consent {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #f8f9fa;
    border: 1px solid #e2e6ea;
    border-radius: 8px;
}

.directchat-gdpr-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.55;
    color: #495057;
}

.directchat-gdpr-checkbox {
    margin-top: 2px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--dcb-green);
    cursor: pointer;
}

.directchat-gdpr-text { flex: 1; }

.directchat-privacy-link {
    color: var(--dcb-green);
    text-decoration: underline;
}
.directchat-privacy-link:hover { color: var(--dcb-green-deeper); }

/* GDPR disabled state — JS in frontend.js manages the enabled/disabled state via
   class toggle and href. The :has() approach is intentionally omitted because
   :has() is not supported in Safari < 15.4 and consent without setting href
   would still block navigation anyway. */
.directchat-gdpr-required {
    opacity: 0.5;
    pointer-events: none;
}

@keyframes dcb-consent-highlight {
    0%, 100% { background: #f8f9fa; border-color: #e2e6ea; }
    50%      { background: #fff8e1; border-color: #ffc107; }
}

.directchat-consent-highlight {
    animation: dcb-consent-highlight 0.5s ease-in-out 3;
}

/* Disabled state */
.directchat-button.directchat-disabled {
    opacity: 0.52;
    pointer-events: none;
    cursor: not-allowed;
    box-shadow: none;
}

/* =============================================
   PRIVACY NOTICE
   ============================================= */

.directchat-privacy-notice {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.5;
    color: #868e96;
    text-align: center;
}

.directchat-privacy-notice a {
    color: #868e96;
    text-decoration: underline;
}
.directchat-privacy-notice a:hover { color: var(--dcb-green); }

/* =============================================
   QUICK REPLY TEMPLATES
   ============================================= */

.directchat-templates-wrapper {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e2e6ea;
}

.directchat-templates-label {
    font-size: 11px;
    font-weight: 700;
    color: #868e96;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.directchat-templates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.directchat-template-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    color: var(--dcb-green);
    background: var(--dcb-white);
    border: 1.5px solid var(--dcb-green);
    border-radius: 100px;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--dcb-transition), color var(--dcb-transition);
}

.directchat-template-btn:hover {
    background: var(--dcb-green);
    color: var(--dcb-white);
    text-decoration: none;
}

/* Welcome + business hours */
.directchat-welcome-message,
.directchat-business-hours {
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 8px;
    color: #444;
}

.directchat-business-hours {
    font-size: 12px;
    color: #666;
}

/* Shop loop compact button */
.directchat-shop-button-wrapper {
    margin-top: 10px;
}

.directchat-shop-button-wrapper .directchat-button {
    width: 100%;
    justify-content: center;
    font-size: 13px;
    padding: 10px 14px;
}

/* Basic floating widget */
.directchat-floating {
    position: fixed;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
}

.directchat-floating--bottom-right {
    right: 20px;
    bottom: 20px;
    flex-direction: row-reverse;
}

.directchat-floating--bottom-left {
    left: 20px;
    bottom: 20px;
}

.directchat-floating__label {
    background: #fff;
    color: #222;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    line-height: 1.3;
    max-width: 180px;
}

.directchat-floating__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.directchat-floating__btn:hover {
    transform: scale(1.05);
    color: #fff;
    text-decoration: none;
}

.directchat-floating__btn.directchat-disabled {
    opacity: 0.6;
    pointer-events: none;
}

@media (max-width: 767px) {
    .directchat-floating--bottom-right,
    .directchat-floating--bottom-left {
        right: 16px;
        left: auto;
        bottom: 16px;
    }

    .directchat-floating__label {
        display: none;
    }
}
