/**
 * Chat Widget Styles
 * Philippe Argento Webshop
 */

/* ============================================
   CHAT WIDGET CONTAINER
   ============================================ */

.chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
    z-index: 99998;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   TOGGLE BUTTON
   ============================================ */

.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C5B8A5 0%, #B8A994 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(197, 184, 165, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(197, 184, 165, 0.5);
    background: linear-gradient(135deg, #D4C9B9 0%, #C5B8A5 100%);
}

.chat-toggle-btn .chat-icon,
.chat-toggle-btn .chat-close-icon {
    color: #fff;
    font-size: 1.4rem;
    transition: all 0.3s ease;
}

.chat-toggle-btn .chat-close-icon {
    position: absolute;
}

.chat-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #dc3545;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================
   CHAT WINDOW
   ============================================ */

.chat-window {
    position: absolute;
    bottom: 70px;
    left: 0;
    right: auto;
    width: 360px;
    max-height: 520px;
    background: #FAFAF8;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(31, 30, 28, 0.12);
    border: 1px solid rgba(197, 184, 165, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

/* ============================================
   CHAT HEADER
   ============================================ */

.chat-header {
    background: linear-gradient(135deg, #C5B8A5 0%, #B8A994 100%);
    color: #1F1E1C;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(197, 184, 165, 0.3);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #C5B8A5;
}

.chat-status.online {
    background: #28a745;
}

.chat-status.offline {
    background: #6c757d;
}

.chat-header-text h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-header-text p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.8;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-actions button {
    background: rgba(31, 30, 28, 0.1);
    border: none;
    color: #1F1E1C;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-header-actions button:hover {
    background: rgba(31, 30, 28, 0.15);
}

/* ============================================
   CHAT BODY
   ============================================ */

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 300px;
    max-height: 380px;
    background: #f8f9fa;
}

/* ============================================
   WELCOME SCREEN
   ============================================ */

.chat-welcome {
    text-align: center;
    padding: 10px 0;
}

.chat-welcome-avatar {
    width: 100px;
    height: auto;
    margin: 0 auto 20px;
}

.chat-welcome-avatar img {
    width: 100%;
    height: auto;
}

.chat-welcome h3 {
    margin: 0 0 10px;
    font-size: 1.35rem;
    font-family: 'Playfair Display', serif;
    font-weight: 500;
    color: #1F1E1C;
    letter-spacing: 0.02em;
}

.chat-welcome p {
    margin: 0 0 24px;
    color: #6B6B6B;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Quick Actions */
.chat-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.chat-quick-btn {
    background: #fff;
    border: 1px solid #E8E4DF;
    border-radius: 10px;
    padding: 14px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.chat-quick-btn:hover {
    border-color: #C5B8A5;
    background: #FDFCFB;
    transform: translateY(-1px);
}

.chat-quick-btn i {
    font-size: 1.2rem;
    color: #1F1E1C;
}

.chat-quick-btn span {
    font-size: 0.8rem;
    color: #4A4A4A;
    font-weight: 500;
}

/* Guest Form (compact inline) */
.chat-guest-form {
    background: #f8f9fa;
    border: 1px solid #E8E4DF;
    border-radius: 10px;
    padding: 12px;
    margin-top: 8px;
}

.guest-form-hint {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 6px;
}

.guest-form-hint i {
    color: #C5B8A5;
}

.chat-start-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-form-row {
    display: flex;
    gap: 8px;
}

.chat-form-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #E8E4DF;
    border-radius: 8px;
    font-size: 0.85rem;
    background: #fff;
    transition: all 0.2s ease;
}

.chat-form-row input:focus {
    outline: none;
    border-color: #C5B8A5;
    box-shadow: 0 0 0 2px rgba(197, 184, 165, 0.15);
}

.chat-form-row input::placeholder {
    color: #9B9B9B;
}

.chat-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #E8E4DF;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    transition: all 0.2s ease;
}

.chat-form-group input:focus {
    outline: none;
    border-color: #C5B8A5;
    box-shadow: 0 0 0 3px rgba(197, 184, 165, 0.15);
}

.chat-form-group input::placeholder {
    color: #9B9B9B;
}

/* ============================================
   MESSAGES
   ============================================ */

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.customer {
    align-self: flex-end;
}

.chat-message.operator,
.chat-message.bot {
    align-self: flex-start;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.customer .chat-message-content {
    background: linear-gradient(135deg, #1e2615 0%, #2a3520 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.operator .chat-message-content,
.chat-message.bot .chat-message-content {
    background: #fff;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.chat-message.system {
    align-self: center;
}

.chat-message.system .chat-message-content {
    background: transparent;
    color: #6c757d;
    font-size: 0.8rem;
    padding: 8px 12px;
    text-align: center;
}

.chat-message-time {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.customer .chat-message-time {
    text-align: right;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e9ecef;
    width: fit-content;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* New Typing Indicator (with text) */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e9ecef;
    width: fit-content;
    margin-top: 8px;
    animation: fadeIn 0.3s ease;
}

.chat-typing-indicator .typing-text {
    font-size: 0.85rem;
    color: #6c757d;
    font-style: italic;
}

.chat-typing-indicator .typing-dots {
    display: flex;
    align-items: center;
    gap: 3px;
}

.chat-typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #C5B8A5;
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out;
}

.chat-typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.chat-typing-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-indicator .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ============================================
   RATING SCREEN
   ============================================ */

.chat-rating {
    text-align: center;
    padding: 20px 0;
}

.chat-rating h4 {
    margin: 0 0 8px;
    color: #1e2615;
}

.chat-rating p {
    margin: 0 0 20px;
    color: #6c757d;
    font-size: 0.9rem;
}

.chat-rating-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.chat-star {
    background: transparent;
    border: none;
    font-size: 1.75rem;
    color: #dee2e6;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
}

.chat-star:hover,
.chat-star.active {
    color: #ffc107;
    transform: scale(1.1);
}

.chat-star.active i {
    font-weight: bold;
}

.chat-rating-comment {
    width: 100%;
    padding: 12px;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    resize: none;
    height: 80px;
    margin-bottom: 12px;
    font-family: inherit;
}

.chat-rating-comment:focus {
    outline: none;
    border-color: #1e2615;
}

.chat-rating-submit {
    background: #1e2615;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.chat-rating-submit:hover {
    background: #2a3520;
}

.chat-rating-skip {
    background: transparent;
    border: none;
    color: #6c757d;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    display: block;
    margin: 8px auto 0;
}

.chat-rating-skip:hover {
    color: #495057;
}

/* ============================================
   CHAT FOOTER
   ============================================ */

.chat-footer {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e9ecef;
}

.chat-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 4px;
}

.chat-attach-btn,
.chat-send-btn {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-attach-btn {
    color: #6c757d;
}

.chat-attach-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.chat-send-btn {
    background: #1e2615;
    color: #fff;
}

.chat-send-btn:hover {
    background: #2a3520;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 0.95rem;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: #adb5bd;
}

.chat-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 4px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.chat-end-btn {
    color: #dc3545;
}

.chat-end-btn:hover {
    background: #fff5f5;
    color: #c82333;
}

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

/* Chat widget elrejtése mobilon */
@media (max-width: 768px) {
    .chat-widget {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .chat-widget {
        display: none !important;
        bottom: 16px;
        left: 16px;
        right: auto;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: none;
        border-radius: 0;
        z-index: 99999;
    }

    .chat-body {
        max-height: none;
        flex: 1;
    }

    .chat-toggle-btn {
        width: 56px;
        height: 56px;
    }

    .chat-quick-actions {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   PRODUCT CARD IN CHAT WIDGET
   ============================================ */

.widget-product-card {
    width: 100%;
    max-width: 260px;
}

.widget-product-card .product-intro {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.product-card-inner {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.widget-product-card .product-card-image {
    position: relative;
    height: 140px;
    background: #f8f9fa;
}

.widget-product-card .product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.widget-product-card .discount-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #dc3545;
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.widget-product-card .product-card-body {
    padding: 12px;
}

.widget-product-card .product-card-title {
    margin: 0 0 6px 0;
    font-size: 0.85rem;
    color: #1F1E1C;
    line-height: 1.3;
    font-weight: 600;
}

.widget-product-card .product-card-price {
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1F1E1C;
}

.widget-product-card .product-card-price .price-old {
    font-size: 0.8rem;
    text-decoration: line-through;
    color: #6c757d;
    font-weight: normal;
    margin-right: 6px;
}

.widget-product-card .product-card-price .price-new {
    color: #dc3545;
}

.widget-product-card .product-card-btn {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #C5B8A5 0%, #B8A994 100%);
    color: #1F1E1C;
    text-align: center;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.widget-product-card .product-card-btn:hover {
    background: linear-gradient(135deg, #D4C9B9 0%, #C5B8A5 100%);
    transform: translateY(-1px);
}

.widget-product-card .product-card-btn i {
    margin-right: 4px;
}

/* Operator message with product - adjust message bubble */
.chat-message.operator .chat-message-content:has(.widget-product-card),
.chat-message.bot .chat-message-content:has(.widget-product-card) {
    padding: 12px;
    background: #f8f9fa;
}

/* ============================================
   STATUS BAR (Business Hours Display)
   ============================================ */

.chat-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.75rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

.status-indicator.online .status-dot {
    background: #28a745;
}

.status-indicator.offline .status-dot {
    background: #6c757d;
    animation: none;
}

.status-text {
    font-weight: 600;
    color: #495057;
}

.status-indicator.online .status-text {
    color: #28a745;
}

.business-hours {
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 4px;
}

.business-hours i {
    font-size: 0.7rem;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Response Info (for offline mode) */
.chat-response-info {
    padding: 8px 16px;
    background: #fff3cd;
    border-bottom: 1px solid #ffeeba;
    font-size: 0.8rem;
    color: #856404;
    display: none;
}

.chat-response-info i {
    margin-right: 4px;
}

/* ============================================
   MESSAGE STATUS INDICATORS (Read Receipts)
   ============================================ */

.message-status {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

.message-status i {
    font-size: 0.7rem;
}

/* Status colors */
.chat-message.status-sending .message-status {
    color: #adb5bd;
}

.chat-message.status-sent .message-status {
    color: #6c757d;
}

.chat-message.status-delivered .message-status {
    color: #6c757d;
}

.chat-message.status-read .message-status {
    color: #007bff;
}

.chat-message.status-failed .message-status {
    color: #dc3545;
}

/* Sending animation */
.chat-message.status-sending .chat-message-content {
    opacity: 0.7;
}

/* Failed message styling */
.chat-message.status-failed .chat-message-content {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%) !important;
}

/* Retry button */
.message-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-retry-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   FALLBACK STATE (API Error)
   ============================================ */

.chat-fallback-message {
    text-align: center;
    padding: 30px 20px;
}

.chat-fallback-message i {
    font-size: 3rem;
    color: #ffc107;
    margin-bottom: 16px;
    display: block;
}

.chat-fallback-message h4 {
    margin: 0 0 12px;
    color: #495057;
    font-size: 1.1rem;
}

.chat-fallback-message p {
    margin: 0 0 16px;
    color: #6c757d;
    font-size: 0.9rem;
}

.fallback-email {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #C5B8A5 0%, #B8A994 100%);
    color: #1F1E1C;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.fallback-email:hover {
    background: linear-gradient(135deg, #D4C9B9 0%, #C5B8A5 100%);
    transform: translateY(-1px);
}

/* ============================================
   QUICK ACTIONS ENHANCED
   ============================================ */

.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.chat-quick-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    background: #fff;
    border: 1px solid #E8E4DF;
    border-radius: 10px;
    padding: 12px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
    font-size: 0.75rem;
}

.chat-quick-btn:hover {
    border-color: #C5B8A5;
    background: #FDFCFB;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(197, 184, 165, 0.2);
}

.chat-quick-btn i {
    font-size: 1.1rem;
    color: #C5B8A5;
}

.chat-quick-btn span {
    font-size: 0.75rem;
    color: #4A4A4A;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

/* Special action buttons */
.chat-quick-btn[data-special="request_operator"] {
    border-color: #28a745;
    background: #f8fff8;
}

.chat-quick-btn[data-special="request_operator"] i {
    color: #28a745;
}

.chat-quick-btn[data-special="order_lookup"] {
    border-color: #17a2b8;
    background: #f8fdff;
}

.chat-quick-btn[data-special="order_lookup"] i {
    color: #17a2b8;
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    /* Future dark mode styles */
}

/* ============================================
   MOBILE RESPONSIVE ENHANCEMENTS
   ============================================ */

@media (max-width: 576px) {
    .chat-quick-btn {
        flex: 1 1 calc(50% - 4px);
        padding: 10px 8px;
    }

    .chat-quick-btn span {
        font-size: 0.7rem;
    }

    .chat-status-bar {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }
}
