/* --- AI Assistant Panel --- */
.ai-panel {
    margin-bottom: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    overflow: hidden;
}

.ai-panel-header {
    background: linear-gradient(135deg, rgba(20, 28, 50, 0.95) 0%, rgba(30, 22, 45, 0.95) 100%);
    padding: 16px 24px;
}

.ai-panel-header h2 {
    font-size: 1.05rem;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- AI Tab Navigation --- */
.ai-tab-nav {
    display: flex;
    background: rgba(10, 14, 26, 0.5);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.ai-tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.ai-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.ai-tab-btn.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
    background: linear-gradient(0deg, rgba(212, 168, 83, 0.1) 0%, transparent 100%);
}

/* --- AI Tab Content --- */
.ai-tab-content {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.ai-tab-content.active {
    display: block;
}

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

.ai-section-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* --- Dropzone & Gallery --- */
.ai-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 30px 20px;
    text-align: center;
    background: rgba(16, 22, 40, 0.3);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 16px;
}

.ai-dropzone:hover, .ai-dropzone.dragover {
    border-color: var(--gold-dim);
    background: rgba(212, 168, 83, 0.05);
}

.ai-dropzone-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.7;
}

.ai-dropzone-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.ai-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.ai-gallery-empty {
    width: 100%;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-xs);
}

.ai-gallery-card {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xs);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.ai-gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-gallery-card.selected {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 168, 83, 0.4);
}

.ai-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    padding: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
}

.ai-gallery-card:hover .ai-gallery-overlay {
    opacity: 1;
}

.ai-gallery-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.ai-gallery-del {
    background: transparent;
    border: none;
    color: var(--color-red);
    cursor: pointer;
    padding: 0 4px;
    font-size: 0.9rem;
}

.ai-gallery-del:hover {
    color: #ff8888;
}

.ai-gallery-check {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--gold);
    color: #000;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-gallery-card.selected .ai-gallery-check {
    opacity: 1;
    transform: scale(1);
}

.ai-selected-count {
    display: block;
    font-size: 0.8rem;
    color: var(--gold-dim);
    margin-bottom: 16px;
    min-height: 1.2em;
}

/* --- Inputs & Buttons --- */
.ai-prompt-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 16px;
    outline: none;
    transition: var(--transition);
}

.ai-prompt-input:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.2);
}

.ai-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    margin-bottom: 16px;
    outline: none;
    cursor: pointer;
}

.ai-select:focus {
    border-color: var(--gold-dim);
}

.ai-action-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(94, 170, 255, 0.15) 0%, rgba(138, 94, 255, 0.15) 100%);
    border: 1px solid rgba(94, 170, 255, 0.3);
    color: #fff;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-action-btn:hover {
    background: linear-gradient(135deg, rgba(94, 170, 255, 0.25) 0%, rgba(138, 94, 255, 0.25) 100%);
    border-color: rgba(94, 170, 255, 0.5);
    box-shadow: 0 4px 15px rgba(94, 170, 255, 0.2);
    transform: translateY(-2px);
}

.ai-action-btn:active {
    transform: translateY(0);
}

/* --- Chat UI --- */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 400px;
    background: rgba(10, 14, 26, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-chat-empty {
    margin: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.ai-chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    line-height: 1.5;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.ai-chat-bubble.user {
    align-self: flex-end;
    background: rgba(94, 170, 255, 0.15);
    border: 1px solid rgba(94, 170, 255, 0.3);
    border-bottom-right-radius: 4px;
}

.ai-chat-bubble.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.ai-chat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.ai-chat-text {
    word-break: break-word;
    white-space: pre-wrap;
}

.ai-chat-insert-btn {
    margin-top: 10px;
    padding: 6px 12px;
    background: rgba(212, 168, 83, 0.15);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.ai-chat-insert-btn:hover {
    background: rgba(212, 168, 83, 0.25);
}

.ai-chat-input-row {
    display: flex;
    padding: 12px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    gap: 8px;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    resize: none;
    outline: none;
}

.ai-chat-input:focus {
    border-color: rgba(94, 170, 255, 0.5);
}

.ai-chat-send {
    padding: 0 20px;
    background: var(--color-blue);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.ai-chat-send:hover {
    filter: brightness(1.1);
}

.ai-chat-clear {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    border-top: 1px solid var(--border);
}

.ai-chat-clear:hover {
    color: var(--color-red);
    background: rgba(255, 0, 0, 0.05);
}

/* --- Response Area --- */
.ai-response-wrapper {
    padding: 0 24px 24px;
}

.ai-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    color: var(--text-secondary);
}

.ai-loading.show {
    display: flex;
}

.ai-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(212, 168, 83, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.ai-response {
    display: none;
    padding: 16px;
    background: rgba(10, 14, 26, 0.8);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-response.has-content {
    display: block;
    animation: fadeIn 0.5s ease;
}

.ai-response.error {
    border-color: var(--color-red);
    background: rgba(255, 94, 94, 0.1);
    color: #ffbaba;
}

.ai-insert-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gold) 0%, #c0943a 100%);
    color: #0a0e1a;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.ai-insert-btn:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    box-shadow: 0 4px 15px rgba(212, 168, 83, 0.3);
    transform: translateY(-2px);
}

.ai-insert-btn.hidden {
    display: none;
}

/* --- Settings --- */
.ai-settings {
    border-top: 1px solid var(--border);
}

.ai-settings-toggle {
    width: 100%;
    padding: 16px 24px;
    background: rgba(0,0,0,0.2);
    border: none;
    color: var(--text-secondary);
    text-align: left;
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-settings-toggle:hover {
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
}

.ai-settings-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.ai-settings-toggle.open::after {
    transform: rotate(180deg);
}

.ai-settings-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(10, 14, 26, 0.4);
}

.ai-settings-content.open {
    max-height: 200px;
}

.ai-key-status {
    padding: 12px 24px 0;
    font-size: 0.85rem;
}

.ai-key-status.configured { color: var(--color-green); }
.ai-key-status.not-configured { color: var(--color-red); }

.ai-key-form {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
}

.ai-key-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
    outline: none;
}

.ai-key-input:focus {
    border-color: var(--gold-dim);
}

.ai-key-save {
    padding: 0 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.ai-key-save:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-key-help {
    padding: 0 24px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
