/**
 * AlBND - Enhanced Workflows Styles
 * RCJY Dark Theme
 */

/* =========================================================================
   VARIABLES
   ========================================================================= */

:root {
    --wf-primary: var(--primary);
    --wf-success: var(--success);
    --wf-warning: var(--warning);
    --wf-danger: var(--danger);
    --wf-purple: #814FFF;
    --wf-navy: #052976;
    --wf-dark: var(--bg-primary);
    --wf-card-bg: var(--bg-card);
    --wf-border: rgba(76, 196, 255, 0.15);
    --wf-text: var(--text-primary);
    --wf-text-muted: var(--text-secondary);
}

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

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

/* =========================================================================
   STATISTICS
   ========================================================================= */

.workflow-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--wf-card-bg);
    border: 1px solid var(--wf-border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.stat-card.pending {
    border-left: 4px solid var(--wf-warning);
}

.stat-card.submitted {
    border-left: 4px solid var(--wf-primary);
}

.stat-card.approved {
    border-left: 4px solid var(--wf-success);
}

.stat-card.rejected {
    border-left: 4px solid var(--wf-danger);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card.pending .stat-icon {
    background: rgba(255, 176, 32, 0.15);
    color: var(--wf-warning);
}

.stat-card.submitted .stat-icon {
    background: rgba(76, 196, 255, 0.15);
    color: var(--wf-primary);
}

.stat-card.approved .stat-icon {
    background: rgba(32, 204, 118, 0.15);
    color: var(--wf-success);
}

.stat-card.rejected .stat-icon {
    background: rgba(255, 71, 87, 0.15);
    color: var(--wf-danger);
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--wf-text);
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--wf-text-muted);
    margin-top: 0.25rem;
}

.stat-urgent {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--wf-danger);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

[dir="rtl"] .stat-urgent {
    right: auto;
    left: 0.5rem;
}

/* =========================================================================
   TABS
   ========================================================================= */

.workflows-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--wf-card-bg);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--wf-border);
}

.workflow-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--wf-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.workflow-tab:hover {
    background: rgba(76, 196, 255, 0.1);
    color: var(--wf-text);
}

.workflow-tab.active {
    background: var(--wf-navy);
    color: white;
}

.workflow-tab i {
    font-size: 1rem;
}

.tab-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    min-width: 24px;
    text-align: center;
}

.workflow-tab.active .tab-badge {
    background: rgba(255, 255, 255, 0.3);
}

/* =========================================================================
   CONTENT PANELS
   ========================================================================= */

.workflows-content {
    background: var(--wf-card-bg);
    border: 1px solid var(--wf-border);
    border-radius: 12px;
    min-height: 400px;
}

.workflow-panel {
    display: none;
    padding: 1.5rem;
}

.workflow-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* =========================================================================
   WORKFLOW LIST
   ========================================================================= */

.workflow-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.workflow-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--wf-border);
    border-radius: 10px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.workflow-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--wf-primary);
}

.workflow-item.urgent {
    border-left: 3px solid var(--wf-danger);
}

[dir="rtl"] .workflow-item.urgent {
    border-left: none;
    border-right: 3px solid var(--wf-danger);
}

.workflow-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.workflow-item-type {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--wf-primary);
    font-size: 0.85rem;
}

.workflow-item-type i {
    font-size: 1rem;
}

.workflow-item-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.workflow-item-status.status-draft {
    background: rgba(139, 148, 158, 0.2);
    color: var(--text-secondary);
}

.workflow-item-status.status-submitted {
    background: rgba(76, 196, 255, 0.2);
    color: var(--wf-primary);
}

.workflow-item-status.status-review {
    background: rgba(255, 176, 32, 0.2);
    color: var(--wf-warning);
}

.workflow-item-status.status-approved {
    background: rgba(32, 204, 118, 0.2);
    color: var(--wf-success);
}

.workflow-item-status.status-rejected {
    background: rgba(255, 71, 87, 0.2);
    color: var(--wf-danger);
}

.workflow-item-status.status-returned {
    background: rgba(255, 176, 32, 0.2);
    color: var(--wf-warning);
}

.workflow-item-time {
    color: var(--wf-text-muted);
    font-size: 0.8rem;
}

.workflow-item-time.urgent {
    color: var(--wf-danger);
}

.workflow-item-time.urgent i {
    margin-right: 0.25rem;
}

[dir="rtl"] .workflow-item-time.urgent i {
    margin-right: 0;
    margin-left: 0.25rem;
}

.workflow-item-body {
    margin-bottom: 0.75rem;
}

.workflow-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--wf-text);
    margin: 0 0 0.5rem 0;
}

.workflow-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--wf-text-muted);
    font-size: 0.85rem;
}

.workflow-item-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.workflow-item-reviewer {
    margin-top: 0.5rem;
    color: var(--wf-primary);
    font-size: 0.85rem;
}

.workflow-item-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--wf-border);
}

.workflow-item-actions .btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* =========================================================================
   PROGRESS BAR
   ========================================================================= */

.workflow-progress-bar {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--wf-border);
}

.workflow-progress-bar.rejected,
.workflow-progress-bar.returned {
    padding: 0.75rem;
    border-radius: 8px;
    border-top: none;
}

.workflow-progress-bar.rejected {
    background: rgba(255, 71, 87, 0.1);
}

.workflow-progress-bar.returned {
    background: rgba(255, 176, 32, 0.1);
}

.progress-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.workflow-progress-bar.rejected .progress-message {
    color: var(--wf-danger);
}

.workflow-progress-bar.returned .progress-message {
    color: var(--wf-warning);
}

.progress-stages {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 0.5rem;
}

.progress-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
}

.stage-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(139, 148, 158, 0.3);
    border: 2px solid var(--wf-card-bg);
    transition: all 0.3s ease;
}

.progress-stage.completed .stage-dot {
    background: var(--wf-success);
}

.progress-stage.current .stage-dot {
    background: var(--wf-primary);
    box-shadow: 0 0 0 4px rgba(76, 196, 255, 0.3);
}

.stage-label {
    font-size: 0.7rem;
    color: var(--wf-text-muted);
    text-align: center;
}

.progress-stage.completed .stage-label,
.progress-stage.current .stage-label {
    color: var(--wf-text);
}

.progress-line {
    position: absolute;
    top: 5px;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(139, 148, 158, 0.2);
    z-index: 0;
}

.progress-fill {
    height: 100%;
    background: var(--wf-success);
    transition: width 0.5s ease;
}

/* =========================================================================
   TIMELINE
   ========================================================================= */

.workflow-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-group {
    position: relative;
}

.timeline-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wf-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--wf-border);
}

.timeline-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-left: 1.5rem;
    border-left: 2px solid var(--wf-border);
}

[dir="rtl"] .timeline-items {
    padding-left: 0;
    padding-right: 1.5rem;
    border-left: none;
    border-right: 2px solid var(--wf-border);
}

.timeline-item {
    display: flex;
    gap: 1rem;
    position: relative;
}

.timeline-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: absolute;
    left: -2.5rem;
    background: var(--wf-card-bg);
    border: 2px solid var(--wf-border);
}

[dir="rtl"] .timeline-icon {
    left: auto;
    right: -2.5rem;
}

.timeline-item.action-approve .timeline-icon {
    color: var(--wf-success);
    border-color: var(--wf-success);
}

.timeline-item.action-reject .timeline-icon {
    color: var(--wf-danger);
    border-color: var(--wf-danger);
}

.timeline-item.action-return .timeline-icon {
    color: var(--wf-warning);
    border-color: var(--wf-warning);
}

.timeline-item.action-submit .timeline-icon {
    color: var(--wf-primary);
    border-color: var(--wf-primary);
}

.timeline-item.action-sign .timeline-icon {
    color: var(--wf-purple);
    border-color: var(--wf-purple);
}

.timeline-content {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--wf-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.timeline-action {
    font-weight: 600;
    color: var(--wf-text);
    font-size: 0.9rem;
}

.timeline-time {
    color: var(--wf-text-muted);
    font-size: 0.75rem;
}

.timeline-body {
    color: var(--wf-text-muted);
    font-size: 0.85rem;
}

.timeline-body strong {
    color: var(--wf-text);
}

.timeline-by {
    margin-left: 0.5rem;
    color: var(--wf-primary);
}

[dir="rtl"] .timeline-by {
    margin-left: 0;
    margin-right: 0.5rem;
}

.timeline-comment {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(76, 196, 255, 0.1);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--wf-text-muted);
    font-style: italic;
}

/* =========================================================================
   EMPTY STATE
   ========================================================================= */

.workflow-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.workflow-empty i {
    font-size: 4rem;
    color: var(--wf-border);
    margin-bottom: 1.5rem;
}

.workflow-empty h3 {
    font-size: 1.25rem;
    color: var(--wf-text);
    margin: 0 0 0.5rem 0;
}

.workflow-empty p {
    color: var(--wf-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* =========================================================================
   CONFIRM MODAL
   ========================================================================= */

.workflow-confirm-modal {
    max-width: 480px;
}

.workflow-confirm-modal .modal-body p {
    margin: 0 0 1rem 0;
    color: var(--wf-text);
}

.workflow-confirm-modal .form-group {
    margin: 0;
}

.workflow-confirm-modal textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--wf-border);
    border-radius: 8px;
    color: var(--wf-text);
    padding: 0.75rem;
    width: 100%;
    resize: vertical;
}

.workflow-confirm-modal textarea:focus {
    border-color: var(--wf-primary);
    outline: none;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 22, 40, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    font-size: 3rem;
    color: var(--wf-primary);
}

/* =========================================================================
   TOAST
   ========================================================================= */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--wf-card-bg);
    border: 1px solid var(--wf-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--wf-text);
    font-size: 0.9rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

[dir="rtl"] .toast {
    right: auto;
    left: 2rem;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--wf-success);
}

.toast-success i {
    color: var(--wf-success);
}

.toast-error {
    border-left: 4px solid var(--wf-danger);
}

.toast-error i {
    color: var(--wf-danger);
}

.toast-info {
    border-left: 4px solid var(--wf-primary);
}

.toast-info i {
    color: var(--wf-primary);
}

[dir="rtl"] .toast-success,
[dir="rtl"] .toast-error,
[dir="rtl"] .toast-info {
    border-left: none;
    border-right-width: 4px;
    border-right-style: solid;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--wf-primary);
    color: var(--wf-navy);
}

.btn-primary:hover {
    background: #3db8f5;
}

.btn-success {
    background: var(--wf-success);
    color: white;
}

.btn-success:hover {
    background: #1ab86a;
}

.btn-warning {
    background: var(--wf-warning);
    color: var(--wf-navy);
}

.btn-warning:hover {
    background: #e5a01c;
}

.btn-danger {
    background: var(--wf-danger);
    color: white;
}

.btn-danger:hover {
    background: #e63e4d;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--wf-text);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-ghost {
    background: transparent;
    color: var(--wf-text-muted);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--wf-text);
}

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

@media (max-width: 1200px) {
    .workflow-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .workflow-stats {
        grid-template-columns: 1fr;
    }
    
    .workflows-tabs {
        flex-direction: column;
    }
    
    .workflow-tab {
        justify-content: flex-start;
    }
    
    .workflow-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .workflow-item-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .workflow-item-actions {
        flex-wrap: wrap;
    }
    
    .workflow-item-actions .btn {
        flex: 1;
        min-width: 80px;
    }
    
    .hide-mobile {
        display: none !important;
    }
    
    .progress-stages {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .progress-line {
        display: none;
    }
    
    .timeline-items {
        padding-left: 1rem;
    }
    
    [dir="rtl"] .timeline-items {
        padding-right: 1rem;
    }
    
    .timeline-icon {
        left: -1.75rem;
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    [dir="rtl"] .timeline-icon {
        right: -1.75rem;
    }
    
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .workflow-panel {
        padding: 1rem;
    }
    
    .workflow-item {
        padding: 0.75rem;
    }
}

/* =========================================================================
   PRINT
   ========================================================================= */

@media print {
    .workflows-tabs,
    .workflow-item-actions,
    .stat-urgent {
        display: none !important;
    }
    
    .workflows-container {
        background: white;
        color: black;
    }
    
    .workflow-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stat-card {
        border: 1px solid #ddd;
        background: white;
    }
    
    .stat-value {
        color: black;
    }
}
