/* ============================================================
   SAATPRO WORKSPACE
   AI RISK REGISTER GENERATOR
   ============================================================ */

.spw-risk-register {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, Helvetica, sans-serif;
    color: #333333;
    box-sizing: border-box;
}

.spw-risk-register *,
.spw-risk-register *::before,
.spw-risk-register *::after {
    box-sizing: border-box;
}


/* ============================================================
   HEADER
   ============================================================ */

.spw-risk-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 25px;
    padding: 24px 26px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e2e6ea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.spw-risk-header-icon {
    width: 54px;
    height: 54px;
    min-width: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #0056d2;
    color: #ffffff;
    font-size: 27px;
}

.spw-risk-header h2 {
    margin: 0 0 6px;
    color: #0056d2;
    font-size: 25px;
    line-height: 1.3;
}

.spw-risk-header p {
    margin: 0;
    color: #666666;
    font-size: 14px;
    line-height: 1.6;
}


/* ============================================================
   CARDS
   ============================================================ */

.spw-risk-card {
    margin-bottom: 22px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e2e6ea;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.spw-risk-card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #0056d2;
    color: #0056d2;
    font-size: 18px;
    font-weight: 700;
}

.spw-risk-card-title span {
    font-size: 20px;
}


/* ============================================================
   FORM GRID
   ============================================================ */

.spw-risk-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
}

.spw-risk-field {
    min-width: 0;
}

.spw-risk-field-full {
    grid-column: 1 / -1;
}

.spw-risk-field label {
    display: block;
    margin-bottom: 7px;
    color: #444444;
    font-size: 13px;
    font-weight: 600;
}

.spw-risk-field .required {
    color: #d63638;
    font-weight: 700;
}

.spw-risk-field input,
.spw-risk-field select,
.spw-risk-field textarea,
.spw-risk-large-textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd5dc;
    border-radius: 6px;
    background: #ffffff;
    color: #333333;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: none;
}

.spw-risk-field input,
.spw-risk-field select {
    height: 42px;
}

.spw-risk-field textarea,
.spw-risk-large-textarea {
    min-height: 110px;
    resize: vertical;
}

.spw-risk-field input:focus,
.spw-risk-field select:focus,
.spw-risk-field textarea:focus,
.spw-risk-large-textarea:focus {
    outline: none;
    border-color: #0056d2;
    box-shadow: 0 0 0 2px rgba(0, 86, 210, 0.10);
}


/* ============================================================
   HELP TEXT
   ============================================================ */

.spw-risk-help {
    margin: -8px 0 18px;
    color: #666666;
    font-size: 13px;
    line-height: 1.6;
}


/* ============================================================
   CATEGORY SELECTION
   ============================================================ */

.spw-risk-category-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.spw-risk-category {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #dfe4e9;
    border-radius: 6px;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color 0.15s ease,
                background 0.15s ease;
}

.spw-risk-category:hover {
    border-color: #0056d2;
    background: #f5f8fd;
}

.spw-risk-category input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #0056d2;
}

.spw-risk-category span {
    color: #444444;
    font-size: 13px;
    line-height: 1.4;
}

.spw-risk-category-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}


/* ============================================================
   BUTTONS
   ============================================================ */

.spw-risk-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 25px 0;
    flex-wrap: wrap;
}
.spw-risk-primary-button,
.spw-risk-secondary-button,
.spw-risk-reset-button,
.spw-risk-export-button {
    border-radius: 6px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.spw-risk-primary-button {
    padding: 12px 22px;
    border: 1px solid #0056d2;
    background: #0056d2;
    color: #ffffff;
}

.spw-risk-primary-button:hover {
    background: #0046ad;
    border-color: #0046ad;
}

.spw-risk-primary-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.spw-risk-secondary-button {
    padding: 7px 13px;
    border: 1px solid #cbd2d9;
    background: #ffffff;
    color: #444444;
}

.spw-risk-secondary-button:hover {
    border-color: #0056d2;
    color: #0056d2;
}

.spw-risk-reset-button {
    padding: 12px 20px;
    border: 1px solid #cbd2d9;
    background: #ffffff;
    color: #555555;
}

.spw-risk-reset-button:hover {
    border-color: #999999;
    background: #f7f7f7;
}


/* ============================================================
   AI STATUS
   ============================================================ */

.spw-risk-ai-status {
    min-height: 20px;
    margin: 10px 0 20px;
    color: #555555;
    font-size: 13px;
    line-height: 1.5;
}

.spw-risk-ai-status.success {
    color: #188038;
}

.spw-risk-ai-status.error {
    color: #c5221f;
}

.spw-risk-ai-status.loading {
    color: #0056d2;
}


/* ============================================================
   OUTPUT
   ============================================================ */

.spw-risk-output {
    margin-top: 25px;
}

.spw-risk-section {
    margin-top: 30px;
}

.spw-risk-section h3 {
    margin: 0 0 15px;
    padding-left: 10px;
    border-left: 4px solid #0056d2;
    color: #0056d2;
    font-size: 17px;
}


/* ============================================================
   SUMMARY
   ============================================================ */

.spw-risk-summary {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 25px;
}

.spw-risk-summary-card {
    padding: 14px;
    border: 1px solid #dfe4e9;
    border-radius: 7px;
    background: #fafbfc;
    text-align: center;
}

.spw-risk-summary-card .label {
    display: block;
    margin-bottom: 5px;
    color: #666666;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.spw-risk-summary-card .value {
    display: block;
    color: #0056d2;
    font-size: 22px;
    font-weight: 700;
}


/* ============================================================
   RISK REGISTER TABLE
   ============================================================ */

.spw-risk-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 10px;
    border: 1px solid #d9dee3;
    border-radius: 7px;
    background: #ffffff;
}

.spw-risk-register-table {
    width: 100%;
    min-width: 2400px;
    border-collapse: collapse;
    border-spacing: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

.spw-risk-register-table th {
    padding: 10px 8px;
    border: 1px solid #cfd5dc;
    background: #f1f5fb;
    color: #333333;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    vertical-align: middle;
    white-space: normal;
}

.spw-risk-register-table td {
    padding: 8px;
    border: 1px solid #d9dee3;
    background: #ffffff;
    color: #333333;
    font-size: 11px;
    line-height: 1.45;
    vertical-align: top;
}

.spw-risk-register-table tbody tr:nth-child(even) td {
    background: #fafbfc;
}

.spw-risk-register-table td textarea,
.spw-risk-register-table td input,
.spw-risk-register-table td select {
    width: 100%;
    min-width: 90px;
    padding: 6px;
    border: 1px solid #ccd2d8;
    border-radius: 4px;
    background: #ffffff;
    color: #333333;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 1.4;
}

.spw-risk-register-table td textarea {
    min-height: 65px;
    resize: vertical;
}

.spw-risk-register-table td input:focus,
.spw-risk-register-table td select:focus,
.spw-risk-register-table td textarea:focus {
    outline: none;
    border-color: #0056d2;
    box-shadow: 0 0 0 1px rgba(0, 86, 210, 0.12);
}


/* ============================================================
   RISK LEVEL BADGES
   ============================================================ */

.spw-risk-level {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.spw-risk-level-low {
    background: #e8f5e9;
    color: #2e7d32;
}

.spw-risk-level-moderate {
    background: #fff8e1;
    color: #8a6d00;
}

.spw-risk-level-high {
    background: #fff0d6;
    color: #a15c00;
}

.spw-risk-level-very-high {
    background: #fde7e7;
    color: #b42318;
}

.spw-risk-level-critical {
    background: #f8d7da;
    color: #8b0000;
}


/* ============================================================
   RISK MATRIX
   ============================================================ */

.spw-risk-matrix {
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.spw-risk-matrix table {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

.spw-risk-matrix th,
.spw-risk-matrix td {
    border: 1px solid #cfd5dc;
    padding: 10px;
    text-align: center;
    vertical-align: middle;
}

.spw-risk-matrix th {
    background: #f1f5fb;
    color: #333333;
    font-weight: 700;
}

.spw-risk-matrix .matrix-axis {
    background: #f8f9fa;
    color: #555555;
    font-weight: 700;
}

.spw-risk-matrix .matrix-low {
    background: #e8f5e9;
}

.spw-risk-matrix .matrix-moderate {
    background: #fff8e1;
}

.spw-risk-matrix .matrix-high {
    background: #fff0d6;
}

.spw-risk-matrix .matrix-very-high {
    background: #fde7e7;
}

.spw-risk-matrix .matrix-critical {
    background: #f8d7da;
}


/* ============================================================
   EXPORT BUTTONS
   ============================================================ */

.spw-risk-export-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e0e4e8;
}

.spw-risk-export-button {
    min-width: 170px;
    padding: 11px 18px;
    border: 1px solid #0056d2;
    background: #ffffff;
    color: #0056d2;
}

.spw-risk-export-button:hover {
    background: #0056d2;
    color: #ffffff;
}


/* ============================================================
   COMMENTS
   ============================================================ */

.spw-risk-register-table th:last-child {
    min-width: 220px;
}

.spw-risk-register-table td:last-child {
    min-width: 220px;
}


/* ============================================================
   PRINT
   ============================================================ */

@media print {

    .spw-risk-register {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .spw-risk-header,
    .spw-risk-actions,
    .spw-risk-ai-status,
    .spw-risk-category-actions,
    .spw-risk-export-actions {
        display: none !important;
    }

    .spw-risk-card {
        margin: 0 0 20px;
        padding: 0;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .spw-risk-card-title {
        page-break-after: avoid;
    }

    .spw-risk-table-wrapper {
        overflow: visible;
        border: none;
    }

    .spw-risk-register-table {
        min-width: 0;
        width: 100%;
        font-size: 8pt;
    }

    .spw-risk-register-table th {
        background: #f1f5fb !important;
        color: #222222 !important;
        padding: 5px;
        font-size: 7pt;
    }

    .spw-risk-register-table td {
        padding: 5px;
        font-size: 7pt;
    }

    .spw-risk-register-table input,
    .spw-risk-register-table select,
    .spw-risk-register-table textarea {
        border: none !important;
        padding: 0 !important;
        min-width: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        font-size: 7pt !important;
    }

    .spw-risk-section {
        page-break-inside: avoid;
    }

    .spw-risk-matrix {
        max-width: 600px;
    }

}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {

    .spw-risk-category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .spw-risk-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

}


@media (max-width: 800px) {

    .spw-risk-register {
        padding: 12px;
    }

    .spw-risk-header {
        align-items: flex-start;
        padding: 18px;
    }

    .spw-risk-header h2 {
        font-size: 21px;
    }

    .spw-risk-grid {
        grid-template-columns: 1fr;
    }

    .spw-risk-field-full {
        grid-column: auto;
    }

    .spw-risk-category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .spw-risk-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .spw-risk-actions,
    .spw-risk-export-actions {
        flex-wrap: wrap;
    }

}


@media (max-width: 500px) {

    .spw-risk-header {
        flex-direction: column;
    }

    .spw-risk-category-grid {
        grid-template-columns: 1fr;
    }

    .spw-risk-summary {
        grid-template-columns: 1fr;
    }

    .spw-risk-primary-button,
    .spw-risk-reset-button,
    .spw-risk-export-button {
        width: 100%;
    }

}
/* =====================================================
   CUSTOMIZATION REQUEST
===================================================== */

.spw-risk-customization-action {
    margin-top: 18px;
    text-align: center;
}

.spw-risk-customization-button {
    display: inline-block;
}
/* =====================================================
   FINAL RISK REGISTER ALIGNMENT
===================================================== */

/* Main header */

.spw-risk-header {
    text-align: center;
    justify-content: center;
}

.spw-risk-header > div:last-child {
    text-align: center;
}


/* Card headings */

.spw-risk-card-title {
    text-align: center;
    justify-content: center;
}


/* AI action buttons */

.spw-risk-actions {
    justify-content: center;
    text-align: center;
}


/* AI status */

.spw-risk-ai-status {
    text-align: center;
}


/* Generated Risk Register heading */

.spw-risk-output .spw-risk-card-title {
    text-align: center;
    justify-content: center;
}


/* Risk Matrix section */

.spw-risk-section {
    text-align: center;
}

.spw-risk-section h3 {
    text-align: center;
}


/* Risk Matrix itself */

.spw-risk-matrix {
    margin-left: auto;
    margin-right: auto;
}


/* Export buttons */

.spw-risk-export-actions {
    justify-content: center;
    text-align: center;
}


/* Customization box */

.spw-customization-prompt {
    text-align: center;
}

.spw-customization-prompt button {
    margin-left: auto;
    margin-right: auto;
}