/**
 * Frontend styles for WooCommerce Order Chat
 */

/* Main Chat Container */
.woc-customer-chat-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.woc-customer-chat-container h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 600;
}

/* No Orders State */
.woc-no-orders {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
}

.woc-no-orders p {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

.woc-no-orders .button {
    background: #0073aa;
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 4px;
    display: inline-block;
    font-weight: 500;
}

.woc-no-orders .button:hover {
    background: #005a87;
    color: white;
}

/* Chat Interface */
.woc-chat-interface {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .woc-chat-interface {
        grid-template-columns: 1fr;
    }
}

/* Order Selector */
.woc-order-selector {
    margin-bottom: 20px;
}

.woc-order-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.woc-order-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.woc-order-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

/* Chat Window */
.woc-chat-window {
    background: white;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.woc-chat-header {
    background: #0073aa;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.woc-order-info {
    display: flex;
    flex-direction: column;
}

.woc-order-number {
    font-weight: 600;
    font-size: 16px;
}

.woc-order-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.woc-chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.woc-admin-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.woc-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3232;
}

.woc-status-indicator.online {
    background: #46b450;
}

.woc-status-indicator.away {
    background: #ffb900;
}

/* Messages Container */
.woc-messages-container {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
}

.woc-welcome-message {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.woc-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.woc-message.customer {
    align-items: flex-end;
}

.woc-message.admin,
.woc-message.system {
    align-items: flex-start;
}

.woc-message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

.woc-message.customer .woc-message-bubble {
    background: #0073aa;
    color: white;
    border-bottom-right-radius: 4px;
}

.woc-message.admin .woc-message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e1e1e1;
    border-bottom-left-radius: 4px;
}

.woc-message.system .woc-message-bubble {
    background: #f0f0f0;
    color: #666;
    font-style: italic;
    text-align: center;
    border-radius: 12px;
    max-width: 80%;
    align-self: center;
}

.woc-message-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.woc-message-time {
    white-space: nowrap;
}

.woc-message-status {
    font-size: 10px;
}

/* Attachment Styles */
.woc-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-top: 8px;
}

.woc-message.admin .woc-attachment {
    background: #f5f5f5;
}

.woc-attachment-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 16px;
}

.woc-attachment-info {
    flex: 1;
    min-width: 0;
}

.woc-attachment-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.woc-attachment-size {
    font-size: 11px;
    opacity: 0.8;
}

.woc-attachment-download {
    color: inherit;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.2);
}

.woc-attachment-download:hover {
    background: rgba(255, 255, 255, 0.3);
    color: inherit;
}

/* Image Attachments */
.woc-attachment-image {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

/* Typing Indicator */
.woc-typing-indicator {
    padding: 10px 20px;
    font-size: 12px;
    color: #666;
    font-style: italic;
    background: #f0f0f0;
    border-top: 1px solid #e1e1e1;
}

.woc-typing-dots {
    display: inline-block;
    animation: woc-typing 1.4s infinite;
}

@keyframes woc-typing {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* Message Input */
.woc-message-input-container {
    background: white;
    border-top: 1px solid #e5e5e5;
    padding: 15px;
    position: relative;
}

.woc-message-input {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 8px;
    gap: 8px;
}

.woc-message-input textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    min-height: 20px;
    overflow-y: auto;
    outline: none;
}

.woc-message-input:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.woc-message-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.woc-attach-btn,
.woc-emoji-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 16px;
}

.woc-attach-btn:hover,
.woc-emoji-btn:hover {
    background: #f0f0f0;
    color: #0073aa;
    transform: scale(1.1);
}

.woc-attach-btn::before {
    content: "📎";
    font-size: 18px;
    display: block;
}

.woc-emoji-btn::before {
    content: "😊";
    font-size: 18px;
    display: block;
}

.woc-attach-btn.no-emoji::before {
    content: "📎";
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
}

.woc-emoji-btn.no-emoji::before {
    content: ":)";
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
}

.woc-attach-btn.no-emoji.simple::before {
    content: "+";
    font-size: 18px;
    font-weight: bold;
}

.woc-emoji-btn.no-emoji.simple::before {
    content: ":)";
    font-size: 14px;
}

.woc-send-btn {
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    min-width: 60px;
}

.woc-send-btn:hover {
    background: #005a87;
    transform: scale(1.02);
}

.woc-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Chat Rating */
.woc-chat-rating {
    padding: 20px;
    background: #f9f9f9;
    border-top: 1px solid #e1e1e1;
    text-align: center;
}

.woc-chat-rating h4 {
    margin: 0 0 15px 0;
    color: #333;
}

.woc-rating-stars {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
}

.woc-star {
    font-size: 24px;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s;
}

.woc-star:hover,
.woc-star.active {
    color: #ffb900;
}

.woc-chat-rating textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
    resize: vertical;
    min-height: 60px;
}

.woc-chat-rating .button {
    background: #0073aa;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Chat History */
.woc-chat-history {
    background: white;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
}

.woc-chat-history h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

.woc-history-item {
    padding: 12px;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.woc-history-item:hover {
    border-color: #0073aa;
    background: #f8f9fa;
}

.woc-history-order {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.woc-history-status {
    font-size: 12px;
    color: #666;
    display: flex;
    justify-content: space-between;
}

.woc-history-unread {
    background: #0073aa;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

/* Emoji Picker */
.woc-emoji-picker {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 10px;
    z-index: 1000;
    max-width: 300px;
    width: 90%;
}

.woc-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.woc-emoji {
    padding: 6px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 18px;
}

.woc-emoji:hover {
    background: #f0f0f0;
}

/* Notification Popup */
.woc-notification-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    max-width: 300px;
    animation: woc-slide-in 0.3s ease-out;
}

@keyframes woc-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.woc-notification-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.woc-notification-text {
    flex: 1;
    font-size: 14px;
}

.woc-notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
}

/* Loading States */
.woc-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #666;
}

.woc-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: woc-spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes woc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.woc-error {
    background: #dc3232;
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

.woc-success {
    background: #46b450;
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .woc-chat-container {
        margin: 10px;
        height: calc(100vh - 100px);
    }
    
    .woc-message-bubble {
        max-width: 85%;
    }
    
    .woc-message-input {
        padding: 6px;
        gap: 6px;
    }
    
    .woc-message-input textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 6px 8px;
    }
    
    .woc-message-actions {
        gap: 3px;
    }
    
    .woc-attach-btn,
    .woc-emoji-btn {
        width: 26px;
        height: 26px;
        font-size: 14px;
        padding: 4px;
    }
    
    .woc-send-btn {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 50px;
    }
    
    .woc-emoji-picker {
        max-width: 280px;
        width: 95%;
        bottom: 50px;
    }
    
    .woc-emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 480px) {
    .woc-chat-header {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .woc-messages-container {
        height: 250px;
        padding: 10px;
    }
    
    .woc-message-input {
        padding: 10px 15px;
    }
    
    .woc-message-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .woc-notification-popup {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Accessibility */
.woc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
.woc-send-btn:focus,
.woc-attach-btn:focus,
.woc-emoji-btn:focus,
.woc-order-select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .woc-message-bubble {
        border: 2px solid;
    }
    
    .woc-chat-window {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .woc-notification-popup {
        animation: none;
    }
    
    .woc-spinner {
        animation: none;
    }
    
    .woc-typing-dots {
        animation: none;
    }
}

/* Enhanced File Previews */
.woc-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin: 8px 0;
    transition: all 0.2s ease;
}

.woc-file-preview:hover {
    background: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.woc-file-preview.image-preview {
    flex-direction: column;
    align-items: flex-start;
    max-width: 250px;
}

.woc-preview-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.woc-preview-image:hover {
    transform: scale(1.02);
}

.woc-file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.woc-file-action {
    display: inline-block;
    padding: 4px 12px;
    background: #0073aa;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.woc-file-action:hover {
    background: #005a87;
    text-decoration: none;
}

/* Image Modal */
.woc-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
}

.woc-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    cursor: default;
}

.woc-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    z-index: 1;
    background: rgba(0, 0, 0, 0.5);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.woc-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.woc-modal-image {
    max-width: 100%;
    max-height: 70vh;
    display: block;
}

.woc-modal-caption {
    padding: 15px;
    font-weight: 500;
    color: #333;
    border-bottom: 1px solid #eee;
}

.woc-modal-actions {
    padding: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.woc-modal-download,
.woc-modal-open {
    padding: 8px 16px;
    background: #0073aa;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.woc-modal-download:hover,
.woc-modal-open:hover {
    background: #005a87;
    text-decoration: none;
}

/* External Links */
.woc-external-link {
    color: #0073aa;
    text-decoration: underline;
    word-break: break-all;
}

.woc-external-link:hover {
    color: #005a87;
    text-decoration: underline;
}

/* File Send Modal */
.woc-file-send-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.woc-file-send-modal .woc-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.woc-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.woc-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.woc-modal-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.woc-file-preview-container {
    margin-bottom: 20px;
}

.woc-message-with-file textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
}

.woc-message-with-file textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.woc-modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.woc-btn-cancel,
.woc-btn-send {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.woc-btn-cancel {
    background: #f5f5f5;
    color: #666;
}

.woc-btn-cancel:hover {
    background: #e8e8e8;
}

.woc-btn-send {
    background: #0073aa;
    color: white;
}

.woc-btn-send:hover {
    background: #005a87;
}

/* Success notifications */
.woc-notification-popup.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.woc-notification-popup.success .woc-notification-close {
    color: #155724;
}

.woc-notification-popup.success .woc-notification-close:hover {
    color: #0c3d1a;
}
