/* =========================================================
   Phase 7: Executive Factory Profile Workspace
   Premium, Modern, Elegant, Responsive, Arabic RTL
========================================================= */

.factory-workspace {
    display: none;
    flex-direction: column;
    gap: 20px;
    padding: 10px;
    animation: fadeIn 0.3s ease-in-out;
}

.factory-workspace.active {
    display: flex;
}

/* Header & Quick Actions */
.workspace-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.workspace-header::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
    pointer-events: none;
}

.workspace-title-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1;
}

.workspace-title-area h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.factory-status-badge {
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
}

.factory-health-stars {
    color: #fbbf24;
    letter-spacing: 2px;
    font-size: 18px;
}

.workspace-meta {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #cbd5e1;
}

.workspace-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Quick Actions Bar - Sticky */
.quick-actions-bar {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    gap: 12px;
    z-index: 100;
    border: 1px solid #e2e8f0;
}

.btn-quick-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8fafc;
    color: #334155;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn-quick-action:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.btn-quick-action.primary {
    background: #3b82f6;
    color: white;
}

.btn-quick-action.primary:hover {
    background: #2563eb;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.kpi-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
}

.kpi-card-icon {
    position: absolute;
    top: -10px;
    left: -10px;
    font-size: 80px;
    opacity: 0.03;
    color: currentColor;
}

.kpi-card h4 {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
}

.kpi-card .value {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.kpi-card .currency {
    font-size: 14px;
    color: #94a3b8;
}

.kpi-card.highlight {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #bfdbfe;
}
.kpi-card.highlight .value { color: #1d4ed8; }
.kpi-card.danger {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fecaca;
}
.kpi-card.danger .value { color: #b91c1c; }

/* Tabs Layout */
.workspace-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.workspace-tabs {
    display: flex;
    gap: 8px;
    background: white;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    overflow-x: auto;
}

.workspace-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.workspace-tab:hover {
    background: #f8fafc;
    color: #334155;
}

.workspace-tab.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.workspace-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    min-height: 400px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

/* Unified Activity Timeline */
.timeline-container {
    padding: 10px 0;
}

.timeline-event {
    position: relative;
    padding-right: 40px;
    padding-bottom: 24px;
}

.timeline-event::before {
    content: '';
    position: absolute;
    right: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.timeline-event:last-child::before {
    display: none;
}

.timeline-icon {
    position: absolute;
    right: 0;
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 1;
}

.timeline-event.type-factory_created .timeline-icon { color: #3b82f6; border-color: #3b82f6; }
.timeline-event.type-cost_sheet_created .timeline-icon { color: #8b5cf6; border-color: #8b5cf6; }
.timeline-event.type-production_run .timeline-icon { color: #10b981; border-color: #10b981; }
.timeline-event.type-expense .timeline-icon { color: #ef4444; border-color: #ef4444; }
.timeline-event.type-payment .timeline-icon { color: #f59e0b; border-color: #f59e0b; }

.timeline-content {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-details h4 {
    margin: 0 0 4px 0;
    font-size: 15px;
    color: #1e293b;
}

.timeline-details p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

.timeline-date {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}

.timeline-amount {
    font-weight: 700;
    font-size: 16px;
    color: #0f172a;
}

/* Manufacturing Model Cards */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.model-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.model-card:hover {
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    border-color: #cbd5e1;
    transform: translateY(-4px);
}

.model-image-placeholder {
    height: 160px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #94a3b8;
}

.model-card-body {
    padding: 20px;
}

.model-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.model-code {
    background: #1e293b;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    font-weight: bold;
}

.model-name {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.model-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.model-stat-item {
    display: flex;
    flex-direction: column;
}

.model-stat-item label {
    font-size: 12px;
    color: #64748b;
}

.model-stat-item span {
    font-size: 16px;
    font-weight: 700;
    color: #334155;
}

.model-card-footer {
    border-top: 1px solid #f1f5f9;
    padding-top: 16px;
    display: flex;
    justify-content: space-between;
}

.model-card-footer .btn {
    width: 100%;
}

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

/* Two-column layout for dashboard */
.dashboard-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}
