/* ============= Gemba Walk Module (Phase 6.4) ============= */

/* ---- Header & Controls ---- */
.gemba-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.gemba-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #1d1d1f);
    margin: 0;
}

.gemba-header-actions {
    display: flex;
    gap: 8px;
}

.gemba-btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gemba-btn-primary {
    background: #0071e3;
    color: #fff;
}
.gemba-btn-primary:hover {
    background: #0077ed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.gemba-btn-secondary {
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
}
.gemba-btn-secondary:hover {
    background: rgba(0, 113, 227, 0.15);
}

.gemba-btn-success {
    background: #34c759;
    color: #fff;
}
.gemba-btn-success:hover {
    background: #30b350;
}

.gemba-btn-danger {
    background: #ff3b30;
    color: #fff;
}
.gemba-btn-danger:hover {
    background: #e0352b;
}

.gemba-btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ---- Filter Bar ---- */
.gemba-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.gemba-filter-select {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    font-size: 0.85rem;
    color: var(--text-primary, #1d1d1f);
    outline: none;
    min-width: 140px;
}
.gemba-filter-select:focus {
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* ---- Tabs (Routes / Walks / Stats) ---- */
.gemba-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 4px;
}

.gemba-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #86868b;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.gemba-tab.active {
    background: #fff;
    color: #0071e3;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.gemba-tab:hover:not(.active) {
    color: #1d1d1f;
}

/* ---- Walk Cards Grid ---- */
.gemba-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.gemba-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}
.gemba-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.gemba-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.gemba-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
    flex: 1;
}

.gemba-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.gemba-card-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #86868b;
}

.gemba-card-meta-item .icon {
    font-size: 0.9rem;
}

.gemba-card-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.gemba-card-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.03);
}

.gemba-card-stat.findings {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}
.gemba-card-stat.critical {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}
.gemba-card-stat.checkpoints {
    color: #0071e3;
    background: rgba(0, 113, 227, 0.08);
}

/* ---- Status Badge ---- */
.gemba-status {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.gemba-status.planned {
    background: rgba(0, 113, 227, 0.1);
    color: #0071e3;
}
.gemba-status.in_progress {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}
.gemba-status.completed {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

/* ---- Severity Badge ---- */
.gemba-severity {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}
.gemba-severity.low {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}
.gemba-severity.medium {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}
.gemba-severity.high {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.gemba-severity.critical {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

/* ---- Priority Badge ---- */
.gemba-priority {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
}
.gemba-priority.low {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}
.gemba-priority.medium {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}
.gemba-priority.high {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.gemba-priority.urgent {
    background: rgba(220, 38, 38, 0.2);
    color: #dc2626;
}

/* ---- Finding Type Badge ---- */
.gemba-finding-type {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
}
.gemba-finding-type.positive {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}
.gemba-finding-type.issue {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.gemba-finding-type.improvement {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}
.gemba-finding-type.safety {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

/* ---- Walk Detail View ---- */
.gemba-detail {
    max-width: 900px;
}

.gemba-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 12px;
}

.gemba-detail-info {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

.gemba-detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gemba-detail-info-item .label {
    font-size: 0.7rem;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.gemba-detail-info-item .value {
    font-size: 0.9rem;
    color: #1d1d1f;
    font-weight: 500;
}

/* ---- Checkpoints Accordion ---- */
.gemba-checkpoint {
    background: #fff;
    border-radius: 14px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.gemba-checkpoint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.gemba-checkpoint-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.gemba-checkpoint-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1d1d1f;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gemba-checkpoint-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0071e3;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.gemba-checkpoint-toggle {
    font-size: 1.1rem;
    color: #86868b;
    transition: transform 0.2s ease;
}
.gemba-checkpoint.open .gemba-checkpoint-toggle {
    transform: rotate(180deg);
}

.gemba-checkpoint-body {
    display: none;
    padding: 0 20px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}
.gemba-checkpoint.open .gemba-checkpoint-body {
    display: block;
}

.gemba-checkpoint-desc {
    font-size: 0.8rem;
    color: #86868b;
    margin-bottom: 14px;
    padding-top: 12px;
}

/* ---- Checklist Items ---- */
.gemba-checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.85rem;
    color: #1d1d1f;
}
.gemba-checklist-item:last-child {
    border-bottom: none;
}

.gemba-checklist-check {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: transparent;
}
.gemba-checklist-check.checked {
    background: #34c759;
    border-color: #34c759;
    color: #fff;
}

/* ---- Findings Section ---- */
.gemba-findings-section {
    margin-top: 24px;
}

.gemba-findings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.gemba-findings-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1d1d1f;
}

.gemba-finding-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-left: 4px solid;
}
.gemba-finding-card.severity-low {
    border-left-color: #10b981;
}
.gemba-finding-card.severity-medium {
    border-left-color: #f59e0b;
}
.gemba-finding-card.severity-high {
    border-left-color: #ef4444;
}
.gemba-finding-card.severity-critical {
    border-left-color: #dc2626;
}

.gemba-finding-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
}

.gemba-finding-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1d1d1f;
    flex: 1;
}

.gemba-finding-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.gemba-finding-desc {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.gemba-finding-photo {
    width: 100%;
    max-width: 300px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

.gemba-finding-photos {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.gemba-finding-photo-wrapper {
    position: relative;
}
.gemba-finding-photo-wrapper .photo-label {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.gemba-finding-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ---- Actions Section ---- */
.gemba-actions-section {
    margin-top: 24px;
}

.gemba-action-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.gemba-action-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: transparent;
    margin-top: 2px;
}
.gemba-action-checkbox.completed {
    background: #34c759;
    border-color: #34c759;
    color: #fff;
}

.gemba-action-content {
    flex: 1;
}

.gemba-action-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 4px;
}
.gemba-action-title.completed-text {
    text-decoration: line-through;
    color: #86868b;
}

.gemba-action-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: #86868b;
}

/* ---- Route Cards ---- */
.gemba-route-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
}
.gemba-route-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.gemba-route-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.gemba-route-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1d1d1f;
}

.gemba-route-card-desc {
    font-size: 0.8rem;
    color: #86868b;
    margin-bottom: 12px;
}

.gemba-route-card-stats {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: #86868b;
}

/* ---- Stats View ---- */
.gemba-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.gemba-stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.gemba-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #0071e3;
    margin-bottom: 4px;
}

.gemba-stat-label {
    font-size: 0.75rem;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.gemba-chart-container {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.gemba-chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 16px;
}

.gemba-chart-canvas {
    width: 100%;
    height: 250px;
}

.gemba-zone-ranking {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.gemba-zone-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.gemba-zone-row:last-child {
    border-bottom: none;
}

.gemba-zone-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1d1d1f;
}

.gemba-zone-stats {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: #86868b;
}

.gemba-zone-bar {
    width: 100px;
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    overflow: hidden;
}
.gemba-zone-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(135deg, #0071e3, #34c759);
    transition: width 0.5s ease;
}

/* ---- Severity Distribution Chart ---- */
.gemba-severity-chart {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    justify-content: center;
    height: 200px;
    padding: 20px 0;
}

.gemba-severity-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gemba-severity-bar-fill {
    width: 48px;
    border-radius: 8px 8px 0 0;
    transition: height 0.5s ease;
    min-height: 4px;
}
.gemba-severity-bar-fill.low {
    background: #10b981;
}
.gemba-severity-bar-fill.medium {
    background: #f59e0b;
}
.gemba-severity-bar-fill.high {
    background: #ef4444;
}
.gemba-severity-bar-fill.critical {
    background: #dc2626;
}

.gemba-severity-bar-label {
    font-size: 0.7rem;
    color: #86868b;
    font-weight: 600;
    text-transform: uppercase;
}

.gemba-severity-bar-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1d1d1f;
}

/* ---- Modal ---- */
.gemba-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.gemba-modal {
    background: #fff;
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.gemba-modal h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0 0 20px 0;
}

.gemba-form-group {
    margin-bottom: 16px;
}

.gemba-form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #86868b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.gemba-form-input,
.gemba-form-select,
.gemba-form-textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    color: #1d1d1f;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.gemba-form-input:focus,
.gemba-form-select:focus,
.gemba-form-textarea:focus {
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.gemba-form-textarea {
    min-height: 80px;
    resize: vertical;
}

.gemba-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ---- Template Cards ---- */
.gemba-template-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.gemba-template-card {
    padding: 14px;
    border-radius: 12px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.gemba-template-card:hover {
    border-color: #0071e3;
    background: rgba(0, 113, 227, 0.04);
}
.gemba-template-card.selected {
    border-color: #0071e3;
    background: rgba(0, 113, 227, 0.08);
}

.gemba-template-card .icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}
.gemba-template-card .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1d1d1f;
}
.gemba-template-card .desc {
    font-size: 0.7rem;
    color: #86868b;
    margin-top: 4px;
}

/* ---- Empty State ---- */
.gemba-empty {
    text-align: center;
    padding: 60px 20px;
    color: #86868b;
}

.gemba-empty .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.gemba-empty .title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 8px;
}

.gemba-empty .desc {
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* ---- Back Button ---- */
.gemba-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    background: none;
    border: none;
    font-size: 0.9rem;
    color: #0071e3;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 16px;
}
.gemba-back-btn:hover {
    text-decoration: underline;
}

/* ---- Photo Upload ---- */
.gemba-photo-upload {
    width: 100%;
    padding: 20px;
    border: 2px dashed rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    color: #86868b;
}
.gemba-photo-upload:hover {
    border-color: #0071e3;
    background: rgba(0, 113, 227, 0.03);
}

.gemba-photo-preview {
    width: 100%;
    max-width: 200px;
    border-radius: 8px;
    margin-top: 8px;
}

/* ---- Loading ---- */
.gemba-loading {
    text-align: center;
    padding: 40px;
    color: #86868b;
    font-size: 0.9rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .gemba-cards-grid {
        grid-template-columns: 1fr;
    }

    .gemba-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .gemba-detail-info {
        flex-direction: column;
    }

    .gemba-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gemba-template-cards {
        grid-template-columns: 1fr;
    }

    .gemba-severity-chart {
        height: 160px;
    }
}

@media (max-width: 480px) {
    .gemba-stats-grid {
        grid-template-columns: 1fr;
    }

    .gemba-finding-card-header {
        flex-direction: column;
    }

    .gemba-card-stats {
        flex-direction: column;
    }

    .gemba-modal-overlay {
        padding: 8px;
    }

    .gemba-modal {
        max-width: 100%;
        border-radius: 14px;
        padding: 20px;
    }

    .gemba-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .gemba-tabs::-webkit-scrollbar {
        display: none;
    }
    .gemba-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .gemba-checklist-check {
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 10px;
    }

    .gemba-action-checkbox {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .gemba-chart-canvas {
        height: 200px;
    }

    .gemba-finding-photos {
        flex-direction: column;
    }

    .gemba-finding-photo {
        max-width: 100%;
    }
}
