/* ============================================
   LEAN TOOLS - Инструменты Lean
   ============================================ */

.lean-tools-section {
    padding: 12px 20px 20px;
}

/* Sub-tabs navigation */
.lean-tools-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    padding: 6px;
    background: #f8fafc;
    border-radius: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.lean-tool-tab {
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.lean-tool-tab:hover {
    background: #e2e8f0;
    color: #334155;
}

.lean-tool-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Tool content area */
.lean-tool-content {
    min-height: 400px;
}

/* ============================================
   ISHIKAWA DIAGRAM (Fishbone/Cause-Effect)
   ============================================ */

.ishikawa-container {
    padding: 20px;
}

.ishikawa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.ishikawa-header h2 {
    margin: 0;
    font-size: 24px;
    color: #1e293b;
}

.ishikawa-actions {
    display: flex;
    gap: 12px;
}

/* Diagrams list */
.ishikawa-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.ishikawa-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ishikawa-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.ishikawa-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.ishikawa-card-problem {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ishikawa-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #94a3b8;
}

/* Ishikawa diagram canvas */
.ishikawa-diagram {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    min-height: 500px;
}

.ishikawa-problem-input {
    text-align: center;
    margin-bottom: 24px;
}

.ishikawa-problem-input input {
    width: 100%;
    max-width: 500px;
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
    transition: border-color 0.2s;
}

.ishikawa-problem-input input:focus {
    outline: none;
    border-color: #667eea;
}

/* Categories (6M) */
.ishikawa-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 24px;
}

@media (max-width: 768px) {
    .ishikawa-categories {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .ishikawa-categories {
        grid-template-columns: 1fr;
    }
}

.ishikawa-category {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}

.ishikawa-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ishikawa-category-title {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ishikawa-category-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.ishikawa-add-cause {
    background: transparent;
    border: none;
    color: #667eea;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.ishikawa-add-cause:hover {
    background: #eef2ff;
}

.ishikawa-causes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ishikawa-cause {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #475569;
}

.ishikawa-cause input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: #475569;
}

.ishikawa-cause input:focus {
    outline: none;
}

.ishikawa-cause-delete {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 2px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.ishikawa-cause-delete:hover {
    opacity: 1;
}

/* Category colors */
.category-man .ishikawa-category-color { background: #3b82f6; }
.category-machine .ishikawa-category-color { background: #8b5cf6; }
.category-material .ishikawa-category-color { background: #f59e0b; }
.category-method .ishikawa-category-color { background: #10b981; }
.category-measurement .ishikawa-category-color { background: #ec4899; }
.category-environment .ishikawa-category-color { background: #6366f1; }

/* ============================================
   5 WHY ANALYSIS
   ============================================ */

.five-why-container {
    padding: 20px;
}

.five-why-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.five-why-header h2 {
    margin: 0;
    font-size: 24px;
    color: #1e293b;
}

/* 5 Why list */
.five-why-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.five-why-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.five-why-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* 5 Why analysis editor */
.five-why-editor {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
}

.five-why-problem {
    margin-bottom: 32px;
}

.five-why-problem label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}

.five-why-problem textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}

.five-why-problem textarea:focus {
    outline: none;
    border-color: #667eea;
}

.five-why-chain {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.five-why-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.five-why-number {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.five-why-step-content {
    flex: 1;
}

.five-why-step-content label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 6px;
}

.five-why-step-content input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.five-why-step-content input:focus {
    outline: none;
    border-color: #667eea;
}

.five-why-arrow {
    text-align: center;
    color: #94a3b8;
    font-size: 20px;
    margin: 8px 0;
    padding-left: 56px;
}

.five-why-root-cause {
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    border: 2px solid #10b981;
    border-radius: 12px;
}

.five-why-root-cause h4 {
    margin: 0 0 8px 0;
    color: #047857;
    font-size: 14px;
}

.five-why-root-cause p {
    margin: 0;
    color: #065f46;
    font-size: 16px;
    font-weight: 500;
}

/* ============================================
   VALUE STREAM MAPPING (VSM)
   ============================================ */

.vsm-container {
    padding: 20px;
}

.vsm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.vsm-header h2 {
    margin: 0;
    font-size: 24px;
    color: #1e293b;
}

/* VSM list */
.vsm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.vsm-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vsm-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* VSM Editor */
.vsm-editor {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
}

.vsm-process-flow {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    overflow-x: auto;
    padding: 20px 0;
}

.vsm-process-step {
    min-width: 200px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    flex-shrink: 0;
}

.vsm-process-step.supplier {
    background: #dbeafe;
    border-color: #3b82f6;
}

.vsm-process-step.customer {
    background: #dcfce7;
    border-color: #10b981;
}

.vsm-process-step.process {
    background: #fef3c7;
    border-color: #f59e0b;
}

.vsm-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.vsm-step-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

.vsm-step-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vsm-metric {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.vsm-metric-label {
    color: #64748b;
}

.vsm-metric-value {
    font-weight: 600;
    color: #334155;
}

.vsm-arrow {
    display: flex;
    align-items: center;
    color: #94a3b8;
    font-size: 24px;
    padding-top: 40px;
}

.vsm-add-step {
    min-width: 100px;
    height: 120px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    font-size: 32px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.vsm-add-step:hover {
    border-color: #667eea;
    color: #667eea;
    background: #eef2ff;
}

/* VSM Timeline */
.vsm-timeline {
    margin-top: 24px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
}

.vsm-timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.vsm-timeline-metric {
    text-align: center;
}

.vsm-timeline-metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
}

.vsm-timeline-metric-label {
    font-size: 12px;
    color: #64748b;
}

.vsm-timeline-metric.highlight .vsm-timeline-metric-value {
    color: #667eea;
}

/* ============================================
   EMPTY STATES
   ============================================ */

.lean-tool-empty {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.lean-tool-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.lean-tool-empty h3 {
    margin: 0 0 8px 0;
    color: #334155;
    font-size: 18px;
}

.lean-tool-empty p {
    margin: 0 0 24px 0;
    font-size: 14px;
}

/* ============================================
   MODALS FOR LEAN TOOLS
   ============================================ */

.lean-tool-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.lean-tool-modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.lean-tool-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.lean-tool-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1e293b;
}

.lean-tool-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
}

.lean-tool-modal-close:hover {
    color: #1e293b;
}

.lean-tool-modal-body {
    padding: 24px;
}

.lean-tool-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: white;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .lean-tools-tabs {
        gap: 4px;
        padding: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .lean-tools-tabs::-webkit-scrollbar {
        display: none;
    }

    .lean-tool-tab {
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .lean-tools-section {
        padding: 12px;
    }

    .ishikawa-header,
    .five-why-header,
    .vsm-header {
        flex-direction: column;
        align-items: stretch;
    }

    .ishikawa-actions {
        justify-content: center;
    }
}


/* ============================================
   AI VISION ANALYSIS — Phase 13.2
   ============================================ */

.ai-vision-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    vertical-align: middle;
    margin-left: 6px;
}

.ai-vision-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.ai-vision-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

/* Modal overlay */
.ai-vision-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: aiVisionFadeIn 0.2s ease;
}

@keyframes aiVisionFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-vision-modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.ai-vision-modal-header {
    padding: 14px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.ai-vision-provider {
    font-size: 10px;
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.ai-vision-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
}

.ai-vision-modal-close:hover { opacity: 1; }

.ai-vision-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.ai-vision-photo {
    width: 100%;
    border-radius: 10px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.ai-vision-photo:hover { transform: scale(1.02); }

/* Results content */
.ai-vision-desc {
    font-size: 14px;
    color: #1d1d1f;
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.ai-vision-overall {
    text-align: center;
    font-size: 16px;
    margin-bottom: 12px;
    color: #374151;
}

/* Score bars */
.ai-vision-scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.ai-vision-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-vision-score-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    min-width: 130px;
    flex-shrink: 0;
}

.ai-vision-bar-bg {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.ai-vision-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.ai-vision-score-val {
    font-size: 12px;
    font-weight: 700;
    color: #1d1d1f;
    min-width: 30px;
    text-align: right;
}

/* Badges */
.ai-vision-severity,
.ai-vision-condition {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
}

.ai-vision-anomaly-badge {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.ai-vision-category {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 12px;
    padding: 4px 10px;
    background: #f3f4f6;
    border-radius: 6px;
    display: inline-block;
}

/* Sections */
.ai-vision-section {
    margin-bottom: 12px;
}

.ai-vision-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
}

.ai-vision-list {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: #4b5563;
    line-height: 1.6;
}

.ai-vision-list li {
    margin-bottom: 2px;
}

/* Gemba waste items */
.ai-vision-waste-item {
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    background: #fefce8;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 13px;
}

.ai-vision-waste-type {
    font-weight: 700;
    color: #92400e;
    white-space: nowrap;
    min-width: 100px;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .ai-vision-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px;
    }

    .ai-vision-score-label {
        min-width: 90px;
        font-size: 11px;
    }

    .ai-vision-btn {
        padding: 3px 8px;
        font-size: 10px;
    }
}
