/**
 * Sophia Chat Widget Styles
 */

/* Container */
.sophia-chat-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    max-width: 100%;
    margin: 0 auto;
}

.sophia-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Header */
.sophia-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2E86C1 0%, #3498DB 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sophia-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sophia-icon {
    font-size: 32px;
    line-height: 1;
}

.sophia-header-text {
    display: flex;
    flex-direction: column;
}

.sophia-title {
    font-weight: 600;
    font-size: 16px;
}

.sophia-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.sophia-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sophia-memory-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    transition: background 0.2s;
}

.sophia-memory-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sophia-memory-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: white;
}

.sophia-memory-label {
    font-size: 12px;
    white-space: nowrap;
}

.sophia-forget-button {
    background: rgba(0, 0, 0, 0.3);  /* DUNKELGRAU statt transparent weiß */
    border: none;
    color: white;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    padding: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 1 !important;
}

.sophia-forget-button:hover {
    background: rgba(0, 0, 0, 0.45);  /* Noch dunkler beim Hover */
    color: #ff4444;  /* ROT beim Hover */
    transform: scale(1.15);
}

.sophia-reset-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sophia-reset-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(180deg);
}

/* Messages Container */
.sophia-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.sophia-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.sophia-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sophia-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.sophia-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Messages */
.sophia-message {
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

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

.sophia-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.sophia-message-timestamp {
    font-size: 11px;
    color: #999;
    margin-bottom: 4px;
}

/* User Messages */
.sophia-message-user {
    text-align: right;
}

.sophia-message-user .sophia-message-content {
    background: #2E86C1;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.sophia-message-user .sophia-message-timestamp {
    text-align: right;
}

/* Sophia Messages */
.sophia-message-sophia {
    text-align: left;
}

.sophia-message-sophia .sophia-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

/* System Messages */
.sophia-message-system .sophia-message-content {
    background: #FFF3CD;
    color: #856404;
    border: 1px solid #FFE69C;
    margin: 0 auto;
    text-align: center;
    max-width: 90%;
}

/* Error Messages */
.sophia-message-error .sophia-message-content {
    background: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
    margin: 0 auto;
    text-align: left;
    max-width: 90%;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 16px;
}

/* Input Wrapper */
.sophia-chat-input-wrapper {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.sophia-chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.sophia-chat-input textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    max-height: 150px;
    transition: border-color 0.2s;
}

.sophia-chat-input textarea:focus {
    outline: none;
    border-color: #2E86C1;
}

.sophia-chat-input textarea:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

/* Send Button */
.sophia-send-button {
    width: 44px;
    height: 44px;
    border: none;
    background: #2E86C1;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sophia-send-button:hover:not(:disabled) {
    background: #1F6691;
    transform: scale(1.05);
}

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

.sophia-send-icon {
    font-size: 18px;
    transform: translateX(1px);
}

/* Loading Spinner */
.sophia-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Input Hint */
.sophia-input-hint {
    font-size: 11px;
    color: #999;
    margin-top: 8px;
    text-align: center;
}

/* Loading State */
.sophia-loading {
    position: relative;
}

.sophia-loading p {
    text-align: center;
    color: #999;
    padding: 40px 20px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sophia-chat-header {
        padding: 12px 16px;
    }
    
    .sophia-title {
        font-size: 14px;
    }
    
    .sophia-subtitle {
        font-size: 11px;
    }
    
    .sophia-chat-messages {
        padding: 16px;
    }
    
    .sophia-message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .sophia-chat-input-wrapper {
        padding: 12px 16px;
    }
    
    .sophia-chat-input textarea {
        font-size: 14px;
    }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
    .sophia-chat-container {
        background: #1e1e1e;
        border-color: #333;
    }
    
    .sophia-chat-messages {
        background: #2d2d2d;
    }
    
    .sophia-message-sophia .sophia-message-content {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #4a4a4a;
    }
    
    .sophia-chat-input-wrapper {
        background: #1e1e1e;
        border-color: #333;
    }
    
    /* Input-Feld IMMER hell - auch im Dark Mode! */
    .sophia-chat-input textarea {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: #4a4a4a;
    }
    
    .sophia-chat-input textarea::placeholder {
        color: #666 !important;
    }
    
    .sophia-chat-input textarea:focus {
        border-color: #2E86C1;
    }
}

/* Accessibility */
.sophia-send-button:focus,
.sophia-reset-button:focus,
.sophia-forget-button:focus,
.sophia-memory-toggle input[type="checkbox"]:focus,
.sophia-chat-input textarea:focus {
    outline: 2px solid #2E86C1;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sophia-chat-input-wrapper,
    .sophia-reset-button {
        display: none;
    }
}

/* Error Screen mit Sophia-Bild (v14.2) */
.sophia-message-error-busy {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
}

.sophia-error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sophia-busy-img {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sophia-error-text {
    color: #856404;
    flex: 1;
}
