/* SG Workflow Frontend Styles */

/* Loading Overlay */
.sg-workflow-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sg-workflow-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sg-workflow-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #dc3545;
    border-radius: 50%;
    animation: sg-workflow-spin 1s linear infinite;
    background-color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.sg-workflow-loading-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 50px;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    background-color: white;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

@keyframes sg-workflow-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
body {
    background-color: #fafbfc;
    color: #34495e;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}

.sg-workflow-frontend {
    max-width: 100%;
    margin: 20px auto;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.sg-workflow-frontend h1 {
    margin: 0 0 30px 0;
    color: #34495e;
    font-size: 2.2em;
    font-weight: 600;
    text-align: left;
}

.sg-workflow-section {
    margin-bottom: 30px;
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e8f4f8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sg-workflow-section h2 {
    margin: 0 0 25px 0;
    color: #34495e;
    font-size: 1.5em;
    font-weight: 600;
    padding-bottom: 10px;
}

.sg-workflow-field {
    margin-bottom: 25px;
}

/* Two-column layout for priority and initiator */
.sg-workflow-field-row {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}

.sg-workflow-field-row .sg-workflow-field {
    flex: 1;
    margin-bottom: 0;
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
    .sg-workflow-field-row {
        flex-direction: column;
        gap: 20px;
    }
}

.sg-workflow-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #34495e;
    font-size: 15px;
}

.sg-workflow-field input,
.sg-workflow-field textarea,
.sg-workflow-field select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8f4f8;
    border-radius: 8px;
    font-size: 15px;
    color: #34495e;
    background: #ffffff;
    transition: all 0.3s ease;
    font-family: inherit;
}

.sg-workflow-field input:focus,
.sg-workflow-field textarea:focus,
.sg-workflow-field select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background: #ffffff;
}

.sg-workflow-field input:disabled {
    background: #f8f9fa;
    color: #7f8c8d;
    cursor: not-allowed;
}

.sg-workflow-field textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

/* Select Dropdowns - gleicher Style wie Textfelder */
#workflow-template,
#workflow-template.widefat,
#workflow-priority,
#workflow-priority.widefat,
.task-step-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8f4f8;
    border-radius: 8px;
    font-size: 15px;
    color: #34495e;
    background: #ffffff;
    transition: all 0.3s ease;
    font-family: inherit;
    height: auto;
    line-height: normal;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2334495e" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

#workflow-template:focus,
#workflow-template.widefat:focus,
#workflow-priority:focus,
#workflow-priority.widefat:focus,
.task-step-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background-color: #ffffff;
}

/* Template Selector */
.template-selector {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.template-selector select {
    flex: 1;
}

.template-selector .button {
    white-space: nowrap;
    padding: 14px 24px;
    background: #dc3545;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-selector .button:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* TinyMCE Editor */
.tinymce-editor {
    width: 100%;
    min-height: 250px;
}

/* TinyMCE Custom Styling */
.tox-tinymce {
    border: 2px solid #e8f4f8 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

.tox .tox-toolbar__primary {
    background: #f8f9fa !important;
    border-bottom: 1px solid #e8f4f8 !important;
    border-radius: 8px 8px 0 0 !important;
}

.tox .tox-edit-area__iframe {
    background: #ffffff !important;
}

.tox .tox-tbtn {
    color: #34495e !important;
}

.tox .tox-tbtn:hover {
    background: #3498db !important;
    color: #ffffff !important;
}

/* Tasks Management */
.tasks-container {
    background: #ffffff;
    border: 2px solid #e8f4f8;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.task-header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e8f4f8;
    font-weight: 600;
    color: #34495e;
    font-size: 15px;
}

.sortable-tasks {
    min-height: 60px;
}

/* Drag and Drop Styles */
.task-placeholder {
    background: #e3f2fd !important;
    border: 2px dashed #2196f3 !important;
    border-radius: 8px !important;
    height: 60px !important;
    margin: 5px 0 !important;
}

.task-row.ui-sortable-helper {
    background: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 8px !important;
    transform: rotate(2deg) !important;
}

.task-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
    padding: 20px;
    border-bottom: 1px solid #f1f3f4;
    align-items: center;
    background: #ffffff;
    cursor: move;
    transition: all 0.3s ease;
}

.task-row:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.task-row:last-child {
    border-bottom: none;
}

.task-placeholder {
    background: #e3f2fd;
    border: 2px dashed #3498db;
    border-radius: 8px;
    margin: 10px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3498db;
    font-weight: 600;
}

.task-explanation {
    grid-column: 1 / -1;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8f4f8;
}

.explanation-textarea {
    width: 100%;
    min-height: 100px;
    padding: 15px;
    border: 2px solid #e8f4f8;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    color: #34495e;
    background: #ffffff;
    resize: vertical;
    transition: all 0.3s ease;
}

.explanation-textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Task step select has custom arrow from above, user-select uses Select2 */
.user-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8f4f8;
    border-radius: 8px;
    font-size: 15px;
    color: #34495e;
    background: #ffffff;
    transition: all 0.3s ease;
    font-family: inherit;
}

.user-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Select2 styles moved to select2-custom.css for better organization */














.task-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.task-explanation-btn,
.task-add-btn,
.task-remove-btn {
    background: #f8f9fa;
    border: 2px solid #e8f4f8;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    color: #34495e;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-add-btn {
    background: #27ae60;
    color: #ffffff;
    border-color: #27ae60;
}

.task-add-btn:hover {
    background: #229954;
    border-color: #229954;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.task-remove-btn {
    background: #e74c3c;
    color: #ffffff;
    border-color: #e74c3c;
}

.task-remove-btn:hover {
    background: #c0392b;
    border-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.task-explanation-btn:hover {
    background: #3498db;
    color: #ffffff;
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* File Upload - Red Theme */
.file-upload-area {
    border: 2px dashed #d3d3d3;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background: #ececec;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
    border-color: #c82333;
    background: #ffe5e5;
    transform: scale(1.01);
}

.upload-content p {
    margin: 5px 0;
    color: #666;
}

.upload-content a {
    color: #dc3545;
    text-decoration: none;
    font-weight: 600;
}

.upload-content a:hover {
    color: #c82333;
    text-decoration: underline;
}

.file-types {
    font-size: 12px;
    color: #999;
}

.file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
    gap: 12px;
    transition: all 0.2s ease;
}

.file-item:hover {
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.1);
}

.file-name {
    font-weight: 500;
    color: #333;
    flex: 1;
    min-width: 0;
}

.file-size {
    color: #666;
    font-size: 12px;
    white-space: nowrap;
}

/* File Visibility Controls */
.file-visibility {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.visibility-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #007bff;
}

.visibility-btn:hover {
    background: rgba(0, 123, 255, 0.1);
    transform: scale(1.1);
}

.visibility-label {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    font-weight: 500;
}

/* New File Action Buttons */
.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.file-icon {
    font-size: 18px;
}

.file-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.file-visibility-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.file-visibility-btn:hover {
    border-color: #dc3545;
    background: #fff5f5;
}

.file-visibility-btn.public {
    background: #28a745;
    color: #fff;
    border-color: #28a745;
}

.file-visibility-btn.public:hover {
    background: #218838;
    border-color: #218838;
}

.file-remove-btn {
    padding: 6px 10px;
    border: 1px solid #dc3545;
    background: #fff;
    color: #dc3545;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.file-remove-btn:hover {
    background: #dc3545;
    color: #fff;
}

/* Legacy remove-file support */
.remove-file {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
}

.remove-file:hover {
    background: #c82333;
}

/* Responsive file item */
@media (max-width: 768px) {
    .file-item {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .file-name {
        flex-basis: 100%;
        margin-bottom: 4px;
    }
    
    .file-visibility {
        order: 2;
    }
    
    .file-size {
        order: 1;
    }
    
    .remove-file {
        order: 3;
    }
    
    .visibility-label {
        display: none;
    }
}

.sg-workflow-submit {
    margin-top: 40px;
    text-align: center;
}

.sg-workflow-btn {
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    min-width: 200px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sg-workflow-btn-primary {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.sg-workflow-btn-primary:hover {
    background: linear-gradient(135deg, #c82333, #a71d2a);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
}

.sg-workflow-btn-primary:disabled {
    background: #e9a7a7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sg-workflow-message {
    margin-top: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    text-align: center;
}

.sg-workflow-message-success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 2px solid #27ae60;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.2);
}

.sg-workflow-message-error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 2px solid #e74c3c;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sg-workflow-frontend {
        margin: 10px;
        padding: 15px;
    }
    
    .sg-workflow-field input,
    .sg-workflow-field textarea,
    .sg-workflow-field select {
        padding: 10px;
    }
    
    .sg-workflow-btn {
        width: 100%;
        padding: 14px;
    }
}

/* WordPress Theme Compatibility */
.sg-workflow-frontend .widefat {
    width: 100%;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .sg-workflow-frontend {
        border-color: #e8f4f8;
        color: #34495e;
    }
    
    .sg-workflow-frontend h3 {
        color: #fff;
    }
    
    .sg-workflow-field label {
        color: #ccc;
    }
    
    .sg-workflow-field input,
    .sg-workflow-field textarea,
    .sg-workflow-field select {
        background: #f8f9fa;
        border-color: #e8f4f8;
        color: #34495e;
    }
    
    .sg-workflow-field input:focus,
    .sg-workflow-field textarea:focus,
    .sg-workflow-field select:focus {
        border-color: #0073aa;
    }
}
