/* ==========================================================================
   Project Planner - Modal & Popover Styles
   ========================================================================== */

/* --- Resource Popover --- */
.resource-popover {
    position: fixed;
    width: 320px;
    background: #fff;
    border: 1px solid var(--gray-200);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 5000;
    display: flex;
    flex-direction: column;
}

.rpop-header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-3);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.rpop-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
}

.rpop-subtitle {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    margin-top: var(--sp-1);
}

.rpop-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.rpop-close:hover {
    color: var(--gray-700);
}

.rpop-field {
    padding: var(--sp-2) var(--sp-3);
}

.rpop-field label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: var(--sp-1);
}

.rpop-actions {
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-3);
    border-top: 1px solid var(--gray-200);
}

.rpop-assigned {
    padding: 0 var(--sp-3) var(--sp-2);
}

.rpop-assigned-heading {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: var(--sp-1);
}

.rpop-assigned-item {
    font-size: var(--font-size-sm);
    color: var(--success-dark);
    padding: var(--sp-1) 0;
    border-bottom: 1px solid var(--gray-100);
}

.rpop-status {
    padding: 0 var(--sp-3) var(--sp-2);
    font-size: var(--font-size-sm);
    min-height: 18px;
}

.rpop-status-error { color: var(--danger); }
.rpop-status-success { color: var(--success-dark); }
.rpop-status-info { color: var(--gray-500); }
.rpop-status-warning {
    color: var(--danger-dark);
    background: var(--danger-light);
    border: 1px solid var(--danger);
    padding: var(--sp-2) var(--sp-3);
    margin: 0 var(--sp-3) var(--sp-2);
    font-weight: 600;
}

/* --- Activity Modal --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 41, 55, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6000;
}

.modal-content {
    background: #fff;
    border: 1px solid var(--gray-200);
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.modal-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: var(--sp-3) var(--sp-4);
    overflow-y: auto;
    flex: 1;
}

.modal-field {
    margin-bottom: var(--sp-3);
}

.modal-field label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: var(--sp-1);
}

.modal-input {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--gray-300);
    font-size: var(--font-size-base);
    outline: none;
}

.modal-input:focus {
    border-color: var(--primary);
}

.modal-textarea {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--gray-300);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    outline: none;
    resize: vertical;
}

.modal-textarea:focus {
    border-color: var(--primary);
}

.modal-target-info {
    padding: var(--sp-2) var(--sp-3);
    background: var(--primary-bg);
    color: var(--primary-dark);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--sp-3);
    border-left: 3px solid var(--primary);
}

/* Three-column row for Type / Section / Priority selects on new activities */
.modal-meta-row {
    display: flex;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.modal-select-field {
    flex: 1;
}

.modal-select-field label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    margin-bottom: var(--sp-1);
}

.modal-select-field select.modal-input {
    padding: var(--sp-1) var(--sp-2);
}

.modal-template-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    align-items: center;
    margin-bottom: var(--sp-3);
}

.modal-badge-label {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    margin-right: var(--sp-1);
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--gray-200);
    justify-content: flex-end;
}

.modal-status {
    flex: 1;
    font-size: var(--font-size-sm);
}

.modal-status-error { color: var(--danger); }
.modal-status-success { color: var(--success-dark); }
.modal-status-info { color: var(--gray-500); }

/* --- Date Mode Controls --- */
.date-mode-row {
    display: flex;
    gap: var(--sp-4);
    margin-bottom: var(--sp-2);
}

.date-mode-option {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--font-size-base);
    color: var(--gray-700);
    cursor: pointer;
}

.date-mode-option input[type="radio"] {
    accent-color: var(--primary);
    margin: 0;
}

.date-relative-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.date-offset-input {
    width: 60px !important;
    text-align: center;
}

.date-unit-select {
    width: auto !important;
    min-width: 80px;
}

.date-dir-select {
    width: auto !important;
    min-width: 70px;
}

.date-relative-label {
    font-size: var(--font-size-base);
    color: var(--gray-500);
    white-space: nowrap;
}

.date-preview {
    font-size: var(--font-size-sm);
    color: var(--primary-dark);
    font-weight: 500;
    padding: var(--sp-1) 0;
    margin-top: var(--sp-1);
}

/* ==========================================================================
   Template Management Modal
   Larger than the rest of the dashboard on purpose — this is a dedicated
   management surface, not an inline panel, so density rules are relaxed.
   ========================================================================== */

/* Wider than the default modal so the CRUD table fits comfortably */
.modal-content.template-modal {
    width: 920px;
    max-width: 95vw;
    font-size: 13px;            /* base bump — everything inside inherits this */
    line-height: 1.5;
}

/* Header / footer sizing inside the template modal */
.template-modal .modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.template-modal .modal-close {
    font-size: 22px;
}

.template-modal .modal-body {
    padding: 16px 20px;
}

.template-modal .modal-footer {
    padding: 12px 20px;
    gap: 10px;
}

.template-modal .btn {
    font-size: 13px;
    padding: 6px 14px;
}

.template-modal .modal-field label,
.template-modal .modal-select-field label {
    font-size: 11px;
    margin-bottom: 4px;
}

.template-modal .modal-input,
.template-modal .modal-textarea {
    font-size: 13px;
    padding: 6px 8px;
}

.modal-loading {
    padding: 24px;
    text-align: center;
    color: var(--gray-500);
    font-size: 13px;
}

.tplmod-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--gray-200);
}

.tplmod-count {
    font-size: 12px;
    color: var(--gray-500);
    margin-left: auto;
}

/* List table */
.tplmod-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.tplmod-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    user-select: none;
}

.tplmod-table thead th.tplmod-th-sortable {
    cursor: pointer;
}

.tplmod-table thead th.tplmod-th-sortable:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.tplmod-table thead th.tplmod-th-sorted {
    color: var(--primary-dark);
}

.tplmod-sort-arrow {
    font-size: 9px;
    color: var(--primary);
}

.tplmod-table tbody td {
    padding: 10px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
    word-wrap: break-word;
    line-height: 1.45;
}

.tplmod-table tbody tr:hover {
    background: var(--gray-50);
}

.tplmod-table .tplmod-title {
    font-weight: 600;
    color: var(--gray-800);
}

.tplmod-table .tplmod-desc {
    color: var(--gray-500);
    font-size: 12px;
}

/* Column widths */
.tplmod-table th:nth-child(1),
.tplmod-table td:nth-child(1) { width: 18%; }      /* Title */
.tplmod-table th:nth-child(2),
.tplmod-table td:nth-child(2) { width: 12%; }      /* Type */
.tplmod-table th:nth-child(3),
.tplmod-table td:nth-child(3) { width: 14%; }      /* Section */
.tplmod-table th:nth-child(4),
.tplmod-table td:nth-child(4) { width: 11%; }      /* Priority */
.tplmod-table th:nth-child(5),
.tplmod-table td:nth-child(5) { width: 26%; }      /* Description */
.tplmod-table th:nth-child(6),
.tplmod-table td:nth-child(6) { width: 19%; }      /* Actions */

/* Row actions */
.tplmod-actions {
    text-align: right;
    white-space: nowrap;
}

.tplmod-btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    margin-left: 4px;
}

.tplmod-confirm-text {
    font-size: 12px;
    color: var(--danger-dark);
    font-weight: 600;
    margin-right: 6px;
}

/* Danger button variant (used for inline delete confirm) */
.btn.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger-dark);
}

.btn.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}
