/* Task Detail / execution page. Scoped under .td-page - see
   FieldDashboard.css / TasksAllocation.css for why every selector here is
   prefixed (this stylesheet loads globally alongside every other page's). */

.td-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.td-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
}

    .td-back-link:hover {
        color: #111827;
        text-decoration: underline;
    }

.td-category-badge {
    display: inline-block;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 20px;
    padding: 3px 12px;
    margin-bottom: 8px;
}

.td-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
}

.td-subtitle {
    margin: 0 0 20px;
    font-size: 0.92rem;
    color: #6b7280;
}

/* ---------- Timeline ---------- */
.td-timeline-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.4rem 1.6rem;
    margin-bottom: 20px;
}

.td-timeline-title {
    margin: 0 0 1.4rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #15803d;
}

.td-timeline {
    display: flex;
    align-items: flex-start;
}

.td-timeline-step {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 140px;
}

.td-timeline-node {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.td-timeline-node.done {
    background: #15803d;
    color: #fff;
}

.td-timeline-node.pending {
    background: #fff;
    border: 2px solid #15803d;
    color: #15803d;
}

.td-timeline-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #111827;
}

.td-timeline-sub {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 2px;
}

.td-timeline-connector {
    flex: 1 1 60px;
    height: 2px;
    background: repeating-linear-gradient(to right, #d1d5db 0, #d1d5db 6px, transparent 6px, transparent 12px);
    margin-top: 21px;
}

.td-timeline-connector.done {
    background: #15803d;
}

/* ---------- Main 2-column layout ----------
   Task Details and Quick actions are explicitly placed in the same grid row
   (col 1 / col 2) with align-items: stretch, so they match height even
   though Quick actions has less content. Time-on-task and Close-out form
   are pinned to col 1 only, which pushes them onto their own rows below -
   col 2 stays empty there rather than being stretched to match them. */
.td-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    grid-auto-rows: min-content;
    gap: 20px;
    align-items: stretch;
}

.td-col-left {
    grid-column: 1;
}

.td-col-right {
    grid-column: 2;
}

.td-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.4rem 1.6rem;
}

.td-card-title {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
}

.td-card-subtitle {
    margin: 0 0 1.1rem;
    font-size: 0.85rem;
    color: #6b7280;
}

/* ---------- Task Details grid ---------- */
.td-details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
}

.td-detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.td-detail-label {
    font-size: 0.8rem;
    color: #6b7280;
}

.td-detail-val {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

/* ---------- Time-on-task bar ---------- */
.td-time-bar {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.td-time-left {
    display: flex;
    flex-direction: column;
}

.td-time-label {
    font-size: 0.8rem;
    color: #6b7280;
}

.td-time-val {
    font-size: 1.9rem;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.td-time-location {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #15803d;
}

/* ---------- Buttons ---------- */
.td-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.3rem;
    cursor: pointer;
    white-space: nowrap;
}

.td-btn-primary {
    background: #15803d;
    color: #fff;
}

    .td-btn-primary:hover:not(:disabled) {
        background: #166534;
    }

    .td-btn-primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

.td-btn-danger {
    background: #dc2626;
    color: #fff;
}

    .td-btn-danger:hover:not(:disabled) {
        background: #b91c1c;
    }

    .td-btn-danger:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ---------- Close-out form fields ---------- */
.td-pos-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem 1.5rem;
}

.td-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
    margin: 1rem 0 6px;
}

    .td-field-label:first-of-type {
        margin-top: 0;
    }

.td-required {
    color: #dc2626;
    margin-left: 2px;
}

.td-input,
.td-textarea {
    width: 100%;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    font-size: 0.92rem;
    color: #111827;
    outline: none;
}

    .td-input:focus,
    .td-textarea:focus {
        border-color: #15803d;
    }

.td-textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.td-file-input {
    display: block;
    font-size: 0.85rem;
    color: #6b7280;
}

/* ---------- Quick actions ---------- */
.td-quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 10px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #111827;
    cursor: pointer;
    text-align: left;
}

    .td-quick-action:last-child {
        margin-bottom: 0;
    }

    .td-quick-action:hover {
        background: #f9fafb;
        border-color: #d1d5db;
    }

    .td-quick-action i {
        color: #15803d;
        font-size: 1.1rem;
    }

/* ---------- Tablet (768px - 1199.98px) ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .td-main-grid {
        grid-template-columns: 1fr;
    }

    /* Only 1 column now - col-right would otherwise land in an unwanted
       implicit 2nd column. Reset both to the single column and move Quick
       actions to the end instead of interrupting Task Details -> Time on
       task -> Close-out form. */
    .td-col-left,
    .td-col-right {
        grid-column: 1;
    }

    .td-col-right {
        order: 99;
    }
}

/* ---------- Phone (<= 767.98px) ---------- */
@media (max-width: 767.98px) {
    .td-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .td-title {
        font-size: 1.25rem;
    }

    .td-timeline-card,
    .td-card {
        padding: 1rem 1.1rem;
    }

    .td-timeline {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .td-timeline-step {
        width: 100px;
    }

    .td-timeline-label {
        font-size: 0.8rem;
    }

    .td-main-grid {
        grid-template-columns: 1fr;
    }

    .td-col-left,
    .td-col-right {
        grid-column: 1;
    }

    .td-col-right {
        order: 99;
    }

    .td-details-grid,
    .td-pos-grid {
        grid-template-columns: 1fr 1fr;
    }

    .td-time-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .td-time-left {
        align-items: center;
    }

    .td-time-location {
        justify-content: center;
    }

    .td-btn,
    .td-back-link {
        min-height: 44px;
    }

    .td-input,
    .td-textarea {
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}

@media (max-width: 420px) {
    .td-details-grid,
    .td-pos-grid {
        grid-template-columns: 1fr;
    }
}
