/* WCGR Frontend Widget Styles - WhatsApp Reference Design */

/* Widget Container */
.wcgr-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: block;
    width: auto;
    padding-top: 0;
}

/* Position Classes */
.wcgr-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.wcgr-widget.bottom-left {
    bottom: 50px;
    left: 20px;
}

/* Toggle Button - Pill Style from Reference */
.wcgr-toggle-button {
    background: #03cc0b;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 18px;
    padding: 10px 20px;
    display: block;
    cursor: pointer;
    border-radius: 50px;
    border: none;
    transform: translateY(0) scale(1);
    transition: transform ease-in-out 0.2s;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.wcgr-toggle-button .icon {
    display: inline-block;
    vertical-align: middle;
    font-size: 18px;
    width: 17px;
    height: auto;
    margin-right: 5px;
    position: relative;
    top: -1px;
}

.wcgr-toggle-button .toggle-text {
    display: inline-block;
    vertical-align: middle;
    font-size: 14px;
    font-weight: 700;
    line-height: 18px;
}

.wcgr-toggle-button.icon-only {
    padding: 15px;
    border-radius: 50px;
}

.wcgr-toggle-button.icon-only .icon {
    width: 31px;
    font-size: 30px;
    margin-right: 0;
}

.wcgr-toggle-button:hover {
    transform: translateY(5px) scale(1);
}

/* Contact List Popup */
.wcgr-contact-list {
    position: absolute;
    bottom: 100%;
    margin: 0;
    padding: 0;
    width: calc(100vw - 60px);
    max-width: 320px;
    margin: 0 0 6px 0;
    background: #F7F7FA;
    padding: 0;
    list-style-type: none;
    border-radius: 10px;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    transition: opacity ease-in-out 0.3s 0.6s, visibility ease-in-out 0.3s 0.6s, margin ease-in-out 0.3s 0.6s;
}

.wcgr-contact-list:after {
    content: "";
    position: absolute;
    display: block;
    top: 100%;
    border-width: 8px 8px 0 8px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

.wcgr-widget.bottom-right .wcgr-contact-list {
    right: 0;
}

.wcgr-widget.bottom-right .wcgr-contact-list:after {
    right: 20px;
}

.wcgr-widget.bottom-left .wcgr-contact-list {
    left: 0;
}

.wcgr-widget.bottom-left .wcgr-contact-list:after {
    left: 20px;
}

.wcgr-widget.open .wcgr-contact-list {
    opacity: 1;
    visibility: visible;
    margin-bottom: 25px;
    transition: opacity ease-in-out 0.3s, visibility ease-in-out 0.3s, margin ease-in-out 0.3s;
}

/* Header */
.wcgr-header {
    padding: 15px;
    background: #03cc0b;
    border-radius: 10px 10px 0 0;
}

.wcgr-header .icon {
    float: left;
    width: 34px;
    position: absolute;
    top: 15px;
    left: 15px;
    height: auto;
}

.wcgr-header h5 {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0;
    text-transform: none;
    margin: 0 0 0 50px;
    padding: 0;
}

.wcgr-header h5 span {
    display: block;
    font-size: 14px;
    font-weight: 400;
    line-height: 120%;
    margin: 2px 0 0 0;
}

/* Contacts */
.wcgr-contact {
    line-height: 18px;
    background: #fafafc;
    padding: 5px 10px;
    position: relative;
    list-style-type: none;
    margin: 0;
}

.wcgr-contact:nth-child(2) {
    padding-top: 10px;
}

.wcgr-contact:nth-last-child(2) {
    padding-bottom: 10px;
}

.wcgr-contact-link {
    width: 100%;
    display: block;
    margin: 0;
    border-width: 0 0 0 0;
    border-radius: 0;
    background: #ffffff;
    position: relative;
    display: block;
    padding: 10px;
    min-height: 55px;
    background-color: transparent;
    color: #000000;
    text-transform: capitalize;
    font-size: 16px;
    transform: translateY(0);
    text-align: left;
    margin-right: 20px;
    box-shadow: 0 0px 0px rgba(38, 211, 103, 0.08);
    transition: transform ease-in 0.2s, box-shadow ease-in-out 0.2s, border ease-in-out 0.2s;
    text-decoration: none;
}

.wcgr-contact-link:hover {
    transform: translateY(0);
    box-shadow: none;
}

.wcgr-contact-link:after, 
.wcgr-contact-link:before {
    display: none;
}

.wcgr-contact-link span.text {
    padding-left: 50px;
    font-weight: 600;
    display: block;
    position: relative;
    min-height: 40px;
    margin-left: 0;
}

.wcgr-contact-link span.text span.label {
    font-size: 12px;
    display: block;
    font-weight: 400;
    color: #bababa;
    white-space: no-nowrap;
    overflow: hidden;
}

.wcgr-contact-link span.text span.label span.status {
    font-size: 11px;
}

.wcgr-contact-link span.text:after {
    content: "";
    display: block;
    width: 12px;
    height: 12px;
    background: #03cc0b;
    position: absolute;
    top: 0;
    margin-right: -40px;
    right: 100%;
    border-radius: 10px;
    border: solid 1px #ffffff;
}

.wcgr-contact-link .avatar {
    float: left;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    border: solid 2px #03cc0b;
    min-height: auto;
    margin: 0;
}

.wcgr-contact.unavailable {
    pointer-events: none;
    filter: saturate(0);
    -ms-filter: saturate(0);
    -webkit-filter: saturate(0);
    opacity: 0.7;
}

.wcgr-contact.unavailable .wcgr-contact-link {
    border-left-color: #efc33c;
    color: #bbbbbb;
}

.wcgr-contact.unavailable .wcgr-contact-link:hover {
    color: #bbbbbb;
}

.wcgr-contact.unavailable .wcgr-contact-link span.text:after {
    background: #bababa;
}

.wcgr-contact.unavailable .wcgr-contact-link span.text span.label span.status {
    color: #bababa;
}

.wcgr-contact.unavailable .wcgr-contact-link .avatar {
    border: solid 2px #bababa;
}

.wcgr-contact.available .wcgr-contact-link {
    border-left-color: #03cc0b;
}
.available {background: #fff;margin: 10px;border-radius: 10px;}
.wcgr-contact.available .wcgr-contact-link span.text span.label span.status {
    color: #03cc0b;
}

/* Footer */
.wcgr-footer {
    background: #ffffff;
    position: relative;
    z-index: 2;
    box-shadow: 0 -20px 20px rgba(82, 99, 158, 0.03);
    border-radius: 0 0 10px 10px;
    text-align: center;
    padding: 0;
}

.wcgr-footer p {
    font-size: 12px;
    line-height: 14px;
    padding: 15px;
    margin: 0;
}

/* Close Button - Positioned at top-right corner of widget */
.wcgr-close-btn {
    position: absolute;
    top: -12px !important;
    right: -12px !important;
    width: 24px;
    height: 24px;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
    z-index: 10001;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* X icon for close button */
.wcgr-close-btn:after, 
.wcgr-close-btn:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 2px;
    background: #666;
    border-radius: 1px;
    transform-origin: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.wcgr-close-btn:after {
    transform: translate(-50%, -50%) rotate(45deg);
}

.wcgr-close-btn:before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Close button hover effects */
.wcgr-close-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wcgr-close-btn:hover:after,
.wcgr-close-btn:hover:before {
    background: #333;
}

/* Show close button when widget is open with X shape */
.wcgr-widget.open .wcgr-close-btn {
    opacity: 1;
    visibility: visible;
}

.wcgr-widget.open .wcgr-close-btn:before {
    transform: translate(-50%, -50%) rotate(-45deg);
    opacity: 1;
}

.wcgr-widget.open .wcgr-close-btn:after {
    transform: translate(-50%, -50%) rotate(45deg);
    opacity: 1;
}

/* Close button when widget is closed (minus shape) */
.wcgr-widget:not(.open) .wcgr-close-btn:before {
    transform: translate(-50%, -50%) rotate(0deg);
}

.wcgr-widget:not(.open) .wcgr-close-btn:after {
    transform: translate(-50%, -50%) rotate(0deg);
    opacity: 0; /* Hide second line to show only minus */
}

/* Responsive */


@media screen and (max-width: 544px) {
    .wcgr-contact-link span.text {
        max-width: calc(100% - 30px);
        
    }
    
    .wcgr-contact-link span.text span.label span.status {
        font-size: 0;
        line-height: 0;
    }
    
    .wcgr-contact-link span.text span.label span.status:before {
        margin-right: 3px;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }
}

.wcgr-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wcgr-whatsapp-icon {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wcgr-whatsapp-icon svg {
    width: 20px;
    height: 20px;
    fill: #25D366;
}

.wcgr-header-text {
    flex: 1;
}

.wcgr-header-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.wcgr-header-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
    line-height: 1.3;
}

/* Widget Body */
.wcgr-widget-body {
    padding: 0;
    background: white;
}

/* Contact List - Force no scroll for few contacts */
.wcgr-widget:not(.has-many-contacts) .wcgr-contact-list {
    max-height: none !important;
    overflow-y: visible !important;
    overflow: visible !important;
}

.wcgr-widget .wcgr-contact-list {
    max-height: none !important;
    overflow-y: visible !important;
}

/* Add scroll only when there are many contacts (5+ contacts) */
.wcgr-widget.has-many-contacts .wcgr-contact-list {
    max-height: 280px !important;
    overflow-y: auto !important;
}

.wcgr-contact-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.wcgr-contact-item:hover {
    background: #f8f9fa;
}

.wcgr-contact-item:last-child {
    border-bottom: none;
}

/* Contact Avatar */
.wcgr-contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: #e9ecef;
    margin-right: 12px;
}

.wcgr-contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wcgr-contact-avatar .wcgr-default-avatar {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
}

/* Online Status Indicator */
.wcgr-status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #25D366;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Contact Info */
.wcgr-contact-info {
    flex: 1;
    min-width: 0;
}

.wcgr-contact-name {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    margin: 0 0 2px 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wcgr-contact-title {
    font-size: 13px;
    color: #666;
    margin: 0 0 2px 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wcgr-contact-status {
    font-size: 12px;
    color: #25D366;
    margin: 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wcgr-contact-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #25D366;
    border-radius: 50%;
    display: inline-block;
}

/* Widget Footer */
.wcgr-widget-footer {
    padding: 16px 20px 20px 20px;
    border-top: 1px solid #f0f0f0;
    background: #fafbfc;
}

.wcgr-footer-text {
    font-size: 13px;
    color: #666;
    margin: 0 0 12px 0;
    text-align: center;
    line-height: 1.4;
}

.wcgr-cta-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    width: 100%;
    position: relative;
}

.wcgr-cta-button:hover {
    background: #20C75C;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.wcgr-cta-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Widget Toggle Button - Pill Style */
.wcgr-widget-toggle {
    background: linear-gradient(135deg, #25D366 0%, #20C75C 100%);
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    position: relative;
    border: none;
    padding: 14px 24px;
    color: white;
    font-weight: 500;
    font-size: 14px;
    min-width: 200px;
}

.wcgr-widget-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.6);
}

.wcgr-toggle-icon {
    width: 20px;
    height: 20px;
    fill: white;
    flex-shrink: 0;
}

.wcgr-toggle-text {
    font-size: 14px;
    font-weight: 500;
    color: white;
}

/* Notification Badge */
.wcgr-notification-badge {
    position: absolute;
    top: -5px;
    right: -6px;
    background: #ff3333;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    animation: wcgr-pulse 2s infinite;    
    box-shadow: 0 2px 8px rgba(255, 51, 51, 0.4);
}

@keyframes wcgr-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Pulse effect for toggle button */
.wcgr-widget-toggle.wcgr-pulse {
    animation: wcgr-pulse 0.6s ease-in-out 3;
}

/* Scrollbar Styling */
.wcgr-contact-list::-webkit-scrollbar {
    width: 4px;
}

.wcgr-contact-list::-webkit-scrollbar-track {
    background: transparent;
}

.wcgr-contact-list::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

.wcgr-contact-list::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .wcgr-widget-card {
        width: calc(100vw - 20px);
        margin: 0 10px 16px 10px;
    }
    
    .wcgr-widget-bottom-right,
    .wcgr-widget-bottom-left {
        bottom: 10px;
        right: 10px;
        left: auto;
    }
    
    .wcgr-widget-top-right,
    .wcgr-widget-top-left {
        top: 10px;
        right: 10px;
        left: auto;
    }
    
    .wcgr-contact-item {
        padding: 10px 16px;
    }
    
    .wcgr-contact-avatar {
        width: 44px;
        height: 44px;
        margin-right: 10px;
    }
    
    .wcgr-widget-header,
    .wcgr-widget-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .wcgr-widget-toggle {
        min-width: 180px;
        padding: 12px 20px;
        font-size: 13px;
        
    }
    
    .wcgr-toggle-text {
        font-size: 13px;
    }
    
    .wcgr-toggle-icon {
        width: 18px;
        height: 18px;
    }
}

/* Loading State */
.wcgr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
}

.wcgr-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top: 2px solid #25D366;
    border-radius: 50%;
    animation: wcgr-spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes wcgr-spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.wcgr-error {
    padding: 20px;
    text-align: center;
    color: #dc3545;
    font-size: 14px;
}

/* Empty State */
.wcgr-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Animation for showing widget */
@keyframes wcgr-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animation for hiding widget */
@keyframes wcgr-slideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
}

.wcgr-widget-card.wcgr-show {
    animation: wcgr-slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.wcgr-widget-card.wcgr-hide {
    animation: wcgr-slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Inline widget styles (for shortcode usage) */
.wcgr-widget.wcgr-widget-inline {
    position: relative;
    display: block;
    max-width: 400px;
    margin: 20px auto;
}

.wcgr-widget-inline .wcgr-widget-toggle {
    display: none;
}

.wcgr-widget-inline .wcgr-widget-card {
    position: relative;
    bottom: auto;
    right: auto;
    width: auto;
    opacity: 1;
    transform: none;
    margin-bottom: 0;
}
