/* -------------------------------------------------------------------------
   ProImpact Plugin Hub application design system
   ------------------------------------------------------------------------- */

:root {
    --ph-bg: #f4f7fb;
    --ph-panel: #ffffff;
    --ph-panel-soft: #f8fafc;
    --ph-border: #dce5f0;
    --ph-border-strong: #c7d4e4;
    --ph-text: #10213d;
    --ph-muted: #667a99;
    --ph-accent: #1167d8;
    --ph-accent-soft: #eef5ff;
    --ph-success: #14854a;
    --ph-warning: #a76500;
    --ph-danger: #bd2727;
    --ph-radius: 14px;
    --ph-shadow: 0 8px 24px rgba(25, 54, 93, 0.06);
}

.ph-page,
#page-wrapper.ph-page {
    min-height: calc(100vh - 60px);
    background: var(--ph-bg);
    color: var(--ph-text);
    padding: 22px;
    box-sizing: border-box;
}

.ph-shell,
#content-wrapper.ph-shell {
    max-width: 1360px;
    margin: 0 auto;
}

.ph-header {
    margin-bottom: 18px;
}

.ph-eyebrow {
    margin: 0 0 4px;
    color: var(--ph-accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ph-title {
    margin: 0;
    color: var(--ph-text);
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    line-height: 1.18;
    font-weight: 750;
}

.ph-subtitle {
    max-width: 900px;
    margin: 7px 0 0;
    color: var(--ph-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.ph-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.32fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.ph-stack {
    display: grid;
    gap: 16px;
}

.ph-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ph-panel {
    background: var(--ph-panel);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius);
    box-shadow: var(--ph-shadow);
    padding: 18px;
}

.ph-panel--soft {
    background: var(--ph-panel-soft);
    box-shadow: none;
}

.ph-panel-title {
    margin: 0 0 4px;
    color: var(--ph-text);
    font-size: 1.03rem;
    font-weight: 730;
}

.ph-panel-help,
.ph-hint {
    margin: 0 0 14px;
    color: var(--ph-muted);
    font-size: 0.87rem;
    line-height: 1.5;
}

.ph-section-label {
    margin: 0 0 10px;
    color: var(--ph-text);
    font-size: 0.82rem;
    font-weight: 700;
}

.ph-field,
.ph-panel label {
    color: var(--ph-text);
    font-size: 0.82rem;
    font-weight: 650;
}

.ph-actions,
.button-group.ph-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.ph-button,
button.ph-button,
a.ph-button,
.btn.ph-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 15px;
    border: 1px solid var(--ph-border-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--ph-text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 680;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.ph-button:hover:not(:disabled) {
    border-color: #91afd2;
    background: #f7faff;
    transform: translateY(-1px);
}

.ph-button--primary,
button.ph-button--primary,
a.ph-button--primary {
    border-color: var(--ph-accent);
    background: var(--ph-accent);
    color: #fff;
}

.ph-button--primary:hover:not(:disabled) {
    background: #0d58ba;
    border-color: #0d58ba;
}

.ph-button:disabled,
button.ph-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
}

.ph-status {
    margin-top: 10px;
    color: var(--ph-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.ph-status--success { color: var(--ph-success); }
.ph-status--warning { color: var(--ph-warning); }
.ph-status--error { color: var(--ph-danger); }

.ph-code,
.ph-output {
    margin: 12px 0 0;
    padding: 12px 14px;
    background: #f7f9fc;
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    color: #344968;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-x: auto;
}

.ph-figure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.ph-figure-thumb {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

/* Shared controls --------------------------------------------------------- */
.ph-page .Select-control,
.ph-page input[type="text"],
.ph-page input[type="number"],
.ph-page textarea {
    border-color: var(--ph-border-strong) !important;
    border-radius: 8px !important;
}

.ph-page .Select-control {
    min-height: 38px;
}

.ph-page hr {
    border: 0;
    border-top: 1px solid var(--ph-border);
    margin: 16px 0;
}

/* xclim temperature / precipitation -------------------------------------- */
.ph-climate-form {
    display: grid;
    gap: 14px;
}

.ph-climate-form > label {
    display: block;
    margin-bottom: 5px;
}

.ph-climate-params {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.ph-climate-params > div {
    min-width: 150px;
}

.ph-time-controls {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--ph-border);
}

.ph-time-controls button {
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--ph-border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ph-text);
    font-weight: 650;
}

.plot-container.ph-plot-container,
.ph-plot-container {
    margin-top: 14px;
    min-height: 360px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--ph-border);
    border-radius: 12px;
    background: #fff;
}

.plot-image.ph-plot-image,
.ph-plot-image,
.ph-plot-container .plot-image {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Blocking --------------------------------------------------------------- */
.ph-blocking-mode .dash-radio-items,
.ph-blocking-mode label {
    margin-right: 16px;
}

.params-group-title {
    margin: 20px 0 10px;
    color: var(--ph-text);
    font-size: 0.95rem;
    font-weight: 720;
}

.params-group-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 12px;
    margin-bottom: 10px;
    align-items: end;
}

.params-group-row > div {
    max-width: none !important;
    min-width: 0 !important;
    width: 100% !important;
    margin-bottom: 0 !important;
}

.params-group-row input {
    width: 100% !important;
    height: 38px !important;
    box-sizing: border-box;
}

/* Existing climate landing/index cards retained under shared tokens. */
.climate-section {
    margin: 28px auto;
    max-width: 1200px;
    padding: 0 20px;
}

.section-title {
    margin-bottom: 16px;
    padding-bottom: 9px;
    color: var(--ph-text);
    border-bottom: 1px solid var(--ph-border);
    font-size: 1.4rem;
}

.index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.index-card {
    background: #fff;
    border: 1px solid var(--ph-border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--ph-shadow);
    text-align: center;
}

.index-btn {
    display: inline-flex;
    padding: 7px 13px;
    background: var(--ph-accent);
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 650;
}

/* Placeholder plugins ---------------------------------------------------- */
.ph-placeholder {
    min-height: 380px;
    display: grid;
    place-items: center;
    text-align: center;
}

.ph-placeholder-mark {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    margin: 0 auto 12px;
    border-radius: 12px;
    background: var(--ph-accent-soft);
    color: var(--ph-accent);
    font-weight: 800;
}

/* Date picker harmonization. */
.SingleDatePickerInput {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
}
.DateInput { background: transparent !important; }
.DateInput_input {
    border: 1px solid var(--ph-border-strong) !important;
    border-radius: 8px !important;
    padding: 7px 9px !important;
}

@media (max-width: 900px) {
    .ph-page { padding: 14px; }
    .ph-layout,
    .ph-grid-2 { grid-template-columns: 1fr; }
}

/* Plugin Hub landing extras ------------------------------------------------ */
.map-selector-wrapper {
    max-width: 1360px;
    margin: 20px auto 0;
    padding: 18px;
    background: var(--ph-panel);
    border: 1px solid var(--ph-border);
    border-radius: var(--ph-radius);
    box-shadow: var(--ph-shadow);
}

.map-selector-title {
    margin: 0 0 12px;
    color: var(--ph-text);
    font-size: 1.05rem;
    font-weight: 720;
}

.map-selector-frame {
    display: block;
    width: 100% !important;
    border: 1px solid var(--ph-border) !important;
    border-radius: 12px !important;
    background: #fff;
}

/* Blocking namelist metadata ------------------------------------------------ */
.ph-meta-card {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    background: #f8fbff;
}

.ph-meta-header {
    margin-bottom: 10px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--ph-border);
}

.ph-meta-heading {
    color: var(--ph-text);
    font-size: 0.82rem;
    font-weight: 750;
}

.ph-meta-file {
    margin-top: 2px;
    color: var(--ph-muted);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.ph-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

.ph-meta-item {
    min-width: 0;
}

.ph-meta-label,
.ph-meta-value {
    display: block;
}

.ph-meta-label {
    margin-bottom: 2px;
    color: var(--ph-muted);
    font-size: 0.7rem;
}

.ph-meta-value {
    color: var(--ph-text);
    font-size: 0.78rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

/* Blocking generated figure gallery --------------------------------------- */
.ph-figure-card {
    min-width: 0;
}

.ph-figure-caption {
    margin-top: 6px;
    color: var(--ph-muted);
    font-size: 0.72rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

@media (max-width: 700px) {
    .ph-meta-grid { grid-template-columns: 1fr; }
}


/* Blocking figure preview modal ------------------------------------------- */
.blocking-figure-modal .modal-dialog {
    width: min(86vw, 1100px);
    max-width: min(86vw, 1100px);
    margin-left: auto;
    margin-right: auto;
}

.blocking-figure-modal .modal-content {
    max-height: 88vh;
    border: 1px solid var(--ph-border);
    border-radius: 14px;
    overflow: hidden;
}

.blocking-modal-body {
    padding: 18px 20px;
    overflow: auto;
}

.blocking-modal-image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 240px;
}

.blocking-modal-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 68vh;
    object-fit: contain;
}

@media (max-width: 700px) {
    .blocking-figure-modal .modal-dialog {
        width: 94vw;
        max-width: 94vw;
        margin: 1.25rem auto;
    }

    .blocking-modal-body {
        padding: 12px;
    }

    .blocking-modal-image {
        max-height: 62vh;
    }
}


/* Blocking gallery caption polish ----------------------------------------- */
.ph-figure-caption {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: 2.1em;
    text-align: center;
    word-break: break-word;
}

/* Hard cap the Blocking preview even if Bootstrap/theme rules override it. */
.blocking-figure-modal .modal-dialog {
    width: min(82vw, 1040px) !important;
    max-width: min(82vw, 1040px) !important;
}
.blocking-figure-modal .modal-content {
    max-height: 84vh !important;
}
.blocking-figure-modal .modal-body {
    overflow: auto !important;
}
.blocking-figure-modal .blocking-modal-image {
    width: auto !important;
    height: auto !important;
    max-width: min(78vw, 980px) !important;
    max-height: 64vh !important;
    object-fit: contain !important;
    margin: 0 auto !important;
}

/* xclim dataset inspection ------------------------------------------------ */
.ph-index-dropdown .Select-control {
    min-height: 42px !important;
    height: auto !important;
}

.ph-index-dropdown .Select-value,
.ph-index-dropdown .Select-placeholder {
    position: relative !important;
    line-height: 1.25 !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    white-space: normal !important;
}

.ph-index-dropdown .Select-value-label {
    white-space: normal !important;
    line-height: 1.25 !important;
}

.ph-source-block {
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    padding: 12px;
    display: grid;
    gap: 10px;
    background: #fbfdff;
}

.ph-field-title {
    margin: 0;
    font-size: 0.92rem;
}

.ph-role-heading {
    margin-top: 6px;
}

.ph-radio-stack,
.ph-radio-inline {
    display: flex;
    gap: 10px;
}

.ph-radio-stack {
    flex-direction: column;
}

.ph-radio-inline {
    flex-wrap: wrap;
}

.ph-radio-stack label,
.ph-radio-inline label {
    margin-right: 14px;
}

.ph-role-row {
    display: grid;
    gap: 6px;
}

.ph-dataset-preview {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

.ph-dataset-card {
    border: 1px solid var(--ph-border);
    border-radius: 10px;
    padding: 12px;
    background: #fbfdff;
    overflow-x: auto;
}

.ph-dataset-card-title {
    margin: 0 0 8px;
}

.ph-meta-line {
    color: var(--ph-muted);
    margin: 3px 0;
    overflow-wrap: anywhere;
}

.ph-metadata-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.82rem;
}

.ph-metadata-table th,
.ph-metadata-table td {
    text-align: left;
    vertical-align: top;
    padding: 6px 8px;
    border-bottom: 1px solid var(--ph-border);
}

.ph-metadata-table th {
    font-weight: 700;
    white-space: nowrap;
}

.ph-empty-preview {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ph-muted);
    border: 1px dashed var(--ph-border-strong);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
}

.ph-variable-info {
    margin-top: 4px;
    color: var(--ph-muted);
    font-size: 0.82rem;
}

/* Hide the empty result-map frame until a computation provides an image. */
.ph-plot-container:has(.ph-plot-image:not([src])),
.ph-plot-container:has(.ph-plot-image[src=""]) {
    display: none;
    min-height: 0;
    border: 0;
    margin-top: 0;
}

/* xclim v11.3 readability and local-file workflow ------------------------ */
.ph-index-dropdown .Select-control {
    min-height: 40px !important;
    height: 40px !important;
}

.ph-index-dropdown .Select-value,
.ph-index-dropdown .Select-placeholder {
    line-height: 38px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ph-index-dropdown .Select-value-label {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ph-index-dropdown .VirtualizedSelectOption {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ph-index-full-label {
    margin-top: 6px;
    min-height: 1.2em;
    font-size: 0.78rem;
    line-height: 1.3;
    color: #c62828;
}

.ph-climate-params input,
.ph-climate-params .Select,
.ph-climate-params .DateInput,
.ph-climate-params .SingleDatePicker,
.ph-climate-params .SingleDatePickerInput {
    width: 75% !important;
    min-width: 180px;
}

.ph-upload-box {
    width: 100%;
    min-height: 66px;
    border: 1px dashed var(--ph-border);
    border-radius: 8px;
    background: #f8fbff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    text-align: center;
    cursor: pointer;
}

.ph-upload-box:hover {
    border-color: #1f6fd6;
    background: #f2f7ff;
}

.ph-upload-help {
    margin-top: 6px;
    color: var(--ph-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}
.ph-selected-variable {
    margin-top: 6px;
    padding: 8px 10px;
    border-left: 3px solid #1f6fd6;
    background: #f8fbff;
    font-size: 0.8rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}


/* xclim v11.4 compact selector and file-picker refinement ---------------- */
.ph-index-dropdown,
.ph-index-dropdown .Select-control {
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
}

.ph-index-dropdown .Select-value,
.ph-index-dropdown .Select-placeholder {
    height: 38px !important;
    line-height: 38px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ph-index-dropdown .Select-value-label {
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ph-index-dropdown .VirtualizedSelectOption {
    height: 38px !important;
    line-height: 38px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ph-index-full-label {
    margin-top: 7px;
    min-height: 34px;
    max-width: 100%;
    font-size: 0.78rem;
    line-height: 1.35;
    color: #c62828;
    overflow-wrap: anywhere;
}

.ph-source-block {
    padding: 10px;
    gap: 8px;
}

.ph-upload-box {
    width: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    display: block;
    text-align: left;
}

.ph-file-picker {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    border: 1px solid var(--ph-border-strong);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
}

.ph-file-picker-button {
    flex: 0 0 auto;
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 13px;
    border-right: 1px solid var(--ph-border-strong);
    background: var(--ph-accent-soft);
    color: var(--ph-accent);
    font-weight: 700;
}

.ph-file-picker-text {
    min-width: 0;
    padding: 0 12px;
    color: var(--ph-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-upload-box:hover .ph-file-picker {
    border-color: var(--ph-accent);
}

.ph-role-heading {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--ph-border);
}


/* xclim v11.5 final selector/status polish -------------------------------- */
.ph-index-dropdown {
    width: 82% !important;
    min-width: 150px;
    max-width: 220px;
}

.ph-index-dropdown .Select-control {
    height: 36px !important;
    min-height: 36px !important;
}

.ph-index-dropdown .Select-value,
.ph-index-dropdown .Select-placeholder {
    height: 34px !important;
    line-height: 34px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-size: 0.9rem;
}

.ph-index-dropdown .Select-value-label {
    display: inline !important;
    line-height: 34px !important;
    font-size: 0.9rem;
}

.ph-index-full-label {
    margin-top: 6px;
    min-height: 1.35em;
    font-size: 0.76rem;
    line-height: 1.3;
}

.ph-next-step-note {
    margin-top: 6px;
    color: #c62828;
    font-size: 0.78rem;
    line-height: 1.35;
    font-weight: 600;
}

/* xclim v11.6 final single-line climate-index selector ------------------- */
.ph-index-dropdown {
    width: 82% !important;
    min-width: 150px;
    max-width: 220px;
    height: 38px !important;
    min-height: 38px !important;
    margin-bottom: 10px;
    position: relative;
}

.ph-index-dropdown .Select,
.ph-index-dropdown .Select-control,
.ph-index-dropdown .Select-multi-value-wrapper,
.ph-index-dropdown .Select-input {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
}

.ph-index-dropdown .Select-control {
    display: table !important;
}

.ph-index-dropdown .Select-value,
.ph-index-dropdown .Select-placeholder {
    height: 36px !important;
    line-height: 36px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.9rem !important;
}

.ph-index-dropdown .Select-value-label {
    display: inline !important;
    line-height: 36px !important;
    white-space: nowrap !important;
    font-size: 0.9rem !important;
}

.ph-index-dropdown .Select-input > input {
    height: 34px !important;
    padding: 0 !important;
    line-height: 34px !important;
}

.ph-index-dropdown .Select-arrow-zone,
.ph-index-dropdown .Select-clear-zone {
    height: 36px !important;
    vertical-align: middle !important;
}

.ph-index-full-label {
    display: block;
    clear: both;
    margin-top: 0;
    margin-bottom: 2px;
    min-height: 1.35em;
    font-size: 0.76rem;
    line-height: 1.3;
    color: #c62828;
    overflow-wrap: anywhere;
}
