/* Field Executive home dashboard. Every selector is scoped under .fd-page
   (the page's root div) - this stylesheet loads globally (see App.razor /
   index.html), and generic names like .stat-card or .task-row are reused by
   other pages' own globally-loaded CSS files. Unscoped rules here would
   either leak properties into those pages or get silently overridden by
   them depending on load order - see SchemeOverview.css for the bug this
   caused previously. */

.fd-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

/* ---------- Profile header ---------- */
.fd-profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.fd-profile-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.fd-avatar {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #facc15, #f59e0b);
    color: #1f2937;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.fd-profile-info {
    min-width: 0;
}

.fd-name-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.fd-name {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #111827;
}

.fd-status-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.fd-status-offduty {
    background-color: #fef3c7;
    color: #b45309;
}

.fd-status-onduty {
    background-color: #dcfce7;
    color: #15803d;
}

.fd-role-line {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: #4b5563;
}

.fd-title-line {
    margin: 0;
    font-size: 0.85rem;
    color: #6b7280;
}

/* ---------- Buttons ---------- */
.fd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 0.65rem 1.2rem;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.fd-btn-primary {
    background-color: #1b5e20;
    color: #fff;
}

    .fd-btn-primary:hover {
        background-color: #164c1a;
    }

.fd-btn-outline {
    background-color: #fff;
    color: #1b5e20;
    border: 1px solid #1b5e20;
}

    .fd-btn-outline:hover {
        background-color: #f0fdf4;
    }

.fd-btn-view {
    background-color: #1b5e20;
    color: #fff;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    flex-shrink: 0;
}

    .fd-btn-view:hover {
        background-color: #164c1a;
    }

/* ---------- Stat cards ---------- */
.fd-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.fd-stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #cbd5e1;
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
}

.fd-stat-active {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff, #ffffff);
}

.fd-stat-pending {
    border-left-color: #d97706;
    background: linear-gradient(135deg, #fef3e2, #ffffff);
}

.fd-stat-progress {
    border-left-color: #0d9488;
    background: linear-gradient(135deg, #ecfdf5, #ffffff);
}

.fd-stat-done {
    border-left-color: #16a34a;
    background: #ffffff;
}

.fd-stat-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.fd-stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.fd-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;
}

.fd-stat-active .fd-stat-icon { color: #3b82f6; }
.fd-stat-pending .fd-stat-icon { color: #d97706; }
.fd-stat-progress .fd-stat-icon { color: #0d9488; }
.fd-stat-done .fd-stat-icon { color: #16a34a; }

.fd-stat-number {
    font-size: 1.9rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.fd-stat-desc {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

/* ---------- Tracking banner ---------- */
.fd-tracking-banner {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.fd-tracking-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.fd-tracking-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1b5e20;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.fd-tracking-title {
    font-weight: 600;
    font-size: 1rem;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fd-tracking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

.fd-tracking-sub {
    font-size: 0.82rem;
    color: #6b7280;
    margin-top: 2px;
}

.fd-tracking-dot-active {
    background: #22c55e;
}

/* ---------- Tracking: active state (map + status + attendance) ---------- */
.fd-tracking-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 20px;
}

.fd-tracking-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.fd-tracking-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.fd-btn-stop {
    background-color: #dc2626;
    color: #fff;
    border-radius: 20px;
    padding: 0.55rem 1.1rem;
}

    .fd-btn-stop:hover {
        background-color: #b91c1c;
    }

.fd-timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #111827;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    border-radius: 20px;
    padding: 0.5rem 0.9rem;
}

.fd-tracking-body {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 1.1rem;
}

.fd-map-placeholder {
    position: relative;
    min-height: 220px;
    border-radius: 10px;
    overflow: hidden;
    background:
        radial-gradient(circle at 12% 88%, #bfdbfe 0%, #bfdbfe 38%, transparent 39%),
        linear-gradient(135deg, #e7f6ec 0%, #eef7f0 55%, #f4f9ec 100%);
}

.fd-map-route-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

    .fd-map-route-svg path {
        fill: none;
        stroke: #3b82f6;
        stroke-width: 3;
        stroke-linecap: round;
    }

.fd-map-pin {
    position: absolute;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.fd-map-pin-end {
    top: 14%;
    right: 16%;
    background: #16a34a;
    border-radius: 50% 50% 50% 0;
    transform: rotate(45deg);
}

    .fd-map-pin-end i {
        transform: rotate(-45deg);
    }

.fd-map-pin-current {
    bottom: 16%;
    left: 18%;
    border-radius: 50%;
    background: #3b82f6;
    border: 3px solid #fff;
}

.fd-tracking-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
}

.fd-detail-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.fd-detail-key {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #6b7280;
    flex-shrink: 0;
}

.fd-detail-val {
    text-align: right;
    font-size: 0.92rem;
    color: #111827;
}

/* .fd-tracking-dot only renders at its 8px size as a flex item (plain
   inline spans ignore width/height), so the dot+"On Duty" row needs its
   own inline-flex wrapper - a column-direction wrapper (like the address
   below) would stack the dot above the text instead of beside it. */
.fd-detail-val-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fd-detail-val-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.fd-detail-val-sub {
    font-size: 0.78rem;
    color: #9ca3af;
}

.fd-attendance-section {
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}

.fd-attendance-title {
    margin: 0 0 0.7rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
}

.fd-attendance-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.fd-attendance-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #15803d;
}

/* ---------- Stop-tracking confirmation modal ---------- */
.fd-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1060; /* above --z-sheet (1050), below --z-toast (1080) */
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fd-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    padding: 1.25rem 1.4rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.fd-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1rem;
}

.fd-modal-header-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.fd-modal-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.fd-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
}

.fd-modal-subtitle {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.fd-modal-warning-badge {
    flex-shrink: 0;
    background: #fef3c7;
    color: #b45309;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: 12px;
    padding: 3px 10px;
}

.fd-modal-body-text {
    font-size: 0.88rem;
    color: #374151;
    line-height: 1.5;
    margin: 0 0 1rem;
}

.fd-modal-duration-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1.25rem;
}

.fd-modal-duration-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #6b7280;
}

.fd-modal-duration-val {
    font-weight: 700;
    font-size: 0.92rem;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

.fd-modal-footer {
    display: flex;
    gap: 10px;
}

    .fd-modal-footer .fd-btn {
        flex: 1 1 0;
        min-height: 44px;
    }

.fd-btn-keep {
    background: #f3f4f6;
    color: #374151;
}

    .fd-btn-keep:hover {
        background: #e5e7eb;
    }

/* ---------- Tasks card ---------- */
.fd-tasks-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.4rem;
}

.fd-tasks-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1.1rem;
}

.fd-tasks-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
}

.fd-tasks-subtitle {
    margin: 2px 0 0;
    font-size: 0.82rem;
    color: #6b7280;
}

.fd-view-all {
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.45rem 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

    .fd-view-all:hover {
        background: #f9fafb;
    }

/* ---------- Task rows ---------- */
.fd-task-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.fd-task-row {
    background: linear-gradient(to right, #ffffff, #e9fbf1);
    border: 1px solid #dcfce7;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 20px;
}

.fd-task-main {
    flex: 1 1 42%;
    min-width: 0;
}

.fd-cat {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.fd-cat-pill {
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: none;
    letter-spacing: normal;
}

.fd-cat-dealer { color: #2563eb; }
.fd-cat-mdprogram { color: #7c3aed; }
.fd-cat-spcm { background: #e0f2f1; color: #0f766e; }
.fd-cat-soil-orange { background: #fef3c7; color: #b45309; }
.fd-cat-soil-grey { background: #f1f5f9; color: #475569; }

.fd-task-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    overflow-wrap: anywhere;
}

.fd-task-sub {
    font-size: 0.82rem;
    color: #111827;
}

.fd-task-sub-muted {
    color: #9ca3af;
}

.fd-task-info {
    flex: 1 1 40%;
    min-width: 0;
}

.fd-task-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #15803d;
    background: #fff;
    border: 1px solid #86efac;
    border-radius: 14px;
    padding: 3px 12px;
    margin-bottom: 6px;
}

.fd-task-info-line {
    font-size: 0.85rem;
    color: #1f2937;
}

/* ---------- Tablet (768px - 1199.98px) ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .fd-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .fd-tracking-body {
        grid-template-columns: 1fr;
    }

    .fd-map-placeholder {
        min-height: 200px;
    }

    .fd-task-row {
        flex-wrap: wrap;
    }

    .fd-task-main,
    .fd-task-info {
        flex: 1 1 100%;
    }

    .fd-btn-view {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* ---------- Phone (<= 767.98px) ---------- */
@media (max-width: 767.98px) {
    .fd-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .fd-modal-backdrop {
        padding: 14px;
        align-items: flex-end;
    }

    .fd-modal {
        padding: 1.1rem;
        max-height: calc(100vh - 28px);
        max-height: calc(100dvh - 28px);
        border-radius: 14px 14px 0 0;
    }

    .fd-modal-footer {
        flex-direction: column;
    }

    .fd-profile-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .fd-avatar {
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }

    .fd-name {
        font-size: 1.1rem;
    }

    .fd-mark-attendance {
        width: 100%;
        min-height: 44px;
    }

    .fd-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .fd-stat-card {
        padding: 0.85rem 0.9rem;
    }

    .fd-stat-number {
        font-size: 1.5rem;
    }

    .fd-stat-label {
        font-size: 0.78rem;
    }

    .fd-stat-icon {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .fd-tracking-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .fd-update-btn {
        width: 100%;
        min-height: 44px;
    }

    .fd-tracking-card {
        padding: 0.9rem 1rem;
    }

    .fd-tracking-header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .fd-tracking-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .fd-btn-stop {
        min-height: 44px;
    }

    .fd-timer-badge {
        justify-content: center;
        min-height: 36px;
    }

    .fd-tracking-body {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .fd-map-placeholder {
        min-height: 180px;
    }

    .fd-detail-row {
        font-size: 0.85rem;
    }

    .fd-attendance-box {
        flex-direction: column;
        align-items: stretch;
    }

    .fd-attendance-status {
        justify-content: center;
        text-align: center;
    }

    .fd-attendance-box .fd-btn {
        width: 100%;
        min-height: 44px;
    }

    .fd-tasks-card {
        padding: 1rem;
    }

    .fd-tasks-header {
        flex-wrap: wrap;
    }

    .fd-view-all {
        min-height: 40px;
    }

    .fd-task-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .fd-task-main,
    .fd-task-info {
        flex: 1 1 auto;
    }

    .fd-btn-view {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
}

/* ---------- Very small phones (<= 420px): stat cards need a full column -
   two-per-row at this width squeezes the icon + number badly, same issue
   fixed on the Top Ranking pages earlier. ---------- */
@media (max-width: 420px) {
    .fd-stats-grid {
        grid-template-columns: 1fr;
    }
}
