﻿/* Inspection Detail - Mobile First */
/* Reuses service styles with inspection-specific overrides */

/* ========== Tab Navigation ========== */

.dashboard-tabs {
    display: flex;
    gap: 0;
    background: #ffffff;
    border-bottom: 2px solid #e2e8f0;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-button {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s;
    text-decoration: none;
    margin-bottom: -2px;
}

.tab-button * { pointer-events: none; }
.tab-button:hover { color: #059669; background: #f8fafc; }
.tab-button.active { color: #059669; border-bottom-color: #059669; background: transparent; }
.tab-button i { font-size: 16px; }

@media (max-width: 479px) {
    .dashboard-tabs { justify-content: center; padding: 0; }
    .tab-button { flex: 1; justify-content: center; padding: 12px 8px; }
    .tab-label { display: none; }
}

/* ========== Page Header ========== */

.page-header {
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff;
    padding: 20px 16px;
    margin-bottom: 0;
}

.page-header-inner { display: flex; align-items: center; justify-content: space-between; }
.page-header-left { display: flex; align-items: center; gap: 12px; }
.page-header-title { font-size: 18px; font-weight: 700; margin: 0; line-height: 1.2; }

.back-btn {
    width: 36px; height: 36px; border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff; display: flex; align-items: center; justify-content: center;
    font-size: 14px; text-decoration: none; transition: all 0.2s;
}
.back-btn:hover { background: rgba(255, 255, 255, 0.25); border-color: rgba(255, 255, 255, 0.5); color: #ffffff; }
.back-btn:active { transform: scale(0.95); }

/* ========== Content ========== */

.inspection-content { padding: 16px; }
.inspection-loading { display: flex; flex-direction: column; gap: 12px; }

.loading-pulse {
    background: #e2e8f0; border-radius: 12px;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ========== Error State ========== */

.inspection-error { text-align: center; padding: 48px 24px; background: #ffffff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
.inspection-error .empty-icon { width: 64px; height: 64px; background: #fee2e2; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 28px; color: #dc2626; }
.inspection-error .empty-title { font-size: 18px; font-weight: 700; color: #1e293b; margin: 0 0 8px; }
.inspection-error .empty-description { font-size: 14px; color: #64748b; margin: 0 0 16px; }
.back-link { display: inline-block; color: #059669; font-weight: 600; font-size: 14px; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ========== Cards ========== */

.service-card { background: #ffffff; border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
.service-card-label { font-size: 12px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.service-badge-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.service-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.service-title-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.service-title { font-size: 18px; font-weight: 700; color: #1e293b; margin: 0; line-height: 1.3; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Status Badge */
.service-status-badge { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; flex-shrink: 0; }
.service-status-badge.status-pending { background: #fef3c7; color: #92400e; }
.service-status-badge.status-scheduled { background: #dbeafe; color: #1e40af; }
.service-status-badge.status-in-progress { background: #d1fae5; color: #065f46; }
.service-status-badge.status-completed { background: #f0fdf4; color: #166534; }
.service-status-badge.status-on-hold { background: #fee2e2; color: #991b1b; }
.service-status-badge.status-cancelled { background: #f1f5f9; color: #475569; }

/* Type Badge */
.job-type-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; }
.job-type-badge.type-inspection { background: #ede9fe; color: #6d28d9; }

/* Buttons */
.change-status-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid #e2e8f0; border-radius: 8px; background: #ffffff; color: #3b82f6; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.change-status-btn:active { transform: scale(0.97); }
.change-status-btn i { font-size: 12px; }

.start-job-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: none; border-radius: 8px; background: #059669; color: #ffffff; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.start-job-btn:hover { background: #047857; }
.start-job-btn:active { transform: scale(0.97); }
.start-job-btn i { font-size: 11px; }

/* Detail List */
.service-detail-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.service-detail-item { display: flex; align-items: center; gap: 12px; }
.service-detail-item > i { width: 20px; text-align: center; font-size: 14px; color: #94a3b8; flex-shrink: 0; }
.service-detail-label { font-size: 11px; color: #94a3b8; font-weight: 500; }
.service-detail-value { font-size: 14px; color: #1e293b; font-weight: 600; }
.service-detail-sub { font-size: 12px; color: #64748b; margin-top: 1px; }

/* Attributes & Assignees */
.service-meta-row { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.service-attribute-list { display: flex; flex-wrap: wrap; gap: 8px; }
.service-attribute-chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; color: #ffffff; }
.service-assignee-list { display: flex; flex-wrap: wrap; gap: 8px; }
.service-assignee-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: #f1f5f9; border-radius: 20px; font-size: 13px; font-weight: 500; color: #475569; }
.service-assignee-chip i { font-size: 12px; color: #94a3b8; }

/* Description */
.service-description { font-size: 14px; color: #475569; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }
.service-description-empty { font-size: 14px; color: #94a3b8; font-style: italic; }

/* ========== Status Bottom Sheet ========== */

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.status-sheet { position: fixed; bottom: 0; left: 0; right: 0; background: #ffffff; border-radius: 16px 16px 0 0; padding: 0 16px 24px; z-index: 1001; max-height: 70vh; overflow-y: auto; }
.status-sheet-handle { width: 36px; height: 4px; background: #cbd5e1; border-radius: 2px; margin: 10px auto 0; }
.status-sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 12px; }
.status-sheet-title { font-size: 16px; font-weight: 700; color: #1e293b; margin: 0; }
.status-sheet-close { width: 32px; height: 32px; border: none; border-radius: 50%; background: #f1f5f9; color: #64748b; font-size: 14px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.status-sheet-close:active { background: #e2e8f0; }
.status-sheet-options { display: flex; flex-direction: column; gap: 4px; }
.status-option { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px; border-radius: 10px; border: none; background: transparent; cursor: pointer; transition: background 0.15s; width: 100%; text-align: left; }
.status-option:active { background: #f1f5f9; }
.status-option-left { display: flex; align-items: center; gap: 12px; }
.status-option-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-option-dot.dot-pending { background: #f59e0b; }
.status-option-dot.dot-scheduled { background: #3b82f6; }
.status-option-dot.dot-in-progress { background: #059669; }
.status-option-dot.dot-completed { background: #16a34a; }
.status-option-dot.dot-on-hold { background: #dc2626; }
.status-option-dot.dot-cancelled { background: #64748b; }
.status-option-name { font-size: 15px; font-weight: 500; color: #1e293b; }
.status-option.active { background: #f0f9ff; }
.status-option.active .status-option-name { font-weight: 700; color: #3b82f6; }
.status-option-check { font-size: 14px; color: #3b82f6; }

/* ========== Building Setup ========== */

.building-setup-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.setup-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.setup-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.setup-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.setup-panel-title i { color: #059669; font-size: 12px; }

.setup-empty {
    padding: 20px 12px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.setup-table {
    width: 100%;
    border-collapse: collapse;
}

.setup-table th {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    background: #f1f5f9;
}

.setup-table td {
    padding: 8px 12px;
    font-size: 13px;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
}

.setup-table tr:last-child td { border-bottom: none; }

.setup-table .actions-cell {
    text-align: right;
    white-space: nowrap;
}

.setup-action-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}

.setup-action-btn:hover { color: #334155; background: #e2e8f0; }
.setup-action-btn.action-danger:hover { color: #dc2626; background: #fef2f2; }

.setup-asset-count {
    font-size: 11px;
    color: #64748b;
    background: #e2e8f0;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}

/* Floor / section deficiency icon with count badge */
.layout-def-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.layout-def-btn.has-deficiencies { color: #dc2626; }
.layout-def-btn.has-deficiencies:hover { color: #b91c1c; background: #fef2f2; }

.layout-def-count {
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #ffffff;
    background: #dc2626;
    padding: 2px 6px;
    border-radius: 9px;
    min-width: 18px;
    text-align: center;
}

/* ========== Floor / Section Deficiencies Modal ========== */

.modal-container-list {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.modal-container-list .modal-header,
.modal-container-list .modal-footer { flex-shrink: 0; }

.modal-subtitle {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.modal-body-list {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    background: #f8fafc;
}

/* Deficiency rows: same look as the Deficiencies tab (inprogress.css) */
.deficiency-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
}

.deficiency-item:last-child { margin-bottom: 0; }

.deficiency-item-main {
    flex: 1;
    min-width: 0;
}

.deficiency-item-asset {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 2px;
}

.deficiency-item-question {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.deficiency-item-meta {
    font-size: 12px;
    color: #dc2626;
    margin-bottom: 6px;
}

.deficiency-item-meta i { margin-right: 3px; }

.deficiency-item-notes {
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
    margin-top: 6px;
}

.deficiency-item-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #ffffff;
    color: #059669;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.deficiency-item-edit-btn:hover { background: #ecfdf5; }

.layout-def-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.layout-def-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 8px;
    line-height: 1.3;
}

.layout-def-tag-critical { background: #fee2e2; color: #b91c1c; }
.layout-def-tag-impairment { background: #ffedd5; color: #c2410c; }
.layout-def-tag-noncritical { background: #e2e8f0; color: #475569; }
.layout-def-tag-current { background: #d1fae5; color: #047857; }
.layout-def-tag-muted { background: #f1f5f9; color: #64748b; font-weight: 500; }

/* ========== Modal Components (Index page) ========== */

.modal-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 420px;
    overflow: visible;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 700; color: #1e293b; margin: 0; }

.modal-close {
    width: 32px; height: 32px; border-radius: 6px; border: none;
    background: transparent; color: #94a3b8; font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.modal-close:active { background: #e2e8f0; color: #1e293b; }

.modal-body { padding: 16px; }

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========== Building Notes modal (Index page) ========== */

/* Wider than the 420px default above: this is a block of prose, not one field. Scoped by
   id so the page rule keeps its width for the section modal. */
#buildingNotesModalContainer { max-width: 680px; }

#buildingNotesModalOverlay .building-notes-textarea {
    min-height: 30vh;
    min-height: 30dvh;
    line-height: 1.55;
    /* 16px, so iOS Safari does not zoom the page when the field takes focus. */
    font-size: 16px;
    resize: none;
    -webkit-appearance: none;
}

#buildingNotesModalOverlay .building-notes-count {
    text-align: right;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
}

#btnBuildingNotes.has-notes i { color: #059669; }

/* ========== Form Fields & Buttons (Index page) ========== */

.form-group { margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block; font-size: 13px; font-weight: 600;
    color: #334155; margin-bottom: 6px;
}

.form-label .required { color: #dc2626; }

.form-input {
    width: 100%; padding: 8px 10px;
    border: 1px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; font-family: inherit; color: #1e293b;
    background: #ffffff; transition: border-color 0.2s; box-sizing: border-box;
}

.form-input:focus { outline: none; border-color: #059669; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: #059669; color: #ffffff; }
.btn-primary:hover { background: #047857; }

.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ========== Responsive ========== */

@media (min-width: 480px) {
    .inspection-content { padding: 20px; }
    .page-header { padding: 24px 20px; }
    .page-header-title { font-size: 20px; }
    .service-detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
    .service-meta-row { flex-direction: row; }
    .service-meta-row > div { flex: 1; min-width: 0; }
}

@media (min-width: 768px) {
    .status-sheet { bottom: auto; top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%); max-width: 400px; width: 90%; border-radius: 16px; }
}

/* ===== Required-question gate =====
   Questions marked "Is Required for Report Submission" in the form builder that are still
   unanswered. Red rather than the amber used by the soft completion gate, because this one
   cannot be overridden.

   Lives in index.css rather than approval.css because it is used in two places: the gate on
   the approval screen (rows tappable, each navigating to its inspection) and the refusal
   modal raised when marking a form or system complete (rows static — there is nowhere to
   navigate, the modal is already scoped to the inspection). */

.required-gate-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.required-gate-item {
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-left: 3px solid #b91c1c;
    border-radius: 8px;
    background: #fef2f2;
    cursor: pointer;
    transition: background 0.2s;
}

.required-gate-item:hover {
    background: #fee2e2;
}

.required-gate-item:active {
    transform: scale(0.99);
}

.required-gate-question {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.required-gate-context {
    margin-top: 3px;
    font-size: 12px;
    color: #64748b;
}

/* The modal's rows are not navigable — the technician is already on the inspection. */
.required-gate-item-static {
    cursor: default;
}

.required-gate-item-static:hover {
    background: #fef2f2;
}

.required-gate-item-static:active {
    transform: none;
}
