/**
 * Farin WhatsApp Support - Frontend Styles
 * Version: 2.0.0
 */

/* ========================================
   CSS Variables
======================================== */
:root {
    --farin-wa-button-color: #25D366;
    --farin-wa-header-color: #25D366;
    --farin-wa-header-dark: #128C7E;
}

/* ========================================
   Widget Container
======================================== */
#farin-wa-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    direction: rtl;
}

/* ========================================
   Float Button
======================================== */
.farin-wa-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--farin-wa-button-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.farin-wa-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(37, 211, 102, 0.5);
}

.farin-wa-button.active {
    transform: rotate(45deg) scale(1.1);
}

.farin-wa-button img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.farin-wa-button svg {
    transition: transform 0.3s;
}

/* Pulse Effect */
.farin-wa-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: farin-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    opacity: 0;
    pointer-events: none;
}

@keyframes farin-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    70% { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Animations */
.farin-wa-anim-bounce {
    animation: farin-bounce 2s ease infinite;
}

@keyframes farin-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.farin-wa-anim-shake {
    animation: farin-shake 3s ease infinite;
}

@keyframes farin-shake {
    0%, 90%, 100% { transform: rotate(0); }
    92%, 96% { transform: rotate(10deg); }
    94%, 98% { transform: rotate(-10deg); }
}

.farin-wa-anim-pulse .farin-wa-pulse {
    animation: farin-pulse-strong 1.5s ease infinite;
}

@keyframes farin-pulse-strong {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

/* ========================================
   Chat Box
======================================== */
.farin-wa-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: farin-box-enter 0.3s ease-out;
}

@keyframes farin-box-enter {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Position Variants */
.farin-wa-bottom-left .farin-wa-box {
    right: auto;
    left: 0;
}

.farin-wa-top-right .farin-wa-box,
.farin-wa-top-left .farin-wa-box {
    bottom: auto;
    top: 80px;
    animation-name: farin-box-enter-top;
}

.farin-wa-top-left .farin-wa-box {
    right: auto;
    left: 0;
}

@keyframes farin-box-enter-top {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ========================================
   Header
======================================== */
.farin-wa-header {
    background: linear-gradient(135deg, var(--farin-wa-header-color) 0%, var(--farin-wa-header-dark) 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.farin-wa-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.farin-wa-header-content .header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.farin-wa-header-content .header-text p {
    margin: 3px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.farin-wa-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.farin-wa-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   Body
======================================== */
.farin-wa-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    max-height: 350px;
}

.farin-wa-body::-webkit-scrollbar {
    width: 5px;
}

.farin-wa-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.farin-wa-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* Welcome Message */
.farin-wa-welcome {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.farin-wa-welcome .welcome-icon {
    color: var(--farin-wa-header-color);
    flex-shrink: 0;
}

.farin-wa-welcome .welcome-text {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

/* Outside Hours Message */
.farin-wa-outside-hours {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.farin-wa-outside-hours .outside-hours-icon {
    font-size: 20px;
}

.farin-wa-outside-hours .outside-hours-text {
    font-size: 13px;
    color: #856404;
}

/* Loading */
.farin-wa-loading {
    text-align: center;
    padding: 40px 20px;
}

.farin-wa-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 12px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--farin-wa-header-color);
    border-radius: 50%;
    animation: farin-spin 0.8s linear infinite;
}

@keyframes farin-spin {
    to { transform: rotate(360deg); }
}

.farin-wa-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* Empty State */
.farin-wa-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.farin-wa-empty svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.farin-wa-empty.error {
    color: #dc3545;
}

.farin-wa-empty.error svg {
    fill: #dc3545;
}

/* ========================================
   Departments & Operators
======================================== */
.farin-wa-department {
    margin-bottom: 15px;
}

.farin-wa-department:last-child {
    margin-bottom: 0;
}

.farin-wa-department-title {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    padding: 0 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Operator Card */
.farin-wa-operator {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid transparent;
}

.farin-wa-operator:hover {
    transform: translateX(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--farin-wa-header-color);
}

.farin-wa-operator:active {
    transform: scale(0.98);
}

.farin-wa-operator:last-child {
    margin-bottom: 0;
}

/* Avatar */
.farin-wa-operator-avatar {
    position: relative;
    flex-shrink: 0;
}

.farin-wa-operator-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.farin-wa-no-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.farin-wa-status-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.farin-wa-status-badge.online { background: #00c853; }
.farin-wa-status-badge.away { background: #ffc107; }
.farin-wa-status-badge.offline { background: #9e9e9e; }

/* Info */
.farin-wa-operator-info {
    flex: 1;
    min-width: 0;
}

.farin-wa-operator-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.farin-wa-operator-position {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status */
.farin-wa-operator-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    background: #f5f5f5;
}

.farin-wa-operator-status.online {
    color: #00c853;
    background: #e8f5e9;
}

.farin-wa-operator-status.away {
    color: #f57c00;
    background: #fff3e0;
}

.farin-wa-operator-status.offline {
    color: #757575;
    background: #f5f5f5;
}

.farin-wa-operator-status .status-icon {
    font-size: 10px;
}

/* ========================================
   Footer
======================================== */
.farin-wa-footer {
    background: #fff;
    padding: 12px 15px;
    border-top: 1px solid #eee;
}

.farin-wa-footer p {
    margin: 0;
    font-size: 11px;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 768px) {
    .farin-wa-button {
        width: 56px;
        height: 56px;
    }
    
    .farin-wa-button img {
        width: 26px;
        height: 26px;
    }
    
    .farin-wa-box {
        width: calc(100vw - 30px);
        max-width: 360px;
        max-height: 70vh;
    }
}

@media (max-width: 480px) {
    .farin-wa-box {
        border-radius: 12px;
    }
    
    .farin-wa-header {
        padding: 15px;
    }
    
    .farin-wa-body {
        padding: 12px;
    }
    
    .farin-wa-operator {
        padding: 10px;
    }
    
    .farin-wa-operator-avatar img,
    .farin-wa-no-avatar {
        width: 42px;
        height: 42px;
    }
}

/* ========================================
   RTL Support
======================================== */
[dir="rtl"] .farin-wa-operator:hover {
    transform: translateX(3px);
}

/* ========================================
   Dark Mode Support
======================================== */
@media (prefers-color-scheme: dark) {
    .farin-wa-box {
        background: #1e1e1e;
    }
    
    .farin-wa-body {
        background: #2d2d2d;
    }
    
    .farin-wa-welcome,
    .farin-wa-operator {
        background: #3d3d3d;
    }
    
    .farin-wa-welcome .welcome-text,
    .farin-wa-operator-name {
        color: #e0e0e0;
    }
    
    .farin-wa-operator-position,
    .farin-wa-department-title {
        color: #aaa;
    }
    
    .farin-wa-footer {
        background: #1e1e1e;
        border-top-color: #3d3d3d;
    }
}

/* ========================================
   Widget Style Variants
======================================== */

/* Rectangle style */
.farin-wa-style-rectangle .farin-wa-button {
    border-radius: 25px;
    width: auto;
    padding: 0 20px;
    height: 50px;
}

.farin-wa-style-rectangle .farin-wa-button-text {
    display: inline;
    margin-right: 8px;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
}

/* Minimal style */
.farin-wa-style-minimal .farin-wa-button {
    box-shadow: none;
    background: transparent;
}

.farin-wa-style-minimal .farin-wa-button svg {
    fill: var(--farin-wa-button-color);
}

.farin-wa-style-minimal .farin-wa-pulse {
    display: none;
}

.farin-wa-style-minimal .farin-wa-button:hover {
    transform: scale(1.1);
    box-shadow: none;
}

/* Hide button text by default */
.farin-wa-button-text {
    display: none;
}

/* ========================================
   Accessibility
======================================== */
.farin-wa-button:focus,
.farin-wa-operator:focus,
.farin-wa-close:focus {
    outline: 3px solid var(--farin-wa-header-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .farin-wa-button,
    .farin-wa-operator,
    .farin-wa-pulse {
        animation: none !important;
        transition: none !important;
    }
}
