/* MDO Farmer Data page. Scoped under .fmd-page - see FieldDashboard.css /
   TasksAllocation.css for why every selector here is prefixed (this
   stylesheet loads globally alongside every other page's). */

.fmd-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.fmd-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
}

.fmd-subtitle {
    margin: 0 0 20px;
    font-size: 0.92rem;
    color: #6b7280;
}

.fmd-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.fmd-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem 1.5rem;
}

.fmd-form-card {
    padding: 1.5rem 1.75rem;
}

.fmd-card-title {
    margin: 0 0 4px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
}

.fmd-meta {
    margin: 0 0 1.25rem;
    font-size: 0.85rem;
    color: #6b7280;
}

/* ---------- Farmer table ---------- */
.fmd-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fmd-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

    .fmd-table th {
        text-align: left;
        font-size: 0.88rem;
        font-weight: 700;
        color: #111827;
        padding: 1rem 0.75rem;
        border-bottom: 1px solid #e5e7eb;
        white-space: nowrap;
    }

    .fmd-table th:first-child,
    .fmd-table td:first-child {
        padding-left: 0;
    }

    .fmd-table td {
        padding: 1rem 0.75rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.9rem;
        color: #111827;
        vertical-align: middle;
    }

    .fmd-table tr:last-child td {
        border-bottom: none;
    }

.fmd-farmer-name {
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.fmd-row-actions {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.fmd-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;
}

    .fmd-icon-btn:hover {
        background: #f9fafb;
    }

/* ---------- Add Farmer Entry form ---------- */
.fmd-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
}

.fmd-required {
    color: #dc2626;
    margin-left: 2px;
}

.fmd-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;
}

    .fmd-select:focus {
        border-color: #15803d;
    }

.fmd-mb {
    margin-bottom: 1.1rem;
}

.fmd-field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
    margin-bottom: 1.1rem;
}

.fmd-field-row-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.fmd-btn-save {
    width: 100%;
    background: #15803d;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.85rem;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}

    .fmd-btn-save:hover:not(:disabled) {
        background: #166534;
    }

    .fmd-btn-save:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ---------- Tablet (768px - 1199.98px) ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .fmd-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Phone (<= 767.98px) ---------- */
@media (max-width: 767.98px) {
    .fmd-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .fmd-title {
        font-size: 1.25rem;
    }

    .fmd-grid {
        grid-template-columns: 1fr;
    }

    .fmd-card {
        padding: 1.1rem 1.1rem;
    }

    .fmd-field-row,
    .fmd-field-row-three {
        grid-template-columns: 1fr;
        gap: 0.9rem;
    }

    .fmd-select {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .fmd-btn-save {
        min-height: 44px;
    }

    /* Table becomes a stack of cards, one per farmer, instead of a
       horizontally-scrolling grid - see AllocationRequests.css for the
       same pattern (data-label driven, header/actions cells opt out). */
    .fmd-table-scroll {
        overflow-x: visible;
    }

    .fmd-table {
        min-width: 0;
    }

    .fmd-table thead {
        display: none;
    }

    .fmd-table,
    .fmd-table tbody,
    .fmd-table tr,
    .fmd-table td {
        display: block;
        width: 100%;
    }

    .fmd-table tr {
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 0.9rem 1rem;
        margin-bottom: 12px;
    }

    .fmd-table tr:last-child {
        margin-bottom: 0;
    }

    .fmd-table td {
        border-bottom: none !important;
        padding: 6px 0;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        text-align: right;
    }

    .fmd-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        text-align: left;
        flex-shrink: 0;
    }

    .fmd-table td.fmd-cell-header {
        display: block;
        text-align: left;
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .fmd-table td.fmd-cell-actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 4px;
    }
}
