/**
 * Live Chat Widget Styles
 */

/* Chat Widget Button */
.chat-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ff5900 0%, #cc4700 100%);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(255, 89, 0, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(255, 89, 0, 0.6);
}

.chat-widget-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chat-widget-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
}

.chat-window.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #ff5900 0%, #cc4700 100%);
    color: white;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
}

.chat-agent-details h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.chat-agent-details p {
    margin: 0;
    font-size: 0.75rem;
    opacity: 0.9;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-end-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.chat-end-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.chat-close-btn:hover {
    opacity: 0.8;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f9fafb;
}

.chat-message {
    display: flex;
    margin-bottom: 1rem;
    animation: messageIn 0.2s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.customer {
    justify-content: flex-end;
}

.chat-message-content {
    max-width: 70%;
    padding: 0.875rem 1.125rem;
    border-radius: 16px;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.chat-message.agent .chat-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-message.customer .chat-message-content {
    background: linear-gradient(135deg, #ff5900 0%, #cc4700 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.system .chat-message-content {
    max-width: 100%;
    background: #e0f2fe;
    color: #0369a1;
    text-align: center;
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
}

.chat-message-time {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    text-align: right;
}

.chat-message.agent .chat-message-time {
    text-align: left;
}

/* Chat Input */
.chat-input-area {
    padding: 1.25rem;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: #ff5900;
}

.chat-send-btn {
    background: linear-gradient(135deg, #ff5900 0%, #cc4700 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Chat Welcome */
.chat-welcome {
    text-align: center;
    padding: 2rem 1.5rem;
}

.chat-welcome h3 {
    color: #1f2937;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.chat-welcome p {
    color: #6b7280;
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

.chat-presession {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.chat-precopy {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.chat-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-form-group label {
    font-size: 0.85rem;
    color: #4b5563;
    font-weight: 600;
}

.chat-form-group input,
.chat-form-group textarea {
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}

.chat-form-group input:focus,
.chat-form-group textarea:focus {
    outline: none;
    border-color: #ff5900;
    box-shadow: 0 0 0 3px rgba(255, 89, 0, 0.1);
}

.chat-start-btn {
    background: linear-gradient(135deg, #ff5900 0%, #cc4700 100%);
    border: none;
    color: #fff;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 89, 0, 0.25);
}

.chat-ticket-link {
    text-align: center;
    color: #ff5900;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
}

.chat-ticket-link:hover {
    text-decoration: underline;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.375rem;
    padding: 0.875rem 1.125rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }
    
    .chat-widget-button {
        width: 56px;
        height: 56px;
        bottom: 15px;
        right: 15px;
    }
}

/* Support Ticket Styles */
.ticket-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.ticket-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #ff5900;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.ticket-number {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #ff5900;
}

.ticket-status {
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: capitalize;
}

.ticket-status.open {
    background: #dbeafe;
    color: #1e40af;
}

.ticket-status.in_progress {
    background: #fef3c7;
    color: #92400e;
}

.ticket-status.resolved {
    background: #dcfce7;
    color: #166534;
}

.ticket-status.closed {
    background: #f3f4f6;
    color: #4b5563;
}

.chat-ticket-cta {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #fee2d5;
    border-radius: 12px;
    background: #fff7ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.chat-ticket-cta p {
    margin: 0;
    color: #7c2d12;
    font-size: 0.9rem;
}

.chat-ticket-btn {
    background: #ff5900;
    color: #fff;
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

#chatStatus[data-state="waiting"] { opacity: 0.9; }
#chatStatus[data-state="error"],
#chatStatus[data-state="ended"] { color: #fee2e2; }

.ticket-subject {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.ticket-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.ticket-category {
    padding: 0.25rem 0.75rem;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #4b5563;
    text-transform: capitalize;
}

/* FAQ Styles */
.faq-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.faq-question {
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #1f2937;
    transition: background 0.2s;
}

.faq-question:hover {
    background: #f9fafb;
}

.faq-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.faq-item.open .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1.5rem;
    color: #4b5563;
    line-height: 1.7;
}

.faq-item.open .faq-answer {
    max-height: 500px;
    padding: 0 1.5rem 1.25rem;
}

.faq-helpful {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.875rem;
}

.faq-helpful-btn {
    background: transparent;
    border: 1px solid #d1d5db;
    padding: 0.375rem 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.2s;
}

.faq-helpful-btn:hover {
    border-color: #ff5900;
    color: #ff5900;
}
