/* ==========================================================================
   Resource Schedule - Modal Overlay & Add New Assignment Form
   ========================================================================== */

/* --- Modal Overlay --- */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-overlay.hidden {
    display: none;
}

/* --- Modal Dialog --- */
.modal-dialog {
    background: #fff;
    width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--gray-300);
    /* border-radius: 0 — enforced by global reset */
}

/* --- Modal Header --- */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    padding: 0;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    color: var(--gray-800);
}

/* --- Modal Body --- */
.modal-body {
    padding: 16px;
}

/* --- Modal Footer --- */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
}

/* --- Form Groups --- */
.form-group {
    margin-bottom: 12px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.form-input,
.form-select {
    width: 100%;
    border: 1px solid var(--gray-300);
    padding: 6px 8px;
    font-size: 12px;
    color: var(--gray-800);
    background: #fff;
    outline: none;
    transition: border-color 0.1s;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-input[type="number"] {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* --- Disabled Form Group --- */
.form-group.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* --- Hint Text --- */
.form-hint {
    font-size: 10px;
    color: var(--gray-400);
    margin-top: 2px;
}

/* --- Default Job Title Hint --- */
#modal-jt-default-hint:not(:empty) {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    padding: 4px 8px;
    margin-top: 4px;
}

/* --- Searchable Dropdown (Activity Manager style) --- */
.searchable-dropdown {
    position: relative;
}

.searchable-dropdown .sd-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    font-size: 12px;
    font-family: inherit;
    color: var(--gray-800);
    outline: none;
    transition: border-color 0.1s;
}

.searchable-dropdown .sd-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-light);
}

.searchable-dropdown .sd-search:disabled {
    background: var(--gray-100);
    color: var(--gray-400);
    cursor: not-allowed;
}

.searchable-dropdown .sd-search.has-value {
    font-weight: 500;
    color: var(--gray-900);
}

.searchable-dropdown .sd-search::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

.sd-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-top: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 300;
}

.sd-list.show {
    display: block;
}

.sd-item {
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
}

.sd-item:last-child {
    border-bottom: none;
}

.sd-item:hover {
    background: var(--gray-50);
}

.sd-item .sd-primary {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-800);
    line-height: 1.3;
}

.sd-item .sd-secondary {
    font-size: 10px;
    color: var(--gray-500);
    margin-top: 1px;
    line-height: 1.3;
}

.sd-item:hover .sd-secondary {
    color: var(--gray-600);
}

.sd-no-results {
    padding: 10px;
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
    text-align: center;
}

/* --- Submit / Cancel Buttons --- */
.modal-btn-submit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary-dark);
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s;
}

.modal-btn-submit:hover {
    background: var(--primary-dark);
}

.modal-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-btn-cancel {
    background: #fff;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s;
}

.modal-btn-cancel:hover {
    background: var(--gray-100);
}

/* --- Spinner inside submit button --- */
.modal-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
    display: none;
}

.modal-btn-submit.loading .modal-spinner {
    display: inline-block;
}

/* --- Error message inside modal --- */
.modal-error {
    padding: 8px;
    font-size: 11px;
    color: var(--danger-dark);
    background: var(--danger-light);
    border: 1px solid var(--danger);
    margin-bottom: 12px;
}

.modal-error.hidden {
    display: none;
}

/* --- Step indicator --- */
.form-step-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}

.form-group.active .form-step-label {
    color: var(--primary);
}

/* ==========================================================================
   Project Detail Modal
   ========================================================================== */

/* --- Overlay --- */
#project-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

#project-detail-overlay.hidden {
    display: none;
}

/* --- Dialog --- */
.pd-dialog {
    background: #fff;
    border: 1px solid var(--gray-300);
    width: 95%;
    max-width: 1100px;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.pd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.pd-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 12px;
}

.pd-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--gray-500);
    padding: 0;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pd-close-btn:hover {
    color: var(--gray-800);
}

/* --- Body (scrollable) --- */
.pd-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* --- Footer --- */
.pd-footer {
    display: flex;
    justify-content: flex-end;
    padding: 10px 16px;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

/* --- Info Bar --- */
.pd-info-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    margin-bottom: 12px;
}

.pd-info-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pd-info-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
}

.pd-info-value {
    font-size: 12px;
    color: var(--gray-800);
}

/* --- KPI Cards --- */
.pd-kpi-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

/* Loading skeleton + budget signals */
.pd-kpi-value.pd-budget-loading {
    color: var(--gray-300);
}
.pd-kpi-card.pd-near-budget { border-color: var(--warning, #c4933f); }
.pd-kpi-card.pd-near-budget .pd-kpi-value { color: var(--warning-dark, #a57a2e); }
.pd-kpi-card.pd-over-budget { border-color: var(--danger, #b85450); background: var(--danger-light, #f0d8d7); }
.pd-kpi-card.pd-over-budget .pd-kpi-value { color: var(--danger-dark, #9a3f3c); }

.pd-kpi-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    padding: 10px 12px;
}

.pd-kpi-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.pd-kpi-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.pd-kpi-breakout {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    max-height: 110px;
    overflow-y: auto;
}

.pd-kpi-breakout-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-600);
    margin-bottom: 3px;
    font-variant-numeric: tabular-nums;
}

/* --- Add New modal: Job Title locked / block states --- */
.modal-jt-readonly {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200, #e5e7eb);
    color: var(--gray-800, #1f2937);
    font-size: 13px;
    cursor: not-allowed;
}
.modal-jt-readonly-name { font-weight: 600; }
.modal-jt-readonly-badge {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500, #6b7280);
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    padding: 2px 6px;
}
.modal-jt-block-error {
    padding: 10px 12px;
    background: var(--danger-light, #f0d8d7);
    border: 1px solid var(--danger, #b85450);
    color: var(--danger-dark, #9a3f3c);
    font-size: 12px;
    line-height: 1.4;
}

/* --- Detail Table --- */
.pd-table-wrapper {
    overflow-x: auto;
}
/* In wide (52-week) mode the table is wider than the wrapper, so the
   wrapper scrolls horizontally inside the modal. */
.pd-table-wrapper.pd-table-wide { overflow-x: auto; }

.pd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}
/* Wide-mode table uses an explicit pixel width set inline — don't let
   100% override it. */
.pd-table.pd-table-fixed-px { width: auto; }

.pd-table th {
    padding: 6px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-300);
    background: var(--gray-100);
    white-space: pre-line;
    vertical-align: bottom;
}

.pd-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--gray-100);
    word-wrap: break-word;
}

.pd-table .text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pd-table .pd-week-col {
    min-width: 36px;
    padding-left: 1px;
    padding-right: 4px;
}

/* Group header */
.pd-group-header td {
    padding: 6px 6px;
    font-weight: 600;
    font-size: 11px;
    color: var(--gray-800);
    background: var(--primary-bg);
    border-bottom: 1px solid var(--primary-light);
}

.pd-group-path {
    font-weight: 700;
    margin-right: 6px;
    color: var(--gray-600);
}

.pd-group-dates {
    font-weight: 400;
    font-size: 10px;
    color: var(--gray-500);
    margin-left: 8px;
}

/* Subtotal row */
.pd-subtotal-row td {
    font-weight: 600;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-variant-numeric: tabular-nums;
}

/* Grand total row */
.pd-grand-total-row td {
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    border-bottom: none;
    font-variant-numeric: tabular-nums;
}

/* Empty state */
.pd-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--gray-500);
    font-size: 13px;
}

/* --- Clickable project name in grid --- */
.cell-projectlong .project-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
}

.cell-projectlong .project-link:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}
