/* ========================================
   D-One Agent Pages - Specific Styles
   ======================================== */

/* ========================================
   LAYOUT & STRUCTURE
   ======================================== */

body.agent-page {
    font-family: var(--font-sans);
    background: var(--bg-body);
    min-height: 100vh;
    overflow-x: hidden;
}

.main-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    width: 90%;
    /* max-width: var(--container-max-width); */
    margin: 0 auto;
    padding: var(--space-4);
}

/* Full-width layout variant - rimuove i limiti di larghezza per layout tipo gallery */
.main-layout.full-width {
    width: 100%;
    max-width: 100%;
    padding: var(--space-4) var(--space-6);
}

@media (max-width: 768px) {
    .main-layout.full-width {
        padding: var(--space-3) var(--space-4);
    }
}

/* ========================================
   PAGE HEADER (come image_media_generator)
   ======================================== */

.page-header {
    background: var(--gradient-primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
    margin-top: 40px;
    margin-bottom:0px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    color: white;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    color: white;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.page-title i {
    color: white;
    font-size: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.page-subtitle {
    font-size: var(--font-size-lg);
    color: rgba(255, 255, 255, 0.9);
    margin: var(--space-4) 0 0 0;
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ========================================
   CONFIGURATION AREA
   ======================================== */

.config-area {
    margin-bottom: var(--space-3);
}

.top-config-row {
    margin-bottom: var(--space-6);
}

/* URL Input Section */
.url-input-with-buttons {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

.url-input-container {
    flex: 1;
    min-width: 0;
    position: relative;
}

.url-input {
    width: 100%;
    padding: var(--space-4) calc(var(--space-4) + var(--space-8)) var(--space-4) var(--space-4);
    border: var(--form-border-width) solid var(--primary);
    border-radius: var(--form-border-radius);
    font-size: var(--font-size-base);
    background: var(--bg-card);
    transition: var(--transition-base);
    color: var(--text-primary);
}

.url-input:focus {
    border-color: var(--primary-hover);
    box-shadow: var(--form-focus-shadow);
    outline: none;
}

.url-icon {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
}

.url-input:valid + .url-icon {
    color: var(--success);
}

.url-action-buttons {
    display: flex;
    gap: var(--space-3);
    flex-shrink: 0;
    align-items: center;
}

/* Settings Layout */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    align-items: flex-start;
}

.settings-column {
    min-width: 0;
}

/* Audio Settings Grid */
.audio-settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.audio-setting-field {
    min-width: 0;
}

/* Synthesis Settings Grid */
.synthesis-settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-4);
}

.synthesis-setting-field {
    min-width: 0;
}

/* Action Buttons Row */
.action-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

/* ========================================
   PROGRESS INDICATOR
   ======================================== */

.progress-container {
    margin: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(10px);
}

.progress-wrapper {
    text-align: center;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
}

.progress-title {
    color: var(--text-primary);
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.progress-percentage {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-lg);
    min-width: 60px;
    box-shadow: var(--shadow-lg);
}

.progress-bar-container {
    margin-bottom: var(--space-6);
}

.progress-bar {
    height: 12px;
    border-radius: var(--radius-md);
    background: rgba(102, 126, 234, 0.1);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    position: relative;
    overflow: hidden;
}

.progress-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progress-glow 2s infinite;
}

@keyframes progress-glow {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Step Indicator */
.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    gap: var(--space-4);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.step-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.1);
    border: 3px solid rgba(102, 126, 234, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 18px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: var(--space-2);
}

.step.active .step-circle {
    background: var(--gradient-primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.step.completed .step-circle {
    background: var(--gradient-secondary);
    border-color: var(--success);
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.step-label {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-align: center;
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-1);
}

.step.active .step-label {
    color: var(--primary);
    font-weight: var(--font-weight-semibold);
}

.step.completed .step-label {
    color: var(--success);
    font-weight: var(--font-weight-semibold);
}

.step-status {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    min-height: 14px;
}

.step.active .step-status {
    color: var(--primary);
}

.step.completed .step-status {
    color: var(--success);
}

.current-step-info {
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    border-left: 4px solid var(--primary);
}

.step-description {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
    font-size: var(--font-size-base);
}

.step-details {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-base);
}

/* ========================================
   CONFIGURATION CARDS
   ======================================== */

.config-card {
    background: var(--bg-card);
    border-radius: var(--card-border-radius);
    padding: var(--card-padding);
    margin-bottom: var(--space-3);
    box-shadow: var(--card-shadow);
}

.config-card h5 {
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    font-weight: var(--font-weight-semibold);
}

/* Form Elements */
.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.form-select, .form-control {
    width: 100%;
    padding: var(--form-padding);
    border: var(--form-border-width) solid var(--border-color);
    border-radius: var(--form-border-radius);
    font-size: var(--font-size-base);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.form-select:focus, .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--form-focus-shadow);
}

/* ========================================
   SYNTHESIS AREA
   ======================================== */

.synthesis-area {
    margin-bottom: 0;
}

.synthesis-panel {
    min-width: 0;
}

/* Results Tabs */
.results-tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
}

.results-tab {
    flex: 1;
    padding: var(--space-3) var(--space-5);
    border: none;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.results-tab.active {
    background: var(--bg-card);
    color: var(--success);
    font-weight: var(--font-weight-semibold);
}

.results-tab:hover {
    background: var(--bg-card);
}

.results-content {
    background: var(--bg-card);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: var(--space-5);
    min-height: 400px;
    box-shadow: var(--card-shadow);
}

.result-section {
    display: none;
}

.result-section.active {
    display: block;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.result-title {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.result-actions {
    display: flex;
    gap: var(--space-3);
}

.result-text {
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* ========================================
   STATUS MESSAGES
   ======================================== */

.status-message {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin: var(--space-3) 0;
    font-weight: var(--font-weight-medium);
}

.status-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ========================================
   BUTTONS
   ======================================== */

.btn-primary {
    background: var(--gradient-secondary);
    border: none;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    font-weight: var(--btn-font-weight);
    transition: var(--transition-base);
    border-radius: var(--btn-border-radius);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: var(--text-muted);
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* ========================================
   LOG CONTAINER
   ======================================== */

.log-container {
    background: var(--bg-surface-alt);
    border: var(--form-border-width) solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    height: 200px;
    max-height: 30vh;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: var(--font-size-base);
    transition: var(--transition-base);
}

.log-content {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: var(--line-height-base);
}

.log-info {
    color: var(--info);
    margin-bottom: var(--space-1);
}

.log-success {
    color: var(--success);
    margin-bottom: var(--space-1);
}

.log-warning {
    color: var(--warning);
    margin-bottom: var(--space-1);
}

.log-error {
    color: var(--danger);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-1);
}

/* Log Toggle Animation */
.log-container.collapsed {
    max-height: 0;
    padding: 0 var(--space-5);
    opacity: 0;
}

/* ========================================
   GENERATOR CARD
   ======================================== */

.generator-card {
    background: var(--bg-card);
    border-radius: var(--card-border-radius);
    padding: var(--space-6);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--space-3);
}

.section-title {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-xl);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .main-layout {
        width: 95%;
        padding: var(--space-3);
    }

    .synthesis-content {
        grid-template-columns: 1fr;
        gap: var(--space-5);
    }

    .config-panel {
        min-width: unset;
    }

    .step-indicator {
        flex-wrap: wrap;
        gap: var(--space-3);
    }

    .step {
        min-width: 80px;
    }

    .settings-row {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .audio-settings-row {
        grid-template-columns: 1fr;
    }

    .synthesis-settings-row {
        grid-template-columns: 1fr;
    }

    .action-buttons-row {
        grid-template-columns: 1fr;
    }

    .url-input-with-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .url-action-buttons {
        justify-content: center;
        margin-top: var(--space-3);
    }

    .result-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: flex-start;
    }
}

/* ========================================
   DARK THEME OVERRIDES
   ======================================== */

html[data-theme='dark'] .agent-page {
    background: var(--bg-body);
}

html[data-theme='dark'] .config-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

html[data-theme='dark'] .results-tabs .results-tab {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

html[data-theme='dark'] .results-tabs .results-tab.active {
    background: var(--bg-card);
}

html[data-theme='dark'] .result-text {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}

html[data-theme='dark'] .log-container {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

html[data-theme='dark'] .generator-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

/* ========================================
   CONTENT PREVIEW (SHARED COMPONENT)
   ======================================== */

.content-preview {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    max-height: 80%;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    white-space: pre-wrap;
    line-height: 1.4;
    color: var(--text-primary);
    transition: var(--transition-base);
}

.content-preview.collapsed {
    max-height: 0;
    padding: 0 var(--space-4);
    opacity: 0;
    overflow: hidden;
}
