/* MDO Task Monitoring page. Scoped under .tm-page - see FieldDashboard.css /
   TasksAllocation.css for why every selector here is prefixed (this
   stylesheet loads globally alongside every other page's). */

.tm-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.tm-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.tm-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
}

.tm-subtitle {
    margin: 0;
    font-size: 0.92rem;
    color: #6b7280;
}

.tm-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.tm-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 0.65rem 1.1rem;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.tm-btn-outline {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}

    .tm-btn-outline:hover {
        background: #f9fafb;
    }

.tm-btn-primary {
    background: #15803d;
    color: #fff;
}

    .tm-btn-primary:hover {
        background: #166534;
    }

/* ---------- Filters ---------- */
.tm-filter-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.4rem 1.6rem;
    margin-bottom: 20px;
}

.tm-filter-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.25rem;
}

.tm-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.tm-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.tm-select {
    width: 100%;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    font-size: 0.92rem;
    color: #111827;
    outline: none;
}

    .tm-select:focus {
        border-color: #15803d;
    }

.tm-filter-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- Task table ---------- */
.tm-table-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem 1.5rem;
}

.tm-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tm-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

    .tm-table th {
        text-align: left;
        font-size: 0.9rem;
        font-weight: 700;
        color: #111827;
        padding: 1rem 0.75rem;
        border-bottom: 1px solid #e5e7eb;
        white-space: nowrap;
    }

    .tm-table th:first-child,
    .tm-table td:first-child {
        padding-left: 0;
    }

    .tm-table td {
        padding: 1rem 0.75rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.9rem;
        color: #111827;
        vertical-align: middle;
    }

    .tm-table tr:last-child td {
        border-bottom: none;
    }

.tm-jmdo-name {
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.tm-type-pill {
    display: inline-block;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 12px;
    padding: 3px 10px;
    white-space: nowrap;
}

.tm-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.tm-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tm-status-requested {
    color: #7c3aed;
}

    .tm-status-requested .tm-status-dot {
        background: #7c3aed;
    }

.tm-status-assigned {
    color: #2563eb;
}

    .tm-status-assigned .tm-status-dot {
        background: #2563eb;
    }

.tm-status-yettostart {
    color: #c2662a;
}

    .tm-status-yettostart .tm-status-dot {
        background: #c2662a;
    }

.tm-status-progress {
    color: #d97706;
}

    .tm-status-progress .tm-status-dot {
        background: #d97706;
    }

.tm-status-completed {
    color: #15803d;
}

    .tm-status-completed .tm-status-dot {
        background: #15803d;
    }

.tm-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

    .tm-icon-btn:hover {
        background: #f9fafb;
    }

.tm-empty-cell {
    text-align: center;
    color: #9ca3af;
    padding: 2rem 0.75rem;
}

/* ---------- Tablet (768px - 1199.98px) ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .tm-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---------- Phone (<= 767.98px) ---------- */
@media (max-width: 767.98px) {
    .tm-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .tm-title {
        font-size: 1.25rem;
    }

    .tm-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tm-header-actions {
        width: 100%;
    }

    .tm-btn {
        flex: 1 1 0;
        justify-content: center;
        min-height: 44px;
    }

    .tm-filter-card,
    .tm-table-card {
        padding: 1.1rem 1.1rem;
    }

    .tm-filter-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tm-select {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .tm-filter-footer {
        flex-direction: column-reverse;
    }

    .tm-filter-footer .tm-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    /* Table becomes a stack of cards, one per task, instead of a
       horizontally-scrolling grid. */
    .tm-table-scroll {
        overflow-x: visible;
    }

    .tm-table {
        min-width: 0;
    }

    .tm-table thead {
        display: none;
    }

    .tm-table,
    .tm-table tbody,
    .tm-table tr,
    .tm-table td {
        display: block;
        width: 100%;
    }

    .tm-table tr {
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 0.9rem 1rem;
        margin-bottom: 12px;
    }

    .tm-table tr:last-child {
        margin-bottom: 0;
    }

    .tm-table td {
        border-bottom: none !important;
        padding: 6px 0;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }

    .tm-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        text-align: left;
        flex-shrink: 0;
    }

    .tm-table td.tm-cell-header {
        display: block;
        text-align: left;
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .tm-table td.tm-cell-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 4px;
    }

    .tm-table td.tm-empty-cell {
        display: block;
        text-align: center;
    }
}
