/* HadithWorld AI Agent - Frontend Styles */

:root {
    --hwai-primary: #00796B;
    --hwai-primary-dark: #004D40;
    --hwai-primary-light: #4DB6AC;
    --hwai-secondary: #FFC107;
    --hwai-accent: #FF5722;
    --hwai-success: #4CAF50;
    --hwai-info: #2196F3;
    --hwai-warning: #FF9800;
    --hwai-error: #F44336;
    --hwai-bg-light: #FAFAFA;
    --hwai-bg-dark: #121212;
    --hwai-surface-light: #FFFFFF;
    --hwai-surface-dark: #1E1E1E;
    --hwai-text-primary-light: #212121;
    --hwai-text-primary-dark: #FFFFFF;
    --hwai-text-secondary-light: #757575;
    --hwai-text-secondary-dark: #B0B0B0;
    --hwai-border-light: #E0E0E0;
    --hwai-border-dark: #424242;
}

.hwai-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    background: var(--hwai-surface-light);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    transition: all 0.3s ease;
}

.hwai-container.dark {
    background: var(--hwai-surface-dark);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Header */
.hwai-header {
    background: linear-gradient(135deg, var(--hwai-primary) 0%, var(--hwai-primary-dark) 100%);
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 121, 107, 0.2);
}

.hwai-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.hwai-header-buttons {
    display: flex;
    gap: 8px;
}

.hwai-header-buttons button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.hwai-header-buttons button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Messages Area */
.hwai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--hwai-bg-light);
}

.dark .hwai-messages {
    background: var(--hwai-bg-dark);
}

.hwai-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--hwai-text-secondary-light);
}

.dark .hwai-welcome {
    color: var(--hwai-text-secondary-dark);
}

.hwai-welcome h4 {
    color: var(--hwai-primary);
    font-size: 24px;
    margin-bottom: 16px;
}

.hwai-welcome p {
    font-size: 16px;
    line-height: 1.6;
    margin: 8px 0;
}

/* Message Bubbles */
.hwai-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

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

.hwai-message.user {
    flex-direction: row-reverse;
}

.hwai-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--hwai-primary-light);
}

.hwai-message.user .hwai-message-avatar {
    background: var(--hwai-secondary);
}

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

.dark .hwai-message-content {
    background: var(--hwai-surface-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hwai-message.user .hwai-message-content {
    background: var(--hwai-primary);
    color: white;
}

.dark .hwai-message.user .hwai-message-content {
    background: var(--hwai-primary-dark);
}

.hwai-message-text {
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

.hwai-message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
}

.hwai-message-time {
    font-size: 11px;
    color: var(--hwai-text-secondary-light);
    margin-top: 4px;
}

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

.dark .hwai-message-time {
    color: var(--hwai-text-secondary-dark);
}

/* References */
.hwai-references {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--hwai-border-light);
}

.dark .hwai-references {
    border-color: var(--hwai-border-dark);
}

.hwai-references-title {
    font-weight: 600;
    color: var(--hwai-primary);
    margin-bottom: 8px;
}

.hwai-reference-group {
    margin: 8px 0;
}

.hwai-reference-group strong {
    color: var(--hwai-primary-dark);
    display: block;
    margin-bottom: 4px;
}

.hwai-reference-group ul {
    margin: 0;
    padding-left: 20px;
}

.hwai-reference-group li {
    font-size: 13px;
    color: var(--hwai-text-secondary-light);
    margin: 2px 0;
}

.dark .hwai-reference-group li {
    color: var(--hwai-text-secondary-dark);
}

/* Thinking Process */
.hwai-thinking {
    margin-top: 12px;
    padding: 8px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 8px;
}

.hwai-thinking summary {
    cursor: pointer;
    color: var(--hwai-info);
    font-weight: 500;
    font-size: 14px;
}

.hwai-thinking ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.hwai-thinking li {
    font-size: 13px;
    color: var(--hwai-text-secondary-light);
    margin: 4px 0;
}

.dark .hwai-thinking li {
    color: var(--hwai-text-secondary-dark);
}

/* Thinking Indicator */
.hwai-thinking-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(33, 150, 243, 0.05);
    border-radius: 12px;
    margin-bottom: 16px;
}

.hwai-thinking-animation {
    display: flex;
    gap: 4px;
}

.hwai-thinking-animation span {
    width: 8px;
    height: 8px;
    background: var(--hwai-info);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.hwai-thinking-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.hwai-thinking-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.hwai-thinking-steps {
    flex: 1;
}

.hwai-thinking-step {
    font-size: 13px;
    color: var(--hwai-info);
    margin: 2px 0;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Suggestions */
.hwai-suggestions {
    padding: 16px;
    background: rgba(255, 193, 7, 0.05);
    border-top: 1px solid var(--hwai-border-light);
}

.dark .hwai-suggestions {
    background: rgba(255, 193, 7, 0.1);
    border-color: var(--hwai-border-dark);
}

.hwai-suggestions-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hwai-text-secondary-light);
    margin-bottom: 8px;
}

.dark .hwai-suggestions-title {
    color: var(--hwai-text-secondary-dark);
}

.hwai-suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hwai-suggestion {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--hwai-border-light);
    border-radius: 20px;
    font-size: 13px;
    color: var(--hwai-text-primary-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dark .hwai-suggestion {
    background: var(--hwai-surface-dark);
    border-color: var(--hwai-border-dark);
    color: var(--hwai-text-primary-dark);
}

.hwai-suggestion:hover {
    background: var(--hwai-secondary);
    color: var(--hwai-text-primary-light);
    border-color: var(--hwai-secondary);
}

/* Input Area */
.hwai-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--hwai-border-light);
}

.dark .hwai-input-area {
    background: var(--hwai-surface-dark);
    border-color: var(--hwai-border-dark);
}

.hwai-selected-image {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.hwai-selected-image img {
    height: 80px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hwai-selected-image button {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--hwai-error);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hwai-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.hwai-voice-button,
.hwai-image-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--hwai-primary-light);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
}

.hwai-voice-button:hover,
.hwai-image-button:hover {
    background: var(--hwai-primary);
    transform: scale(1.1);
}

.hwai-voice-button.listening {
    background: var(--hwai-error);
    animation: recording 1.5s infinite;
}

@keyframes recording {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.hwai-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--hwai-border-light);
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    background: var(--hwai-bg-light);
}

.dark .hwai-input {
    background: var(--hwai-bg-dark);
    border-color: var(--hwai-border-dark);
    color: var(--hwai-text-primary-dark);
}

.hwai-input:focus {
    border-color: var(--hwai-primary);
    box-shadow: 0 0 0 3px rgba(0, 121, 107, 0.1);
}

.hwai-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hwai-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--hwai-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
}

.hwai-send-button:hover:not(:disabled) {
    background: var(--hwai-primary-dark);
    transform: scale(1.1);
}

.hwai-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Settings Modal */
.hwai-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.hwai-settings-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

.dark .hwai-settings-content {
    background: var(--hwai-surface-dark);
}

.hwai-settings-content h4 {
    margin: 0 0 20px 0;
    color: var(--hwai-primary);
    font-size: 20px;
}

.hwai-close-settings {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--hwai-bg-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.dark .hwai-close-settings {
    background: var(--hwai-bg-dark);
    color: var(--hwai-text-primary-dark);
}

.hwai-setting {
    margin-bottom: 16px;
}

.hwai-setting label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--hwai-text-primary-light);
    font-size: 14px;
}

.dark .hwai-setting label {
    color: var(--hwai-text-primary-dark);
}

.hwai-setting select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--hwai-border-light);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: var(--hwai-text-primary-light);
}

.dark .hwai-setting select {
    background: var(--hwai-bg-dark);
    border-color: var(--hwai-border-dark);
    color: var(--hwai-text-primary-dark);
}

/* Quran Reference Highlighting */
.hwai-quran-ref {
    color: var(--hwai-primary);
    font-weight: 600;
}

/* Custom Scrollbar */
.hwai-messages::-webkit-scrollbar {
    width: 8px;
}

.hwai-messages::-webkit-scrollbar-track {
    background: var(--hwai-bg-light);
    border-radius: 4px;
}

.dark .hwai-messages::-webkit-scrollbar-track {
    background: var(--hwai-bg-dark);
}

.hwai-messages::-webkit-scrollbar-thumb {
    background: var(--hwai-primary-light);
    border-radius: 4px;
}

.hwai-messages::-webkit-scrollbar-thumb:hover {
    background: var(--hwai-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .hwai-container {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    .hwai-message-content {
        max-width: 85%;
    }
    
    .hwai-header {
        padding: 12px 16px;
    }
    
    .hwai-header h3 {
        font-size: 18px;
    }
    
    .hwai-messages {
        padding: 16px;
    }
    
    .hwai-input-area {
        padding: 12px;
    }
}

/* RTL Support for Arabic */
.hwai-container[dir="rtl"] .hwai-message {
    flex-direction: row-reverse;
}

.hwai-container[dir="rtl"] .hwai-message.user {
    flex-direction: row;
}

.hwai-container[dir="rtl"] .hwai-input {
    text-align: right;
}

/* Loading Animation */
.hwai-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 121, 107, 0.3);
    border-top-color: var(--hwai-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Print Styles */
@media print {
    .hwai-header-buttons,
    .hwai-input-area,
    .hwai-suggestions,
    .hwai-settings-modal {
        display: none !important;
    }
    
    .hwai-container {
        height: auto;
        box-shadow: none;
    }
    
    .hwai-messages {
        overflow: visible;
    }
}
