/* ==========================================================================
   AI Assistant Styling - 100% In-Browser WebLLM Writing Assistant
   ========================================================================== */

/* User Profile AI Assistant Section */
.dropdown-ai-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f1f3f5;
    text-align: left;
}

[data-theme="dark"] .dropdown-ai-section {
    border-top-color: #334155;
}

.dropdown-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.dropdown-ai-title {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
}

[data-theme="dark"] .dropdown-ai-title {
    color: #f1f5f9;
}

.dropdown-ai-select {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #1e293b;
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 6px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    font-family: inherit;
}

.dropdown-ai-select:focus {
    border-color: #6366f1;
}

[data-theme="dark"] .dropdown-ai-select {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

.dropdown-ai-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    color: #64748b;
    background: #f1f5f9;
    padding: 6px 8px;
    border-radius: 6px;
}

[data-theme="dark"] .dropdown-ai-details {
    color: #94a3b8;
    background: #1e293b;
}

.dropdown-ai-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Profile AI Progress Box */
.profile-ai-progress-box {
    margin-bottom: 8px;
    padding: 8px 10px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
}

[data-theme="dark"] .profile-ai-progress-box {
    background: #1e1b4b;
    border-color: #3730a3;
}

.profile-ai-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    color: #4338ca;
    margin-bottom: 4px;
}

[data-theme="dark"] .profile-ai-progress-header {
    color: #c7d2fe;
}

.profile-ai-progress-bar-bg {
    width: 100%;
    height: 5px;
    background: #e0e7ff;
    border-radius: 999px;
    overflow: hidden;
}

[data-theme="dark"] .profile-ai-progress-bar-bg {
    background: #312e81;
}

.profile-ai-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.profile-ai-progress-text {
    font-size: 10px;
    color: #6366f1;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
}

[data-theme="dark"] .profile-ai-progress-text {
    color: #a5b4fc;
}

/* Profile Clean Cache Button */
.dropdown-ai-clean-btn {
    width: 100%;
    margin-top: 8px;
    padding: 6px 10px;
    border: 1px solid #fecaca;
    background: #fff5f5;
    color: #dc2626;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dropdown-ai-clean-btn:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #b91c1c;
}

[data-theme="dark"] .dropdown-ai-clean-btn {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

[data-theme="dark"] .dropdown-ai-clean-btn:hover {
    background: #7f1d1d;
    color: #ffffff;
}

/* Compact Card Editor AI Controls */
.ai-assistant-wrapper.compact {
    margin-bottom: 8px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 8px;
}

[data-theme="dark"] .ai-assistant-wrapper.compact {
    border-color: #334155;
    background: #0f172a;
}

.ai-assistant-wrapper {
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    transition: all 0.25s ease;
    overflow: hidden;
}

[data-theme="dark"] .ai-assistant-wrapper {
    border-color: #334155;
    background: #0f172a;
}

/* Header & Toggle */
.ai-assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f1f5f9;
    border-bottom: 1px solid transparent;
}

[data-theme="dark"] .ai-assistant-header {
    background: #1e293b;
}

.ai-assistant-wrapper.active .ai-assistant-header {
    border-bottom-color: #e2e8f0;
}

[data-theme="dark"] .ai-assistant-wrapper.active .ai-assistant-header {
    border-bottom-color: #334155;
}

.ai-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

[data-theme="dark"] .ai-toggle-label {
    color: #cbd5e1;
}

.ai-sparkle-icon {
    color: #6366f1;
    font-size: 15px;
    animation: sparkleSpin 4s linear infinite;
}

@keyframes sparkleSpin {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.15) rotate(15deg); }
}

/* Modern Switch */
.ai-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.ai-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
}

.ai-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ai-switch input:checked + .ai-slider {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.ai-switch input:checked + .ai-slider:before {
    transform: translateX(18px);
}

.ai-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badges */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.ai-badge-idle {
    background: #e2e8f0;
    color: #475569;
}

[data-theme="dark"] .ai-badge-idle {
    background: #334155;
    color: #94a3b8;
}

.ai-badge-ready {
    background: #dcfce7;
    color: #15803d;
}

[data-theme="dark"] .ai-badge-ready {
    background: #14532d;
    color: #86efac;
}

.ai-badge-busy {
    background: #e0e7ff;
    color: #4338ca;
}

[data-theme="dark"] .ai-badge-busy {
    background: #312e81;
    color: #c7d2fe;
}

.ai-badge-sim {
    background: #fef3c7;
    color: #b45309;
}

[data-theme="dark"] .ai-badge-sim {
    background: #78350f;
    color: #fde68a;
}

.ai-badge-error {
    background: #fee2e2;
    color: #b91c1c;
}

.ai-badge-speed {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    cursor: help;
}

[data-theme="dark"] .ai-badge-speed {
    background: #1e3a8a;
    color: #93c5fd;
    border-color: #1d4ed8;
}

.ai-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.ai-dot-ready { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.6); }
.ai-dot-idle { background: #94a3b8; }
.ai-dot-sim { background: #f59e0b; }
.ai-dot-error { background: #ef4444; }

.ai-spinner {
    width: 8px;
    height: 8px;
    border: 2px solid #6366f1;
    border-top-color: transparent;
    border-radius: 50%;
    animation: aiSpin 0.75s linear infinite;
}

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

/* Assistant Body */
.ai-assistant-body {
    padding: 12px 14px;
}

/* Configuration Row */
.ai-config-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 11px;
}

.ai-model-picker {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-model-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: white;
    font-size: 12px;
    color: #1e293b;
    font-weight: 500;
    outline: none;
    cursor: pointer;
}

[data-theme="dark"] .ai-model-select {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

.ai-cache-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #64748b;
    font-size: 11px;
}

[data-theme="dark"] .ai-cache-indicator {
    color: #94a3b8;
}

/* Progress Box */
.ai-progress-box {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
}

[data-theme="dark"] .ai-progress-box {
    background: #1e1b4b;
    border-color: #3730a3;
}

.ai-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    color: #4338ca;
    margin-bottom: 6px;
}

[data-theme="dark"] .ai-progress-header {
    color: #c7d2fe;
}

.ai-progress-bar-bg {
    width: 100%;
    height: 6px;
    background: #e0e7ff;
    border-radius: 999px;
    overflow: hidden;
}

[data-theme="dark"] .ai-progress-bar-bg {
    background: #312e81;
}

.ai-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.ai-progress-text {
    font-size: 10px;
    color: #6366f1;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
}

[data-theme="dark"] .ai-progress-text {
    color: #a5b4fc;
}

/* Action Toolbar */
.ai-action-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ai-btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

[data-theme="dark"] .ai-btn-action {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.ai-btn-action:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .ai-btn-action:hover:not(:disabled) {
    background: #334155;
    border-color: #475569;
}

.ai-btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Primary "Improve Writing" button */
.ai-btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border-color: transparent;
}

.ai-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 8px rgba(99, 102, 241, 0.35);
}

[data-theme="dark"] .ai-btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
}

.ai-shortcut-badge {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    font-weight: 700;
    margin-left: 2px;
}

/* Stop generation button */
.ai-btn-stop {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
    animation: stopPulse 1.2s ease infinite;
}

[data-theme="dark"] .ai-btn-stop {
    background: #7f1d1d;
    color: #fecaca;
    border-color: #991b1b;
}

@keyframes stopPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(0.98); }
}

/* Undo revision button */
.ai-btn-undo {
    background: #f8fafc;
    color: #6366f1;
    border: 1px solid #c7d2fe;
}

.ai-btn-undo:hover {
    background: #eef2ff;
    border-color: #818cf8;
}

[data-theme="dark"] .ai-btn-undo {
    background: #1e1b4b;
    color: #a5b4fc;
    border-color: #3730a3;
}

/* Live Metrics Bar */
.ai-metrics-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: #64748b;
}

[data-theme="dark"] .ai-metrics-bar {
    color: #94a3b8;
}

.ai-metrics-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-metrics-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: inherit;
}

.ai-speed-chip {
    font-family: monospace;
    font-weight: 600;
    color: #4f46e5;
    background: #eef2ff;
    padding: 1px 6px;
    border-radius: 4px;
}

[data-theme="dark"] .ai-speed-chip {
    color: #c7d2fe;
    background: #312e81;
}

/* Streaming In-Place Animation */
.ai-streaming-pulse {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
    animation: textareaGlow 1.5s ease-in-out infinite alternate;
}

@keyframes textareaGlow {
    from { box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); }
    to { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.4); }
}

/* WebGPU Warning */
.ai-webgpu-warning {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 8px;
    font-size: 11px;
    color: #92400e;
}

[data-theme="dark"] .ai-webgpu-warning {
    background: #451a03;
    border-color: #78350f;
    color: #fde68a;
}
