/* Chat container styles */
.smardis-chat-container {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Auto-sized chat container */
.smardis-chat-auto-size {
    width: 90% !important;
    height: 90% !important;
}

/* Embedded mode specific styles */
.smardis-chat-embedded-mode {
    position: static;
    border-radius: 8px;
    margin: 20px auto;
}

/* Anchored chat styles */
.smardis-chat-anchored {
    position: fixed;
    z-index: 9999;
    transition: all 0.3s ease;
}

/* Positioning classes */
.smardis-chat-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.smardis-chat-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.smardis-chat-position-top-right {
    top: 20px;
    right: 20px;
}

.smardis-chat-position-top-left {
    top: 20px;
    left: 20px;
}

.smardis-chat-position-middle-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.smardis-chat-position-middle-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

/* Transform middle positions back when minimized */
.smardis-chat-minimized.smardis-chat-position-middle-right,
.smardis-chat-minimized.smardis-chat-position-middle-left {
    transform: translateY(-50%) scale(1);
}

.smardis-chat-anchored.smardis-chat-minimized {
    width: 60px !important;
    height: 60px !important;
    border-radius: 30px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: visible;
}

/* Chat bubble button */
.smardis-chat-bubble {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    color: white;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: transform 0.2s ease;
}

.smardis-chat-bubble:hover {
    transform: scale(1.05);
}

.smardis-chat-bubble img {
    max-width: 40px;
    max-height: 40px;
}

/* Close button */
.smardis-chat-close {
    position: absolute;
    top: 10px;
    right: 10px;
    color: white;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    display: none;
}

.smardis-chat-anchored:not(.smardis-chat-minimized) .smardis-chat-close {
    display: block;
    opacity: 1;
}

/* Header styles */
.smardis-chat-header {
    padding: 15px;
    color: white;
    font-weight: bold;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Message container */
.smardis-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: transparent;
    min-height: 200px;
}

/* Welcome message */
.smardis-chat-welcome {
    text-align: center;
    padding: 10px;
    margin-bottom: 15px;
    color: #666;
    font-style: italic;
}

/* Message styles */
.smardis-chat-message {
    max-width: 80%;
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
}

/* User message */
.smardis-user-message {
    margin-left: auto;
    color: white;
    border-bottom-right-radius: 4px;
}

/* AI message */
.smardis-ai-message {
    margin-right: auto;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* Markdown formatting in AI messages */
.smardis-ai-message p {
    margin: 0 0 10px 0;
}

.smardis-ai-message p:last-child {
    margin-bottom: 0;
}

.smardis-ai-message strong,
.smardis-ai-message b {
    font-weight: 600;
}

.smardis-ai-message em,
.smardis-ai-message i {
    font-style: italic;
}

.smardis-ai-message ul,
.smardis-ai-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.smardis-ai-message ul {
    list-style-type: disc;
}

.smardis-ai-message ol {
    list-style-type: decimal;
}

.smardis-ai-message li {
    margin: 4px 0;
    line-height: 1.4;
}

.smardis-ai-message h1,
.smardis-ai-message h2,
.smardis-ai-message h3,
.smardis-ai-message h4,
.smardis-ai-message h5,
.smardis-ai-message h6 {
    font-weight: 600;
    margin: 12px 0 8px 0;
    line-height: 1.3;
}

.smardis-ai-message h1 { font-size: 1.4em; }
.smardis-ai-message h2 { font-size: 1.3em; }
.smardis-ai-message h3 { font-size: 1.2em; }
.smardis-ai-message h4 { font-size: 1.1em; }
.smardis-ai-message h5 { font-size: 1.05em; }
.smardis-ai-message h6 { font-size: 1em; }

.smardis-ai-message h1:first-child,
.smardis-ai-message h2:first-child,
.smardis-ai-message h3:first-child,
.smardis-ai-message h4:first-child,
.smardis-ai-message h5:first-child,
.smardis-ai-message h6:first-child {
    margin-top: 0;
}

.smardis-ai-message code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.smardis-ai-message pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.smardis-ai-message pre code {
    background-color: transparent;
    padding: 0;
}

.smardis-ai-message blockquote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    padding-left: 12px;
    margin: 8px 0;
    font-style: italic;
    color: #666;
}

.smardis-ai-message a {
    color: #2196F3;
    text-decoration: underline;
}

.smardis-ai-message a:hover {
    color: #1976D2;
}

.smardis-ai-message hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 12px 0;
}

.smardis-ai-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}

.smardis-ai-message table th,
.smardis-ai-message table td {
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 6px 8px;
    text-align: left;
}

.smardis-ai-message table th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* Thinking indicator */
.smardis-thinking {
    position: relative;
    padding-right: 30px;
}

.smardis-thinking:after {
    content: '';
    animation: dots 1.5s linear infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Input wrapper and buttons row */
.smardis-chat-input-wrapper {
    background-color: transparent;
    border-top: 1px solid #ddd;
}

.smardis-chat-buttons-row {
    display: flex;
    gap: 8px;
    padding: 8px 10px 4px 10px;
    flex-wrap: wrap;
}

/* Button container */
.smardis-chat-button-container {
    position: relative;
}

/* Dropdown style */
.smardis-chat-button-select {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.smardis-chat-button-select:hover {
    border-color: #999;
}

.smardis-chat-button-select:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Button trigger for popups */
.smardis-chat-button-trigger {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.smardis-chat-button-trigger:hover {
    border-color: #999;
    background-color: #f5f5f5;
}

.smardis-chat-button-trigger:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

/* Toggle button styles */
.smardis-chat-button-toggle {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
}

.smardis-chat-button-toggle:hover {
    border-color: #999;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.smardis-chat-button-toggle:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.smardis-chat-button-toggle.active {
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
    font-weight: 600;
}

.smardis-chat-button-toggle.active::after {
    content: '\2713';
    margin-left: 6px;
    font-weight: bold;
}

/* Popup options container */
.smardis-chat-button-popup {
    position: relative;
}

.smardis-chat-button-options {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
}

.smardis-chat-button-options-inner {
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

/* Radio and checkbox labels */
.smardis-chat-radio-label,
.smardis-chat-checkbox-label {
    display: block;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    margin: 2px 0;
}

.smardis-chat-radio-label:hover,
.smardis-chat-checkbox-label:hover {
    background-color: #f5f5f5;
}

.smardis-chat-radio-label input,
.smardis-chat-checkbox-label input {
    margin-right: 8px;
    cursor: pointer;
}

/* Input area */
.smardis-chat-input {
    display: flex;
    padding: 10px;
    background-color: transparent;
}

.smardis-chat-text {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    margin-right: 10px;
    font-size: 14px;
    background-color: white;
}

.smardis-chat-text:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.smardis-chat-send {
    padding: 8px 15px;
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s;
}

.smardis-chat-send:hover {
    opacity: 0.9;
}

.smardis-chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Branding */
.smardis-chat-branding {
    text-align: center;
    font-size: 11px;
    padding: 5px;
    color: #999;
    background-color: transparent;
}

/* Hide all except bubble when minimized */
.smardis-chat-minimized .smardis-chat-header,
.smardis-chat-minimized .smardis-chat-messages,
.smardis-chat-minimized .smardis-chat-input-wrapper,
.smardis-chat-minimized .smardis-chat-branding {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .smardis-chat-anchored {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
    }
    
    .smardis-chat-message {
        max-width: 90%;
    }
    
    .smardis-chat-anchored:not(.smardis-chat-minimized) {
        width: 90% !important;
        height: 80% !important;
        max-width: 400px;
        max-height: 600px;
    }
    
    .smardis-chat-buttons-row {
        flex-direction: column;
    }
    
    .smardis-chat-button-select,
    .smardis-chat-button-trigger,
    .smardis-chat-button-toggle {
        width: 100%;
    }
    
    .smardis-chat-button-options {
        left: 0;
        right: 0;
        width: auto;
    }
}

/* Embedded mode responsive */
@media (max-width: 767px) {
    .smardis-chat-embedded-mode {
        width: 100% !important;
        height: 500px !important;
        margin: 10px 0;
        border-radius: 0;
    }
}

/* Admin panel styling */
.settings_page_smardis-chat-settings .tab-content {
    margin-top: 20px;
}

.settings_page_smardis-chat-settings .form-table th {
    width: 200px;
}

.settings_page_smardis-chat-settings .smardis-chat-image-preview {
    margin-bottom: 10px;
}

.settings_page_smardis-chat-settings .smardis-remove-button {
    margin-left: 10px;
}

/* Scrollbar styling for options */
.smardis-chat-button-options-inner::-webkit-scrollbar {
    width: 6px;
}

.smardis-chat-button-options-inner::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.smardis-chat-button-options-inner::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.smardis-chat-button-options-inner::-webkit-scrollbar-thumb:hover {
    background: #555;
}
