/* MDO Reports (region-wide) page. Scoped under .mdr-page - see
   FieldDashboard.css / TasksAllocation.css for why every selector here is
   prefixed (this stylesheet loads globally alongside every other page's). */

.mdr-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.mdr-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.mdr-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
}

.mdr-subtitle {
    margin: 0;
    font-size: 0.92rem;
    color: #6b7280;
}

.mdr-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.mdr-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;
}

.mdr-btn-outline {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}

    .mdr-btn-outline:hover {
        background: #f9fafb;
    }

.mdr-btn-primary {
    background: #15803d;
    color: #fff;
}

    .mdr-btn-primary:hover {
        background: #166534;
    }

/* ---------- Report Filters ---------- */
.mdr-filter-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.4rem 1.6rem;
    margin-bottom: 20px;
}

.mdr-filter-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.25rem;
}

.mdr-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.mdr-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.mdr-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;
}

    .mdr-select:focus {
        border-color: #15803d;
    }

.mdr-filter-footer {
    display: flex;
    justify-content: flex-end;
}

/* ---------- Stat cards ---------- */
.mdr-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.mdr-stat-card {
    border: 1px solid #e5e7eb;
    border-left: 4px solid #cbd5e1;
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
}

.mdr-stat-tasks {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #dbeafe, #ffffff);
}

.mdr-stat-turnaround {
    border-left-color: #d97706;
    background: linear-gradient(135deg, #fef3e2, #ffffff);
}

.mdr-stat-soil {
    border-left-color: #7c3aed;
    background: linear-gradient(135deg, #ede9fe, #ffffff);
}

.mdr-stat-farmers {
    border-left-color: #16a34a;
    background: linear-gradient(135deg, #dcfce7, #ffffff);
}

.mdr-stat-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.mdr-stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.mdr-stat-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.mdr-stat-tasks .mdr-stat-icon { color: #3b82f6; }
.mdr-stat-turnaround .mdr-stat-icon { color: #d97706; }
.mdr-stat-soil .mdr-stat-icon { color: #7c3aed; }
.mdr-stat-farmers .mdr-stat-icon { color: #16a34a; }

.mdr-stat-number {
    font-size: 1.9rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.mdr-stat-desc {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

/* ---------- Tables ---------- */
.mdr-table-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 20px;
}

.mdr-table-title {
    margin: 0 0 4px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
}

.mdr-table-subtitle {
    margin: 0 0 1.25rem;
    font-size: 0.88rem;
    color: #6b7280;
}

.mdr-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mdr-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

    .mdr-table th {
        text-align: left;
        font-size: 0.88rem;
        font-weight: 700;
        color: #111827;
        padding: 0.9rem 0.75rem;
        border-bottom: 1px solid #e5e7eb;
        white-space: nowrap;
    }

    .mdr-table th:first-child,
    .mdr-table td:first-child {
        padding-left: 0;
    }

    .mdr-table td {
        padding: 1rem 0.75rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.9rem;
        color: #111827;
        vertical-align: top;
    }

    .mdr-table tr:last-child td {
        border-bottom: none;
    }

.mdr-jmdo-name {
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.mdr-resolution {
    min-width: 260px;
    color: #374151;
}

.mdr-type-pill {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 12px;
    padding: 3px 10px;
    white-space: nowrap;
}

.mdr-type-blue {
    background: #e0e7ff;
    color: #4338ca;
}

.mdr-type-green {
    background: #dcfce7;
    color: #15803d;
}

.mdr-type-orange {
    background: #ffedd5;
    color: #c2410c;
}

.mdr-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.mdr-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mdr-status-completed {
    color: #15803d;
}

    .mdr-status-completed .mdr-status-dot {
        background: #15803d;
    }

.mdr-status-partial,
.mdr-status-progress {
    color: #c2662a;
}

    .mdr-status-partial .mdr-status-dot,
    .mdr-status-progress .mdr-status-dot {
        background: #c2662a;
    }

.mdr-status-notstarted {
    color: #6b7280;
}

    .mdr-status-notstarted .mdr-status-dot {
        background: #9ca3af;
    }

/* ---------- Tablet (768px - 1199.98px) ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .mdr-filter-grid {
        grid-template-columns: 1fr;
    }

    .mdr-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---------- Phone (<= 767.98px) ---------- */
@media (max-width: 767.98px) {
    .mdr-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .mdr-title {
        font-size: 1.25rem;
    }

    .mdr-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .mdr-header-actions {
        width: 100%;
    }

    .mdr-btn {
        flex: 1 1 0;
        justify-content: center;
        min-height: 44px;
    }

    .mdr-filter-card,
    .mdr-table-card {
        padding: 1.1rem 1.1rem;
    }

    .mdr-filter-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .mdr-select {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .mdr-filter-footer .mdr-btn-primary {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .mdr-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .mdr-stat-card {
        padding: 0.85rem 0.9rem;
    }

    .mdr-stat-number {
        font-size: 1.5rem;
    }

    .mdr-stat-icon {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .mdr-table-card {
        padding: 1.1rem 1.1rem;
    }

    /* Both tables on this page (JMDO summary + Detailed Task Report)
       become a stack of cards, one per row, instead of a
       horizontally-scrolling grid. */
    .mdr-table-scroll {
        overflow-x: visible;
    }

    .mdr-table {
        min-width: 0;
    }

    .mdr-table thead {
        display: none;
    }

    .mdr-table,
    .mdr-table tbody,
    .mdr-table tr,
    .mdr-table td {
        display: block;
        width: 100%;
    }

    .mdr-table tr {
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 0.9rem 1rem;
        margin-bottom: 12px;
    }

    .mdr-table tr:last-child {
        margin-bottom: 0;
    }

    .mdr-table td {
        border-bottom: none !important;
        padding: 6px 0;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }

    .mdr-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        text-align: left;
        flex-shrink: 0;
    }

    .mdr-table td.mdr-cell-header {
        display: block;
        text-align: left;
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .mdr-resolution {
        text-align: right;
    }
}

@media (max-width: 420px) {
    .mdr-stats-grid {
        grid-template-columns: 1fr;
    }
}
