/* MDO Performance Tracker page. Scoped under .pt-page - see
   FieldDashboard.css / TasksAllocation.css for why every selector here is
   prefixed (this stylesheet loads globally alongside every other page's). */

.pt-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.pt-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
}

.pt-subtitle {
    margin: 0 0 20px;
    font-size: 0.92rem;
    color: #6b7280;
}

/* ---------- Filters ---------- */
.pt-filter-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem 1.6rem;
    margin-bottom: 1rem;
}

.pt-filter-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #111827;
}

.pt-filter-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
}

.pt-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
}

.pt-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.pt-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;
}

    .pt-select:focus {
        border-color: #15803d;
    }

.pt-filter-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.pt-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;
}

.pt-btn-outline {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}

    .pt-btn-outline:hover {
        background: #f9fafb;
    }

.pt-btn-primary {
    background: #15803d;
    color: #fff;
}

    .pt-btn-primary:hover {
        background: #166534;
    }

.pt-helper-text {
    font-size: 0.85rem;
    color: #374151;
    font-weight: 600;
    margin: 0 0 1rem;
}

/* ---------- Ranking table ---------- */
.pt-table-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem 1.5rem;
}

.pt-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pt-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

    .pt-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;
    }

    .pt-table th:first-child,
    .pt-table td:first-child {
        padding-left: 0;
    }

    .pt-table td {
        padding: 1rem 0.75rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.92rem;
        color: #111827;
        vertical-align: middle;
    }

    .pt-table tr:last-child td {
        border-bottom: none;
    }

.pt-rank-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 14px;
    padding: 4px 12px;
    white-space: nowrap;
}

.pt-rank-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pt-rank-top {
    background: #dcfce7;
    color: #15803d;
}

    .pt-rank-top .pt-rank-dot {
        background: #15803d;
    }

.pt-rank-mid {
    background: #f3f4f6;
    color: #4b5563;
}

    .pt-rank-mid .pt-rank-dot {
        background: #6b7280;
    }

.pt-rank-bottom {
    background: #fee2e2;
    color: #dc2626;
}

    .pt-rank-bottom .pt-rank-dot {
        background: #dc2626;
    }

.pt-jmdo-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.pt-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #15803d;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pt-jmdo-name {
    font-weight: 700;
    color: #111827;
}

.pt-jmdo-sub {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

.pt-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;
}

    .pt-icon-btn:hover {
        background: #f9fafb;
    }

/* ---------- Tablet (768px - 1199.98px) ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .pt-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---------- Phone (<= 767.98px) ---------- */
@media (max-width: 767.98px) {
    .pt-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .pt-title {
        font-size: 1.25rem;
    }

    .pt-filter-card,
    .pt-table-card {
        padding: 1.1rem 1.1rem;
    }

    .pt-filter-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .pt-select {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .pt-filter-footer {
        flex-direction: column-reverse;
    }

    .pt-filter-footer .pt-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    /* Table becomes a stack of cards, one per JMDO, instead of a
       horizontally-scrolling grid. The row uses flex (not plain block) so
       the JMDO cell - 2nd in the DOM/desktop column order, after Rank -
       can be moved to the top of the card via "order" without touching
       desktop layout. */
    .pt-table-scroll {
        overflow-x: visible;
    }

    .pt-table {
        min-width: 0;
    }

    .pt-table thead {
        display: none;
    }

    .pt-table,
    .pt-table tbody {
        display: block;
        width: 100%;
    }

    .pt-table tr {
        display: flex;
        flex-direction: column;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 0.9rem 1rem;
        margin-bottom: 12px;
    }

    .pt-table tr:last-child {
        margin-bottom: 0;
    }

    .pt-table td {
        border-bottom: none !important;
        padding: 6px 0;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }

    .pt-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        text-align: left;
        flex-shrink: 0;
    }

    .pt-table td.pt-cell-header {
        order: -1;
        display: block;
        text-align: left;
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .pt-table td.pt-cell-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 4px;
    }
}
