/* Workflow Widget Base Styles - Shared across all chat page widgets */
/* ALL styles scoped under .workflow-widget-container to prevent conflicts */

:root {
    /* Light theme variables */
    --default-widget-bg: #e7e5dc;
    --oaf-checklist-widget-bg: #f3f3f3;
    --shadow-color: rgb(151 151 151 / 51%);
    --widget-header-bg: #e1dfd6;
}

body.dark-theme {
    /* Dark theme variables */
    --default-widget-bg: #1a1a1a;
    --oaf-checklist-widget-bg: #020222;
    --shadow-color: rgb(151 151 151 / 51%);
    --widget-header-bg: #353535;
}

/* Container - Base styles for all workflow widgets */
.workflow-widget-container {
    position: fixed;
    /* background: var(--background-color, white);
    background: #f6f5f2;*/
    background: var(--default-widget-bg);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    /* box-shadow: 0 4px 12px rgb(151 151 151 / 51%); */
    z-index: 1000;
    transition: all 0.3s ease;
    overflow: visible; /* Changed from hidden to allow tooltips to show outside widget */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-color, #333);
}

.workflow-widget-container.workflow-oaf_assistant {
    background: var(--oaf-checklist-widget-bg);
}

/* Full view - covers entire chat area */
.workflow-widget-container.state-full {
    top: 65px;
    left: 265px;
    right: 5px;
    bottom: 5px;
    padding: 30px 30px 0;
}

/* Half view - side panel on right (chat visible on left) */
.workflow-widget-container.state-half {
    top: 80px;
    left: auto !important; /* Force reset left positioning from full view */
    right: 10px;
    bottom: 10px;
    width: 460px;
    max-width: 50%;
}

/* Collapsed - minimized panel on right edge */
.workflow-widget-container.state-collapsed {
    top: 80px;
    left: auto !important; /* Force reset left positioning from full view */
    right: 0;
    width: 60px;
    height: auto;
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Common widget header */
.workflow-widget-container .widget-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #eee);
    background: var(--header-bg, #f8f9fa);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.workflow-widget-container .widget-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.workflow-widget-container .widget-title h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color, #2c3e50);
    font-weight: 600;
}

/* Control buttons */
.workflow-widget-container .widget-controls {
    display: flex;
    gap: 8px;
}

.workflow-widget-container .btn-icon {
    background: var(--background-color, white);
    border: 1px solid var(--border-color, #ddd);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--icon-color, #7f8c8d);
    font-size: 14px;
    position: relative;
}

/* Disable browser default tooltip for buttons with custom tooltips */
.workflow-widget-container .btn-icon[title] {
    pointer-events: auto;
}

.workflow-widget-container .btn-icon[title]::after {
    pointer-events: none;
}

/* Instant tooltip appearance for all widget action buttons - positioned to the left */
.workflow-widget-container .btn-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    /* top: 50%;
    right: calc(100% + 8px);
    transform: translateY(-50%); */
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    animation: tooltip-fade-in 0.15s ease;
}

/* Tooltip arrow pointing to the right (towards the button) */
.workflow-widget-container .btn-icon[title]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    /* top: 50%;
    right: calc(100% + 2px);
    transform: translateY(-50%); */
    border: 6px solid transparent;
    border-left-color: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    pointer-events: none;
    animation: tooltip-fade-in 0.15s ease;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.workflow-widget-container .btn-icon:hover {
    background: var(--header-bg, #f8f9fa);
    border-color: #3498db;
    color: #3498db;
}

.workflow-widget-container .btn-icon:active {
    transform: scale(0.95);
}

/* Primary button */
.workflow-widget-container .btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.workflow-widget-container .btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.workflow-widget-container .btn-primary:active {
    transform: translateY(0);
}

/* Collapsed panel */
.workflow-widget-container .widget-collapsed-panel {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.workflow-widget-container .btn-expand {
    background: #c0c9d3;
    color: black;
    border: none;
    padding: 12px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.workflow-widget-container .btn-expand:hover {
    background: #87949e;
    color: white;
}

.workflow-widget-container .btn-expand i {
    font-size: 16px;
}

/* Error message */
.workflow-widget-container .error-message {
    color: #e74c3c;
    background: #fde8e8;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
    border: 1px solid #f5c6cb;
}

body.dark-theme .workflow-widget-container .error-message {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.4);
}

/* Success message */
.workflow-widget-container .success-message {
    color: #2ecc71;
    background: #d4edda;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
    border: 1px solid #c3e6cb;
}

body.dark-theme .workflow-widget-container .success-message {
    background: rgba(46, 204, 113, 0.2);
    border-color: rgba(46, 204, 113, 0.4);
}

/* Widget content area */
.workflow-widget-container .widget-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Widget footer */
.workflow-widget-container .widget-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color, #eee);
    background: var(--header-bg, #f8f9fa);
}

/* Progress indicators */
.workflow-widget-container .progress-bar {
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.workflow-widget-container .progress-fill {
    height: 100%;
    background: #2ecc71;
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Badge */
.workflow-widget-container .badge {
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.workflow-widget-container .badge-success {
    background: #2ecc71;
}

.workflow-widget-container .badge-warning {
    background: #f39c12;
}

.workflow-widget-container .badge-danger {
    background: #e74c3c;
}

.workflow-widget-container .badge-info {
    background: #3498db;
}

/* Loading spinner */
.workflow-widget-container .widget-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.workflow-widget-container .spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: workflow-widget-spin 1s linear infinite;
}

@keyframes workflow-widget-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .workflow-widget-container.state-half {
        width: 400px;
        max-width: 55%;
    }
}

@media (max-width: 768px) {
    .workflow-widget-container.state-full,
    .workflow-widget-container.state-half {
        top: 60px;
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        max-width: none;
    }

    .workflow-widget-container.state-collapsed {
        width: 50px;
    }
}

/* Scrollbar styling */
.workflow-widget-container .widget-content::-webkit-scrollbar {
    width: 8px;
}

.workflow-widget-container .widget-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.workflow-widget-container .widget-content::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

.workflow-widget-container .widget-content::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}
