/* California Tax Optimizer - AI Assistant Styles */

/* AI Assistant Container */
.ai-assistant-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
}

/* AI Toggle Button */
.ai-toggle-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-on-primary);
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    z-index: 1001;
}

.ai-toggle-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.ai-toggle-button:active {
    transform: translateY(0);
}

.ai-status-indicator {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-left: 0.25rem;
}

.ai-status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.ai-status-indicator.offline {
    background-color: var(--error);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
}

/* AI Panel */
.ai-panel {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    width: 400px;
    max-width: 90vw;
    max-height: 70vh;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

.ai-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* AI Panel Header */
.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-on-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-panel-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.ai-panel-title i {
    font-size: 1.25rem;
}

.ai-status-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ai-status-badge.online {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-on-primary);
}

.ai-status-badge.offline {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.ai-panel-close {
    background: none;
    border: none;
    color: var(--text-on-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.ai-panel-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* AI Panel Body */
.ai-panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Configuration Section */
.ai-config-section {
    padding: 1.5rem;
    overflow-y: auto;
}

.ai-config-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.ai-config-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.ai-provider-selector,
.ai-model-selector,
.ai-api-key-input {
    margin-bottom: 1.25rem;
}

.ai-api-key-input .input-group-icon {
    margin-bottom: 0.5rem;
}

.ai-config-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.ai-config-actions .btn {
    flex: 1;
}

/* Chat Section */
.ai-chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--surface-alt);
}

.ai-welcome-message {
    margin-bottom: 1rem;
}

.ai-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

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

.ai-message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-primary);
    flex-shrink: 0;
}

.ai-message-user .ai-message-avatar {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
}

.ai-message-content {
    flex: 1;
    max-width: calc(100% - 3rem);
}

.ai-message-user .ai-message-content {
    text-align: right;
}

.ai-message-text {
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.ai-message-assistant .ai-message-text {
    border-top-left-radius: 0;
}

.ai-message-user .ai-message-text {
    background: var(--primary);
    color: var(--text-on-primary);
    border-top-right-radius: 0;
}

.ai-message-text h2,
.ai-message-text h3,
.ai-message-text h4 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    color: inherit;
}

.ai-message-text h2 {
    font-size: 1.125rem;
}

.ai-message-text h3 {
    font-size: 1rem;
}

.ai-message-text h4 {
    font-size: 0.875rem;
}

.ai-message-text ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.ai-message-text li {
    margin-bottom: 0.25rem;
}

.ai-message-text strong {
    font-weight: 600;
}

.ai-message-text em {
    font-style: italic;
}

.ai-message-time {
    font-size: 0.625rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
    opacity: 0.7;
}

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

/* Typing Indicator */
.ai-typing .ai-message-text {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.ai-typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border-top-left-radius: 0;
    box-shadow: var(--shadow-sm);
}

.ai-typing-indicator span {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Input */
.ai-chat-input-container {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.ai-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ai-quick-question {
    padding: 0.375rem 0.75rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

.ai-quick-question:hover {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
}

.ai-chat-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ai-chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-primary);
    resize: none;
    min-height: 3rem;
    max-height: 8rem;
    line-height: 1.5;
    transition: border-color var(--transition-fast);
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-send-button {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-on-primary);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-send-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.ai-send-button:active {
    transform: translateY(0);
}

.ai-chat-actions {
    display: flex;
    gap: 0.5rem;
}

.ai-chat-actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

/* AI Panel Footer */
.ai-panel-footer {
    padding: 0.75rem 1.25rem;
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.ai-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.625rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.ai-disclaimer i {
    color: var(--warning);
    flex-shrink: 0;
    margin-top: 0.125rem;
}

/* Modal Styles */
.modal-overlay {
    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: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-on-primary);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-on-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.api-provider-info {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.api-provider-info:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.api-provider-info h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.api-provider-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.api-provider-info a {
    color: var(--primary);
    text-decoration: none;
}

.api-provider-info a:hover {
    text-decoration: underline;
}

.api-security-note {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--warning);
}

.api-security-note h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.api-security-note p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    text-align: right;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .ai-assistant-container {
        bottom: 0.5rem;
        right: 0.5rem;
    }
    
    .ai-panel {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
        right: 0.5rem;
        bottom: calc(100% + 0.5rem);
        max-height: 80vh;
    }
    
    .ai-toggle-button {
        padding: 0.625rem 1rem;
        font-size: 0.75rem;
    }
    
    .ai-toggle-button span:not(.ai-status-indicator) {
        display: none;
    }
    
    .ai-toggle-button i {
        margin-right: 0;
    }
    
    .ai-config-actions {
        flex-direction: column;
    }
    
    .ai-quick-questions {
        flex-direction: column;
    }
    
    .ai-quick-question {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ai-panel {
        width: calc(100vw - 1rem);
        max-height: 85vh;
    }
    
    .ai-config-section,
    .ai-chat-messages {
        padding: 1rem;
    }
    
    .ai-chat-input-container {
        padding: 0.75rem 1rem;
    }
    
    .ai-chat-actions {
        flex-direction: column;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ai-toggle-button {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .ai-panel {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    }
    
    .ai-chat-messages {
        background: var(--background);
    }
    
    .ai-message-text {
        background: var(--surface);
    }
    
    .ai-chat-input {
        background: var(--surface-alt);
    }
    
    .modal {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    }
}

/* Print Styles */
@media print {
    .ai-assistant-container {
        display: none;
    }
}