/* Chat Container */
.chat-container {
    display: flex;
    height: calc(100vh - 70px);
    background: #f8f9fa;
}

/* Chat Sidebar */
.chat-sidebar {
    width: 350px;
    background: white;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

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

.chat-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.btn-new-chat {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-new-chat:hover {
    background: #0056b3;
}

.chat-search {
    padding: 15px 20px;
    position: relative;
}

.chat-search input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

.chat-search i {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.3s;
    position: relative;
}

.chat-item:hover {
    background: #f8f9fa;
}

.chat-item.active {
    background: #e3f2fd;
    border-right: 3px solid #007bff;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.chat-participant {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.chat-time {
    font-size: 12px;
    color: #666;
}

.chat-preview {
    color: #666;
    font-size: 13px;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-status {
    font-size: 12px;
    color: #666;
}

.unread-badge {
    background: #007bff;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-welcome {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.welcome-content {
    text-align: center;
    color: #666;
}

.welcome-content i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #ddd;
}

.welcome-content h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.welcome-content p {
    margin: 0;
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin: 0 8px;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

/* Product chip (system message product context) */
.product-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 8px 0;
    padding: 8px;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    background: #fdfdfd;
}
.product-chip-img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #eee;
    flex-shrink: 0;
}
.product-chip-body {
    min-width: 0;
    flex: 1;
}
.product-chip-title {
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-chip-price {
    color: #00cc99;
    font-weight: 800;
    font-size: .92rem;
}
.product-chip-vendor {
    color: #666;
    font-weight: 600;
    font-size: .85rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-chip-link {
    text-decoration: none;
    border: 1px solid #00cc99;
    color: #00cc99;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
}

.message.sent .message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-text {
    margin: 0;
    word-wrap: break-word;
    line-height: 1.4;
}

.message-time {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255,255,255,0.7);
}

.message.reactions {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.reaction {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.3s;
}

.reaction:hover {
    background: #e0e0e0;
}

.message-attachments {
    margin-top: 8px;
}

.attachment {
    display: inline-block;
    margin: 2px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    font-size: 12px;
    transition: background 0.3s;
}

.attachment:hover {
    background: #e9ecef;
}

.attachment i {
    margin-right: 5px;
}

/* Image Attachments */
.attachment-image {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
}

.attachment-preview {
    width: 100%;
    max-width: 300px;
    max-height: 200px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: block;
}

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

.attachment-info {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.attachment-name {
    font-size: 12px;
    color: #666;
    flex: 1;
    margin-right: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-download {
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.attachment-download:hover {
    background: #f8f9fa;
}

.attachment-size {
    font-size: 11px;
    color: #999;
    margin-left: 5px;
}

.attachment-error {
    padding: 20px;
    text-align: center;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.attachment-error i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.attachment-error span {
    font-size: 12px;
    display: block;
}

/* Message Input */
.message-input-container {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 15px 20px;
}

.message-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.btn-attach {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.btn-attach:hover {
    background: #f0f0f0;
}

.message-textarea {
    flex: 1;
    position: relative;
}

.message-textarea textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    min-height: 40px;
}

.message-textarea textarea:focus {
    border-color: #007bff;
}

.btn-send {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-send:hover {
    background: #0056b3;
}

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

.typing-indicator {
    padding: 5px 15px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 20px;
}

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

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #007bff;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Support Ticket Styles */
.support-ticket {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ticket-number {
    font-weight: 600;
    color: #007bff;
}

.ticket-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.ticket-status.open {
    background: #d4edda;
    color: #155724;
}

.ticket-status.in_progress {
    background: #fff3cd;
    color: #856404;
}

.ticket-status.resolved {
    background: #d1ecf1;
    color: #0c5460;
}

.ticket-status.closed {
    background: #f8d7da;
    color: #721c24;
}

.ticket-priority {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.ticket-priority.high {
    color: #dc3545;
}

.ticket-priority.urgent {
    color: #dc3545;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 60px);
    }
    
    .chat-sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .chat-main {
        height: calc(100% - 200px);
    }
    
    .message-content {
        max-width: 85%;
    }
}

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

.loading i {
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

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

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #ddd;
}

.empty-state h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Support Dashboard Styles */
.support-dashboard {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-content h3 {
    margin: 0;
    font-size: 2rem;
    color: #333;
}

.stat-content p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.support-controls {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filters {
    display: flex;
    gap: 15px;
}

.filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.actions {
    display: flex;
    gap: 10px;
}

.tickets-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

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

.tickets-header h2 {
    margin: 0;
    color: #333;
}

.tickets-count {
    color: #666;
    font-size: 14px;
}

.tickets-list {
    max-height: 600px;
    overflow-y: auto;
}

.ticket-details {
    max-height: 70vh;
    overflow-y: auto;
}

.ticket-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-row label {
    font-weight: 600;
    color: #333;
    margin: 0;
}

.info-row span {
    color: #666;
}

.ticket-description {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.ticket-description h4 {
    margin: 0 0 10px 0;
    color: #333;
}

.ticket-description p {
    margin: 0;
    color: #666;
    line-height: 1.6;
}

.ticket-actions {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.action-group {
    margin-bottom: 15px;
}

.action-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.action-group select,
.action-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

.action-group textarea {
    resize: vertical;
    min-height: 80px;
}

.ticket-chat {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    background: #f8f9fa;
}

/* Modal Large */
.modal-content.large {
    max-width: 800px;
    width: 95%;
}

/* Priority Colors */
.ticket-priority.urgent {
    color: #dc3545;
    font-weight: 600;
}

.ticket-priority.high {
    color: #fd7e14;
    font-weight: 600;
}

.ticket-priority.medium {
    color: #ffc107;
    font-weight: 600;
}

.ticket-priority.low {
    color: #28a745;
    font-weight: 600;
}

/* Status Colors */
.ticket-status.open {
    background: #d4edda;
    color: #155724;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.ticket-status.in_progress {
    background: #fff3cd;
    color: #856404;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.ticket-status.resolved {
    background: #d1ecf1;
    color: #0c5460;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.ticket-status.closed {
    background: #f8d7da;
    color: #721c24;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Support Ticket Chat Styles */
.ticket-chat-section {
    margin-top: 20px;
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

.ticket-chat-section h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.chat-container {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    height: 300px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    max-height: 200px;
}

.message-bubble {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
    flex-shrink: 0;
}

.message-sent .message-avatar {
    background: #28a745;
    order: 2;
    margin-right: 0;
    margin-left: 10px;
}

.message-content {
    flex: 1;
    background: white;
    padding: 10px 15px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-sent .message-content {
    background: #007bff;
    color: white;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.message-sent .message-header {
    color: rgba(255,255,255,0.8);
}

.message-text {
    line-height: 1.4;
    word-wrap: break-word;
}

.message-attachments {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.message-sent .message-attachments {
    border-top-color: rgba(255,255,255,0.2);
}

.attachment-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 14px;
}

.attachment-item i {
    margin-right: 8px;
    color: #6c757d;
}

.message-sent .attachment-item i {
    color: rgba(255,255,255,0.7);
}

.attachment-item a {
    color: #007bff;
    text-decoration: none;
}

.message-sent .attachment-item a {
    color: #fff;
}

.chat-input {
    padding: 15px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.chat-input .input-group {
    display: flex;
    gap: 10px;
}

.chat-input .form-control {
    flex: 1;
    border: 1px solid #ced4da;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 14px;
}

.chat-input .form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.chat-input .btn {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s ease-out;
}

.toast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.toast-header strong {
    color: #495057;
    font-size: 14px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: #495057;
}

.toast-body {
    padding: 12px 16px;
    color: #495057;
    font-size: 14px;
    line-height: 1.4;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
