/**
 * SaatPro Workspace
 * RACI Matrix Builder
 *
 * Module-specific styles only.
 * Does not modify shared Workspace styles.
 */


/* =========================================================
   MODULE BASE
   ========================================================= */

.spw-raci-module {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.spw-raci-module *,
.spw-raci-module *::before,
.spw-raci-module *::after {
    box-sizing: border-box;
}


/* =========================================================
   MODULE HEADER
   ========================================================= */

.spw-raci-module .spw-module-header {
    margin-bottom: 24px;
}

.spw-raci-module .spw-module-title {
    margin: 0 0 8px;
}

.spw-raci-module .spw-module-description {
    margin: 0;
    line-height: 1.6;
}


/* =========================================================
   CARD LAYOUT
   ========================================================= */

.spw-raci-module .spw-card {
    width: 100%;
    margin-bottom: 24px;
}

.spw-raci-module .spw-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.spw-raci-module .spw-card-title {
    margin: 0 0 6px;
}

.spw-raci-module .spw-card-description {
    margin: 0;
    line-height: 1.55;
}

.spw-raci-module .spw-card-body {
    width: 100%;
}


/* =========================================================
   FORM
   ========================================================= */

.spw-raci-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    width: 100%;
}

.spw-raci-description-group {
    margin-top: 20px;
}

.spw-raci-module .spw-form-group {
    min-width: 0;
}

.spw-raci-module .spw-form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
}

.spw-raci-module .spw-input,
.spw-raci-module .spw-textarea {
    width: 100%;
    max-width: 100%;
    font-family: inherit;
    line-height: 1.5;
}

.spw-raci-module .spw-textarea {
    resize: vertical;
    min-height: 120px;
}

.spw-raci-module .spw-field-help {
    margin: 7px 0 0;
    font-size: 13px;
    line-height: 1.5;
}


/* =========================================================
   ASSISTANT ACTIONS
   ========================================================= */

.spw-raci-assistant-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.spw-raci-module .spw-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    cursor: pointer;
    white-space: nowrap;
}

.spw-raci-module .spw-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.spw-button-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spw-raci-spin 0.7s linear infinite;
}

@keyframes spw-raci-spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   STATUS
   ========================================================= */

.spw-raci-status,
.spw-raci-export-status {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    line-height: 1.5;
}

.spw-raci-status[hidden],
.spw-raci-export-status[hidden] {
    display: none;
}

.spw-raci-status {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.spw-raci-status-icon {
    flex: 0 0 auto;
}


/* =========================================================
   RESULTS
   ========================================================= */

.spw-raci-results[hidden] {
    display: none;
}

.spw-raci-results {
    width: 100%;
}


/* =========================================================
   PROJECT SUMMARY
   ========================================================= */

.spw-raci-project-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.spw-raci-project-summary-item {
    min-width: 0;
}

.spw-raci-project-summary-label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.spw-raci-project-summary-value {
    display: block;
    line-height: 1.5;
    overflow-wrap: anywhere;
}


/* =========================================================
   DASHBOARD
   ========================================================= */

.spw-raci-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}

.spw-raci-stat-card {
    min-width: 0;
    padding: 18px 14px;
    border: 1px solid #e1e5ea;
    border-radius: 8px;
    text-align: center;
    background: #fff;
}

.spw-raci-stat-value {
    margin-bottom: 5px;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.spw-raci-stat-label {
    font-size: 12px;
    line-height: 1.4;
}

.spw-raci-stat-warning {
    border-color: #e7d6a0;
}


/* =========================================================
   MATRIX HEADER
   ========================================================= */

.spw-raci-matrix-header {
    align-items: center;
}

.spw-raci-matrix-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}


/* =========================================================
   MATRIX TABLE WRAPPER
   ========================================================= */

.spw-raci-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e1e5ea;
    border-radius: 8px;
}


/* =========================================================
   RACI TABLE
   ========================================================= */

.spw-raci-matrix-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
    background: #fff;
}

.spw-raci-matrix-table th,
.spw-raci-matrix-table td {
    border-right: 1px solid #e1e5ea;
    border-bottom: 1px solid #e1e5ea;
    vertical-align: middle;
}

.spw-raci-matrix-table th:last-child,
.spw-raci-matrix-table td:last-child {
    border-right: 0;
}

.spw-raci-matrix-table tr:last-child td {
    border-bottom: 0;
}


/* =========================================================
   MATRIX HEADER CELLS
   ========================================================= */

.spw-raci-matrix-table thead th {
    min-width: 110px;
    padding: 11px 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

.spw-raci-matrix-table thead th.spw-raci-activity-header {
    width: 240px;
    min-width: 240px;
    text-align: left;
}

.spw-raci-matrix-table thead th.spw-raci-deliverable-header {
    width: 220px;
    min-width: 220px;
    text-align: left;
}

.spw-raci-role-header {
    width: 120px;
    min-width: 120px;
}


/* =========================================================
   MATRIX BODY CELLS
   ========================================================= */

.spw-raci-matrix-table tbody td {
    min-width: 110px;
    padding: 8px;
    font-size: 13px;
    line-height: 1.45;
}

.spw-raci-matrix-table tbody td.spw-raci-activity-cell {
    width: 240px;
    min-width: 240px;
}

.spw-raci-matrix-table tbody td.spw-raci-deliverable-cell {
    width: 220px;
    min-width: 220px;
}


/* =========================================================
   EDITABLE MATRIX FIELDS
   ========================================================= */

.spw-raci-edit-input,
.spw-raci-edit-textarea,
.spw-raci-role-input,
.spw-raci-assignment-select {
    width: 100%;
    max-width: 100%;
    margin: 0;
    font-family: inherit;
}

.spw-raci-edit-input,
.spw-raci-role-input {
    min-height: 36px;
}

.spw-raci-edit-textarea {
    min-height: 58px;
    resize: vertical;
}

.spw-raci-assignment-select {
    min-width: 70px;
    min-height: 38px;
    padding: 6px 8px;
    text-align: center;
    text-align-last: center;
    font-weight: 700;
    cursor: pointer;
}


/* =========================================================
   RACI ASSIGNMENT CELLS
   ========================================================= */

.spw-raci-assignment-cell {
    width: 120px;
    min-width: 120px;
    padding: 6px !important;
    text-align: center;
}

.spw-raci-assignment-cell select {
    display: block;
    margin-left: auto;
    margin-right: auto;
}


/* =========================================================
   ASSIGNMENT VISUAL STATES
   ========================================================= */

.spw-raci-assignment-cell[data-raci="R"] {
    background: rgba(0, 86, 210, 0.06);
}

.spw-raci-assignment-cell[data-raci="A"] {
    background: rgba(220, 53, 69, 0.06);
}

.spw-raci-assignment-cell[data-raci="C"] {
    background: rgba(255, 193, 7, 0.08);
}

.spw-raci-assignment-cell[data-raci="I"] {
    background: rgba(25, 135, 84, 0.06);
}


/* =========================================================
   ROLE / ACTIVITY CONTROLS
   ========================================================= */

.spw-raci-row-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 7px;
}

.spw-raci-role-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.spw-raci-row-delete,
.spw-raci-role-delete {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
}

.spw-raci-role-header-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


/* =========================================================
   EMPTY STATE
   ========================================================= */

.spw-raci-empty-state {
    padding: 30px 20px;
    text-align: center;
}

.spw-raci-empty-state[hidden] {
    display: none;
}

.spw-raci-empty-state p {
    margin: 0;
}


/* =========================================================
   LEGEND
   ========================================================= */

.spw-raci-legend {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.spw-raci-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.spw-raci-legend-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 1px solid #d9dee5;
    border-radius: 6px;
    font-weight: 700;
}

.spw-raci-legend-item strong {
    display: block;
    margin-bottom: 3px;
}

.spw-raci-legend-item span:not(.spw-raci-legend-code) {
    display: block;
    font-size: 12px;
    line-height: 1.5;
}

.spw-raci-code-r {
    background: rgba(0, 86, 210, 0.08);
}

.spw-raci-code-a {
    background: rgba(220, 53, 69, 0.08);
}

.spw-raci-code-c {
    background: rgba(255, 193, 7, 0.10);
}

.spw-raci-code-i {
    background: rgba(25, 135, 84, 0.08);
}


/* =========================================================
   VALIDATION
   ========================================================= */

.spw-raci-validation-empty {
    padding: 14px 16px;
    border: 1px solid #d9e7dc;
    border-radius: 7px;
    line-height: 1.5;
}

.spw-raci-validation-empty[hidden] {
    display: none;
}

.spw-raci-validation-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.spw-raci-validation-list[hidden] {
    display: none;
}

.spw-raci-validation-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid #ead9a5;
    border-radius: 7px;
    line-height: 1.5;
}

.spw-raci-validation-item:last-child {
    margin-bottom: 0;
}

.spw-raci-validation-icon {
    flex: 0 0 auto;
    font-weight: 700;
}

.spw-raci-validation-item strong {
    display: block;
    margin-bottom: 2px;
}


/* =========================================================
   EXPORT
   ========================================================= */

.spw-raci-export-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.spw-raci-export-status {
    line-height: 1.5;
}


/* =========================================================
   CUSTOMIZATION
   ========================================================= */

.spw-raci-customization-container {
    width: 100%;
}


/* =========================================================
   FOCUS / ACCESSIBILITY
   ========================================================= */

.spw-raci-module button:focus-visible,
.spw-raci-module input:focus-visible,
.spw-raci-module textarea:focus-visible,
.spw-raci-module select:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}


/* =========================================================
   RESPONSIVE — TABLET
   ========================================================= */

@media (max-width: 1100px) {

    .spw-raci-dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .spw-raci-project-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .spw-raci-legend {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* =========================================================
   RESPONSIVE — MOBILE
   ========================================================= */

@media (max-width: 760px) {

    .spw-raci-form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .spw-raci-project-summary {
        grid-template-columns: 1fr;
    }

    .spw-raci-dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .spw-raci-legend {
        grid-template-columns: 1fr;
    }

    .spw-raci-card-header,
    .spw-raci-matrix-header {
        align-items: flex-start;
    }

    .spw-raci-matrix-actions {
        width: 100%;
    }

    .spw-raci-matrix-actions .spw-button {
        flex: 1 1 auto;
    }

    .spw-raci-assistant-actions,
    .spw-raci-export-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .spw-raci-assistant-actions .spw-button,
    .spw-raci-export-actions .spw-button {
        width: 100%;
    }
}


/* =========================================================
   RESPONSIVE — SMALL MOBILE
   ========================================================= */

@media (max-width: 480px) {

    .spw-raci-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .spw-raci-stat-card {
        padding: 15px 12px;
    }

    .spw-raci-stat-value {
        font-size: 24px;
    }

    .spw-raci-module .spw-card-header {
        gap: 12px;
    }

    .spw-raci-matrix-actions {
        flex-direction: column;
    }

    .spw-raci-matrix-actions .spw-button {
        width: 100%;
    }
}


/* =========================================================
   PRINT BASELINE
   ========================================================= */

@media print {

    .spw-raci-module {
        width: 100%;
        max-width: none;
    }

    .spw-raci-table-wrapper {
        overflow: visible;
        border: 0;
    }

    .spw-raci-matrix-table {
        width: 100%;
        min-width: 0;
    }

    .spw-raci-matrix-table th,
    .spw-raci-matrix-table td {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .spw-raci-module .spw-button,
    .spw-raci-matrix-actions,
    .spw-raci-export-actions,
    .spw-raci-customization-card,
    .spw-raci-assistant-card {
        display: none !important;
    }

    .spw-raci-module .spw-card {
        margin-bottom: 15px;
        break-inside: avoid;
    }

    .spw-raci-matrix-card {
        break-inside: auto;
    }

    .spw-raci-matrix-table thead {
        display: table-header-group;
    }

    .spw-raci-matrix-table tr {
        break-inside: avoid;
    }
}