body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    height: 100vh;
    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.06), 0 2px 5px 0 rgba(0, 0, 0, 0.06);
    background-color: #fff;
    overflow: hidden;
}

@media (min-width: 1600px) {
    .container {
        height: 95vh;
        max-height: 1024px;
        border-radius: 4px;
    }
}

.sidebar {
    flex: 0 0 30%;
    max-width: 450px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ddd;
    background-color: #fff;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
    background-color: #e5ddd5;
}

.app-container {
    display: flex;
    height: 100vh;
}
.sidebar-header {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ddd;
}
.sidebar-header-info {
    margin-left: 15px;
}
.sidebar-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}
.sidebar-header-info p {
    margin: 0;
    font-size: 13px;
    color: #667781;
}
.chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
}
.chat-list li {
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid #0b5345;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}
.chat-list li.active, .chat-list li:hover {
    background: #25d366;
    color: #075e54;
}
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ece5dd;
}
.chat-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    background-color: #f0f2f5;
    border-bottom: 1px solid #ddd;
}
.chat-header h3 {
    margin: 0;
    margin-left: 15px;
    font-size: 16px;
    font-weight: 500;
}
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.welcome-message {
    margin: auto;
    text-align: center;
    color: #4a4a4a;
    background-color: #f7f9fa;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
}
.message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    max-width: 80%;
}
.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.message.received {
    align-self: flex-start;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 12px;
    vertical-align: middle;
    object-fit: cover;
}
.chat-list li span {
    flex: 1;
}
.sidebar-chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background-color 0.2s ease;
}
.sidebar-chat-item:hover {
    background-color: #f0f2f5;
}
.sidebar-chat-item.active {
    background-color: #e9edef;
}
.sidebar-chat-item .avatar {
    width: 39px;
    height: 39px;
}
.chat-item-content {
    flex: 1;
    margin-left: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.chat-item-line-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.sidebar-chat-name {
    font-size: 16px;
    font-weight: 500;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.sidebar-chat-time {
    font-size: 12px;
    color: #667781;
    margin-left: 10px;
}
.chat-item-line-2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #667781;
    white-space: nowrap;
    margin-top: 4px;
}
.chat-item-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}
.unread-badge {
    background-color: #25d366;
    color: white;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 10px;
    padding: 0 0px;
    flex-shrink: 0;
}
.header-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 12px;
    vertical-align: middle;
    object-fit: cover;
    display: inline-block;
}
.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
    background: #ece5dd;
}
.message.sent .message-avatar {
    margin-left: 8px;
    margin-right: 0;
}
.message-bubble {
    padding: 8px 12px 10px 12px;
    border-radius: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    color: #111b21;
    max-width: 70%;
    padding-right: 60px;
}
.message.sent .message-bubble {
    background-color: #dcf8c6;
}

/* Specific color for AI Agent messages */
.message.sent .message-bubble.agent-message {
    background-color: #e1f5fe; /* A light blue for the agent */
}

.message.received .message-bubble {
    background-color: #fff;
}
.message-bubble-container {
    display: flex;
    flex-direction: column;
}

/* Trigger AI icon styling */
.trigger-ai-icon {
    align-self: flex-start !important;
    margin-top: 4px !important;
    margin-left: 8px !important;
    font-size: 14px !important;
    opacity: 0.7;
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.trigger-ai-icon:hover {
    opacity: 1 !important;
    background-color: #e3f2fd !important;
}

.trigger-ai-icon svg {
    width: 16px;
    height: 16px;
}

/* Spinning animation for loader */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.message-sender {
    font-size: 0.8em;
    color: #128c7e;
    margin-bottom: 8px;
    font-weight: bold;
}
.message-time {
    font-size: 8px;
    color: #667781a6;
    position: absolute;
    bottom: 4px;
    right: 10px;
    white-space: nowrap;
}

.chat-input {
    background: #f0f0f0;
    padding: 20px;
    border-top: 1px solid #ddd;
}

.message-form {
    display: flex;
    gap: 10px;
}

.message-form input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: .9em;
    background: #f7f9fa;
    outline: none;
}

.message-form button {
    background: #25d366;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.message-form button:hover {
    background: #128c7e;
}

@media (max-width: 700px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: 200px;
        flex-shrink: 0;
    }
    .chat-window {
        height: calc(100vh - 200px);
    }
    
    /* Mobile media adjustments */
    .media-preview {
        max-width: 150px;
        max-height: 150px;
    }
    
    .audio-container,
    .document-container {
        min-width: 150px;
        padding: 8px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

/* Search Container */
.search-container {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 12px;
}

.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 9px 60px 9px 41px;
    border: none;
    border-radius: 8px;
    background-color: #f0f2f5;
    font-size: 14px;
}

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

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #667781;
}

/* Hide conversations that don't match search */
.chat-item-hidden {
    display: none !important;
}

/* Highlight search matches */
.search-highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
}

/* No results message */
.no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.sidebar-chat-list {
    flex: 1;
    overflow-y: auto;
    background-color: #fff;
} 

ul#chat-list {
    padding: 0;
    margin: 0;
}

/* Add transitions for smoother interactions */
.sidebar-chat-list li, .message-form button, .search-input {
    transition: background-color 0.3s ease, box-shadow 0.2s ease;
}

/* Hover effect for chat list items */
.sidebar-chat-list li:hover {
    background-color: #f0f2f5;
    cursor: pointer;
}

.sidebar-chat-list li.active {
    background-color: #e9ecef;
}

/* Focus effect for search and message inputs */
.search-input:focus, #message-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

/* Style and hover effect for the send button */
.message-form button {
    background-color: #1877f2;
    transition: background-color 0.3s ease;
    height: 40px;
}

.message-form button svg {
    height: 18px;
}

.message-form button:hover:not(:disabled) {
    background-color: #166fe5;
}

/* Animation for new messages */
@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: fadeInSlideUp 0.4s ease-out;
}

.message-bubble.sent {
    background-color: #dcf8c6;
    align-self: flex-end;
}
.message-bubble.agent {
    background-color: #cfe8fc; /* Light blue for agent messages */
    align-self: flex-end;
}
.message-bubble.received {
    background-color: #fff;
    align-self: flex-start;
}
.message-bubble .timestamp {
    /* ... existing code ... */
}

/* Styles for the n8n toggle switch in the header */
.n8n-toggle-container {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.n8n-toggle-container span {
    font-size: 14px;
    color: #666;
}

/* Re-using the admin panel switch style */
.switch {
    position: relative;
    display: inline-block;
    width: 44px; /* Smaller switch */
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.switch span:not(.contact-name) {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.admin-container .switch span:not(.contact-name) {

    top: 10px;
}

.switch span:not(.contact-name):before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + span:not(.contact-name) {
    background-color: #25d366; /* WhatsApp Green */
}

input:checked + span:not(.contact-name):before {
    transform: translateX(20px);
}

.chat-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
}

.chat-header-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.n8n-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4a4a4a;
}

.message-bubble.agent-message {
    background: linear-gradient(135deg, #1976d2 60%, #42a5f5 100%);
    color: #fff;
    border: none;
 
}

.sidebar-collapsed {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    transition: width 0.3s, min-width 0.3s, flex-basis 0.3s;
    flex: 0 0 0 !important;
}
.sidebar-toggle {
    position: fixed;
    top: 8px;
    left: 15px;
    z-index: 2000;
    background: #fff;
    border: none;
    font-size: 28px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

@media (min-width: 701px) {
    .sidebar-toggle {
        right: unset !important;
        position: absolute;
        left: 13px;
        bottom: 49px;
        top: unset !important;
    }
}

@media (max-width: 700px) {
    .sidebar {
        display: none;
    }
    .sidebar.sidebar-collapsed {
        display: block;
        width: 100vw;
        min-width: 0;
        max-width: 100vw;
        position: absolute;
        z-index: 1000;
        left: 0;
        top: 0;
        height: 100vh;
        background: #fff;
        box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    }
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
}

.file-preview {
  display: flex;
  align-items: center;
  margin-right: 8px;
  background: #f7f7f7;
  border-radius: 4px;
  padding: 2px 8px 2px 2px;
  max-width: 200px;
  min-width: 0;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.file-preview img {
  max-width: 32px;
  max-height: 32px;
  border-radius: 3px;
  margin-right: 6px;
}
.file-preview .file-icon {
  font-size: 20px;
  margin-right: 6px;
  display: flex;
  align-items: center;
}

.file-preview .file-icon svg {
  width: 20px;
  height: 20px;
}

.file-preview .file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
  margin-right: 6px;
}
.file-preview .remove-file-btn {
  background: none;
  border: none;
  color: #d32f2f;
  font-size: 18px;
  cursor: pointer;
  margin-left: 2px;
  padding: 0 2px;
  line-height: 1;
}

/* Enhanced Media Styling */
.media-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.media-caption {
    font-size: 14px;
    line-height: 1.4;
    color: inherit;
    word-wrap: break-word;
    margin-top: 4px;
}

.text-content {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Audio Container */
.audio-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    min-width: 200px;
}

.audio-container svg {
    width: 20px;
    height: 20px;
    color: #666;
    flex-shrink: 0;
}

.audio-player {
    flex: 1;
    height: 32px;
}

/* Document Container */
.document-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    min-width: 200px;
}

.document-container svg {
    width: 24px;
    height: 24px;
    color: #666;
    flex-shrink: 0;
}

.document-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.document-name {
    font-size: 14px;
    font-weight: 500;
    color: inherit;
    word-break: break-word;
}

.download-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
    align-self: flex-start;
}

.download-btn:hover {
    background-color: rgba(0,0,0,0.1);
}

.download-btn svg {
    width: 16px;
    height: 16px;
    color: #666;
}

/* Message bubble group spacing */
.message + .message {
    margin-top: 14px;
}

.avatar.message-avatar {
    width: 38px;
    height: 38px;
    margin-right: 10px;
    margin-bottom: 2px;
}

.message-bubble {
    max-width: 60vw;
    line-height: 1.6;
    font-size: 15px;
    word-break: break-word;
    margin-bottom: 0;
    padding: 10px 14px;
}

.message-time {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    text-align: right;
    position: static;
}

.sidebar {
    max-width: 320px;
    min-width: 220px;
    width: 25vw;
    transition: width 0.3s;
}
.sidebar.sidebar-collapsed {
    width: 0 !important;
    min-width: 0 !important;
}

.n8n-toggle-container .switch input:checked + span {
    background-color: #25d366;
}
.n8n-toggle-container .switch input:not(:checked) + span {
    background-color: #f44336;
}
.n8n-toggle-container .ai-status {
    font-weight: bold;
    margin-left: 8px;
}

.send-btn {
    background: #25d366;
    border: none;
    border-radius: 50%;
    width: 66px;
    height: 40px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-left: 8px;
    transition: background 0.2s;
}
.send-btn:hover {
    background: #128c7e;
}
.send-btn svg {
    width: 22px;
    height: 22px;
}

@media (max-width: 700px) {
    .sidebar {
        display: none;
    }
    .sidebar.sidebar-collapsed {
        display: block;
        width: 100vw;
        min-width: 0;
        max-width: 100vw;
        position: absolute;
        z-index: 1000;
        left: 0;
        top: 0;
        height: 100vh;
        background: #fff;
        box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    }
    .main-content {
        width: 100vw;
    }
    .message-bubble {
        max-width: 85vw;
    }
}

.load-more-btn {
  display: block;
  margin: 16px auto 8px auto;
  padding: 8px 24px;
  background: #075e54;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(7,94,84,0.08);
}
.load-more-btn:hover, .load-more-btn:focus {
  background: #128c7e;
  outline: none;
}
.load-more-btn:disabled {
  background: #bdbdbd;
  color: #fff;
  cursor: not-allowed;
}
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-top: 2px solid #128c7e;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin {
  0% { transform: rotate(0deg);}
  100% { transform: rotate(360deg);}
}

/* Desktop/Default: collapse sidebar */
@media (min-width: 701px) {
    .sidebar.sidebar-collapsed {
        width: 0 !important;
        min-width: 0 !important;
        overflow: hidden;
        transition: width 0.3s, min-width 0.3s, flex-basis 0.3s;
        flex: 0 0 0 !important;
    }
}

/* Mobile: overlay sidebar */
@media (max-width: 700px) {
    .sidebar {
        display: none;
    }
    .sidebar.sidebar-collapsed {
        display: block;
        width: 100vw!important;
        min-width: 0;
        max-width: 100vw;
        position: absolute;
        z-index: 1000;
        left: 0;
        top: 0;
        height: 100vh;
        background: #fff;
        box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    }
}