/* Mobile AI Assistant Redesign - Phase 2.3 */

/* ========== AI Assistant Variables ========== */
:root {
    --ai-drawer-height: 85vh;
    --ai-drawer-radius: 20px;
    --ai-action-size: 72px;
    --ai-input-height: 56px;
    --ai-response-padding: 16px;
    --ai-quick-action-cols: 3;
}

/* ========== Enhanced Mobile AI Drawer ========== */
.mobile-ai-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mobile-bg-primary);
    border-top-left-radius: var(--ai-drawer-radius);
    border-top-right-radius: var(--ai-drawer-radius);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    max-height: var(--ai-drawer-height);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-ai-drawer.open {
    transform: translateY(0);
}

/* Drawer Handle */
.ai-drawer-handle {
    padding: 12px;
    cursor: grab;
    touch-action: none;
    background: var(--mobile-bg-primary);
    border-top-left-radius: var(--ai-drawer-radius);
    border-top-right-radius: var(--ai-drawer-radius);
    position: relative;
}

.ai-drawer-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 4px;
    background: var(--mobile-border);
    border-radius: 2px;
}

.ai-drawer-handle:active {
    cursor: grabbing;
}

/* Drawer Header */
.ai-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mobile-border);
    background: var(--mobile-bg-primary);
}

.ai-drawer-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-drawer-title i {
    color: var(--mobile-primary);
    font-size: 1.25rem;
}

.ai-drawer-close {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-drawer-close:active {
    background: var(--mobile-bg-secondary);
    transform: scale(0.95);
}

/* Drawer Body */
.ai-drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--ai-input-height) + 32px);
}

/* Quick Actions Grid */
.ai-quick-actions {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(var(--ai-quick-action-cols), 1fr);
    gap: 16px;
    background: var(--mobile-bg-secondary);
    margin-bottom: 1px;
}

.ai-quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: var(--ai-action-size);
    padding: 12px 8px;
    background: var(--mobile-bg-primary);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.ai-quick-action:active {
    transform: scale(0.95);
    border-color: var(--mobile-primary);
}

.ai-quick-action i {
    font-size: 1.5rem;
    color: var(--mobile-primary);
    margin-bottom: 6px;
}

.ai-quick-action span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
}

.ai-quick-action.loading {
    pointer-events: none;
    opacity: 0.6;
}

.ai-quick-action.loading i {
    animation: spin 1s linear infinite;
}

/* AI Response Area */
.ai-response-container {
    padding: var(--ai-response-padding);
}

.ai-response {
    background: var(--mobile-bg-secondary);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    animation: slideUp 0.3s ease;
}

.ai-response-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.ai-response-type {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--mobile-primary);
}

.ai-response-actions {
    display: flex;
    gap: 8px;
}

.ai-response-action {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--mobile-bg-primary);
    color: var(--text-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-response-action:active {
    transform: scale(0.95);
    color: var(--mobile-primary);
}

.ai-response-content {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.ai-response-content h3,
.ai-response-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: var(--text-primary);
}

.ai-response-content ul,
.ai-response-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.ai-response-content li {
    margin: 4px 0;
}

.ai-response-content code {
    background: var(--mobile-bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

.ai-response-content pre {
    background: var(--mobile-bg-primary);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.875rem;
    margin: 12px 0;
}

/* Loading State */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.ai-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--mobile-bg-secondary);
    border-top-color: var(--mobile-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.ai-loading-text {
    font-size: 0.875rem;
    text-align: center;
}

/* Input Area */
.ai-input-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: var(--mobile-bg-primary);
    border-top: 1px solid var(--mobile-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.ai-input-wrapper {
    flex: 1;
    position: relative;
}

.ai-input {
    width: 100%;
    min-height: var(--ai-input-height);
    max-height: 120px;
    padding: 16px;
    padding-right: 48px;
    background: var(--mobile-bg-secondary);
    border: 2px solid transparent;
    border-radius: 28px;
    font-size: 1rem;
    color: var(--text-primary);
    resize: none;
    overflow-y: auto;
    transition: all 0.2s ease;
}

.ai-input:focus {
    outline: none;
    border-color: var(--mobile-primary);
}

.ai-input::placeholder {
    color: var(--text-secondary);
}

/* Voice Input Button */
.ai-voice-button {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--mobile-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-voice-button:active {
    transform: scale(0.95);
}

.ai-voice-button.recording {
    background: var(--mobile-danger);
    animation: pulse 1.5s infinite;
}

/* Send Button */
.ai-send-button {
    width: var(--ai-input-height);
    height: var(--ai-input-height);
    border: none;
    background: var(--mobile-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-send-button:active {
    transform: scale(0.95);
}

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

/* Cost Display */
.ai-cost-display {
    padding: 12px 20px;
    background: var(--mobile-bg-secondary);
    border-bottom: 1px solid var(--mobile-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.ai-cost-label {
    color: var(--text-secondary);
}

.ai-cost-value {
    font-weight: 600;
    color: var(--mobile-primary);
}

/* Empty State */
.ai-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.ai-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.ai-empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.ai-empty-text {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Backdrop */
.ai-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1999;
}

.ai-drawer-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

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

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--mobile-danger), 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(var(--mobile-danger), 0); }
}

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

/* Landscape Adjustments */
@media (orientation: landscape) and (max-width: 991px) {
    .mobile-ai-drawer {
        max-height: 90vh;
    }
    
    .ai-quick-actions {
        padding: 12px;
        gap: 12px;
    }
    
    .ai-quick-action {
        min-height: 60px;
        padding: 8px;
    }
    
    .ai-quick-action i {
        font-size: 1.25rem;
    }
}

/* Dark Mode Support */
[data-theme="dark"] .mobile-ai-drawer {
    background: #1a1a1a;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ai-drawer-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ai-quick-actions {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .ai-quick-action {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .ai-response {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .ai-response-action {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ai-input {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

[data-theme="dark"] .ai-cost-display {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .mobile-ai-drawer,
    .ai-drawer-backdrop,
    .ai-quick-action,
    .ai-response {
        transition: none;
        animation: none;
    }
}