* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --info: #2196F3;
    --light: #f8f9fa;
    --dark: #333;
    --border: #e0e0e0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.app-header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
    text-align: center;
}

.app-header h1 {
    color: var(--primary);
    font-size: 2.5em;
    margin-bottom: 10px;
}

.app-header p {
    color: #666;
    font-size: 1.2em;
}

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-tab {
    flex: 1;
    min-width: 150px;
    padding: 15px 25px;
    background: var(--light);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: var(--dark);
    transition: all 0.3s ease;
}

.nav-tab:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Content Sections */
.content-section {
    display: none;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s ease;
}

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

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

/* Workflow Library */
.workflow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.workflow-card {
    background: var(--light);
    border-radius: 15px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.workflow-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.workflow-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border-color: var(--primary);
}

.workflow-card h3 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 1.5em;
}

.workflow-card .stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.stat-number {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85em;
    color: #666;
}

.workflow-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Workflow Builder Form */
.builder-form {
    max-width: 900px;
    margin: 0 auto;
}

.form-section {
    margin-bottom: 40px;
    padding: 30px;
    background: var(--light);
    border-radius: 15px;
    border-left: 5px solid var(--primary);
}

.form-section h3 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-help {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
}

/* Dynamic List Builder */
.dynamic-list {
    margin-top: 15px;
}

.list-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.list-item input {
    flex: 1;
}

/* Stage Item with Conditional Logic */
.stage-item {
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.stage-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.stage-main {
    display: flex;
    gap: 10px;
    align-items: center;
}

.stage-main .stage-name {
    flex: 1;
    margin: 0;
}

.stage-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-substage {
    padding: 8px 15px;
    background: var(--light);
    color: var(--dark);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-substage:hover {
    background: var(--border);
}

.btn-substage.active {
    background: var(--info);
    color: white;
    border-color: var(--info);
}

.btn-conditional {
    padding: 8px 15px;
    background: var(--info);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-conditional:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.btn-conditional.active {
    background: var(--success);
}

.stage-substages {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--info);
}

.substage-item {
    margin-bottom: 10px;
}

.stage-conditional {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px dashed var(--border);
}

.conditional-branch {
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.conditional-branch label {
    min-width: 80px;
    font-weight: 600;
    font-size: 0.9em;
    color: var(--dark);
}

.conditional-branch input,
.conditional-branch select {
    flex: 1;
    margin: 0;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
}

.conditional-branch select {
    background: white;
    cursor: pointer;
}

.conditional-branch select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.conditional-branch:has(.branch-yes-target) select {
    border-color: var(--success);
}

.conditional-branch:has(.branch-no-target) select {
    border-color: var(--danger);
}

.btn-add-branch {
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
    margin-top: 10px;
}

.btn-add-branch:hover {
    background: var(--primary-dark);
}

.trigger-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--light);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s ease;
}

.trigger-checkbox:hover {
    background: var(--border);
}

.trigger-checkbox input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.trigger-checkbox input[type="radio"]:checked + span {
    color: var(--warning);
    font-weight: 600;
}

.final-result-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--light);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s ease;
}

.final-result-checkbox:hover {
    background: var(--border);
}

.final-result-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.final-result-checkbox input[type="checkbox"]:checked + span {
    color: var(--success);
    font-weight: 600;
}

/* Automation Item Styles */
.automation-item {
    margin-bottom: 10px;
}

.automation-main {
    display: flex;
    gap: 10px;
    align-items: center;
}

.automation-main .automation-description {
    flex: 2;
    margin: 0;
}

.automation-main .automation-stage {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
}

.automation-main .automation-stage:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Role Item Styles */
.role-item {
    margin-bottom: 10px;
}

.role-main {
    display: flex;
    gap: 10px;
    align-items: center;
}

.role-main .role-name {
    flex: 2;
    margin: 0;
}

.role-main .role-stage {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
}

.role-main .role-stage:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-remove {
    padding: 8px 15px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

.btn-add {
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 10px;
}

.btn-add:hover {
    background: #43a047;
}

/* Preview Section */
.preview-container {
    background: var(--light);
    padding: 30px;
    border-radius: 15px;
    margin-top: 30px;
}

.preview-container h4 {
    color: var(--primary);
    margin-bottom: 15px;
}

/* Export Options */
.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.export-card {
    background: var(--light);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.export-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.export-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.export-card h4 {
    color: var(--primary);
    margin-bottom: 10px;
}

/* Alert Messages */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 5px solid;
}

.alert-success {
    background: #d4edda;
    border-color: var(--success);
    color: #155724;
}

.alert-info {
    background: #d1ecf1;
    border-color: var(--info);
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border-color: var(--warning);
    color: #856404;
}

/* Loading Spinner */
.spinner {
    border: 4px solid var(--light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Responsive */
@media (max-width: 768px) {
    .workflow-grid {
        grid-template-columns: 1fr;
    }

    .nav-tabs {
        flex-direction: column;
    }

    .nav-tab {
        width: 100%;
    }
}

/* Flowchart Container */
.flowchart-display {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid var(--border);
    margin-top: 20px;
}

.mermaid {
    display: flex;
    justify-content: center;
}

/* Workflow Detail View */
.workflow-detail {
    display: none;
}

.workflow-detail.active {
    display: block;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--border);
}

.detail-header h2 {
    color: var(--primary);
    font-size: 2em;
}

.back-btn {
    padding: 10px 20px;
    background: var(--light);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tabs-container {
    margin-top: 30px;
}

.detail-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 30px;
}

.detail-tab {
    padding: 12px 25px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
}

.detail-tab:hover {
    color: var(--primary);
}

.detail-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.detail-content {
    display: none;
}

.detail-content.active {
    display: block;
}

