/* MagicPrompt Core Styles
=========================================================
This file contains shared styles used across the MagicPrompt extension,
including layout, common components, buttons, and shared UI elements.

TABLE OF CONTENTS:
1. Core Layout & Container Styles
2. Common UI Components
   - Headers
   - Buttons 
   - Form Controls
3. Utility Classes & Animations
4. Prompt Enhancement Buttons & Loading
5. Mini-Settings Panel
=========================================================== */

/* 1. CORE LAYOUT & CONTAINER STYLES 
   These styles define the main layout structure and core containers */

/* Main container - Positions the entire MagicPrompt interface */
.magicprompt#magicprompt_container {
    position: absolute;
    top: 40px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    background: var(--background);
    color: var(--text);
    display: flex;
    overflow: hidden;
}

/* Main content wrapper - Contains both vision and chat sections */
.magicprompt .main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
}

/* Resize handle - Allows resizing between vision and chat panels */
.resize-handle {
    width: 5px;
    cursor: col-resize;
    background-color: var(--light-border);
    margin: 0;
    padding: 0;
    height: 100%;
    flex-shrink: 0;
    z-index: 100;
    position: relative;
}

    .resize-handle:hover,
    .resize-handle:active {
        background-color: var(--emphasis);
        box-shadow: -0.5rem 0 0.5rem 0 color-mix(in srgb, transparent 50%, var(--emphasis)), 0.5rem 0 0.5rem 0 color-mix(in srgb, transparent 50%, var(--emphasis));
    }

/* 2. COMMON UI COMPONENTS 
   Shared components used across multiple sections */

/* Section Headers - Used in both vision and chat sections */
.magicprompt .section-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 0.75rem;
    background: var(--background-gray);
    color: var(--text);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    flex-shrink: 0;
    font-weight: 500;
}

/* Settings Button - Global settings access */
.magicprompt #settings_button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    z-index: 2;
}

/* Basic Button - Standard button styling used throughout */
.magicprompt.basic-button {
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    background-color: var(--button-background);
    color: var(--button-text);
    border: 1px solid var(--button-border);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

/* Radio Button Base Styles */
.magicprompt .btn-check + .btn-outline-primary {
    /* Unselected state */
    border: 1px solid var(--shadow);
    background: var(--shadow);
    color: var(--emphasis-text);
    padding: 0.25rem 0.5rem;
}

/* Radio Button Selected State */
.magicprompt .btn-check:checked + .btn-outline-primary {
    /* Selected state */
    background: var(--emphasis);
    border-color: var(--emphasis);
    color: var(--button-foreground-hover);
}

/* Hover effect for radio buttons */
.magicprompt .btn-check + .btn-outline-primary:hover {
    background: color-mix(in srgb, var(--emphasis-soft) 70%, white);
    color: var(--emphasis-text);
}

/* Form Controls - Input fields, selects, and form elements */
.magicprompt.form-control,
.magicprompt.form-select {
    background-color: var(--background-soft);
    color: var(--text);
    border: 1px solid var(--shadow);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 0.9em;
}

/* 3. UTILITY CLASSES & ANIMATIONS 
   Helper classes and animation definitions */

/* Dragging state for resize handle */
body.dragging {
    cursor: col-resize !important;
    user-select: none;
    -webkit-user-select: none;
}

    body.dragging * {
        pointer-events: none !important;
    }

/* Loading animation dots */
@keyframes typingDot {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Collapse animation for expandable sections */
.magicprompt.collapse {
    transition: height 0.2s ease-out;
}

    .magicprompt.collapse:not(.show) {
        display: block;
        height: 0 !important;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }

/* 4. PROMPT ENHANCEMENT BUTTONS & LOADING
   Styling for the Generate Tab enhancements */

.magicprompt.prompt-buttons-container {
    position: absolute;
    /* Calculate position to align with textarea, accounting for the + button width */
    left: calc(2.5rem + ((100% - 2.5rem - 11rem) / 2));
    transform: translateX(-50%);
    top: -5px;
    padding-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
}

.magicprompt.prompt-button {
    padding: 0.2rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--emphasis-soft);
    color: var(--emphasis-text);
    border: 1px solid var(--button-border);
    border-radius: 0.7rem;
    font-weight: bold;
    font-size: 0.7em;
    min-width: 2rem;
    height: 1rem;
}

    .magicprompt.prompt-button:hover {
        background-color: color-mix(in srgb, var(--emphasis-soft) 70%, white);
        color: var(--emphasis-text);
    }

/* Loading animation for prompt enhancement - fixed width to prevent layout shift */
.magicprompt.prompt-loading {
    width: 30px;
    height: 1rem;
    margin-right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

    .magicprompt.prompt-loading.active {
        opacity: 1;
    }

    .magicprompt.prompt-loading .dot {
        width: 6px;
        height: 6px;
        background: var(--emphasis);
        border-radius: 50%;
        animation: bounce 1.4s infinite ease-in-out;
    }

        .magicprompt.prompt-loading .dot:nth-child(1) {
            animation-delay: -0.32s;
        }

        .magicprompt.prompt-loading .dot:nth-child(2) {
            animation-delay: -0.16s;
        }

        .magicprompt.prompt-loading .dot:nth-child(3) {
            animation-delay: 0s;
        }

/* Bounce animation for loading dots */
@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Generate tab settings button */
.magicprompt.prompt-settings-button {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.9em;
    width: 1.5rem;
    height: -2rem;
    margin-left: -0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0;
}

    .magicprompt.prompt-settings-button:hover {
        opacity: 1;
    }

/* 5. MINI-SETTINGS PANEL
   Styling for the feature-specific settings panel */
.magicprompt.prompt-settings-panel {
    background-color: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 300px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.magicprompt .settings-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

    .magicprompt .settings-panel-header h3 {
        margin: 0;
        font-size: 1em;
        font-weight: 600;
        color: var(--text);
    }

.magicprompt .panel-close-btn {
    background: transparent;
    border: none;
    font-size: 1.2em;
    color: var(--text);
    cursor: pointer;
    opacity: 0.7;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .magicprompt .panel-close-btn:hover {
        opacity: 1;
    }

.magicprompt .settings-panel-body {
    padding: 16px;
}

.magicprompt .feature-setting {
    margin-bottom: 16px;
}

    .magicprompt .feature-setting:last-child {
        margin-bottom: 0;
    }

    .magicprompt .feature-setting label {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
        color: var(--text);
        font-size: 0.9em;
    }

.magicprompt .feature-select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background);
    color: var(--text);
    font-size: 0.9em;
}

.magicprompt .setting-description {
    margin-top: 4px;
    font-size: 0.8em;
    color: var(--text-color-secondary, #777);
    line-height: 1.4;
}