/* ============================================
   Matrix Styles - Open PRO / Nebula Inspired
   ============================================ */

/* Matrix View Flex Layout */
#matrix-view {
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    height: 100%;
}

#matrix-view .view-header {
    flex-shrink: 0;
}

#matrix-legend-bar {
    flex-shrink: 0;
}

/* Matrix Wrapper */
.matrix-wrapper {
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.5rem;
    overflow: auto;
    max-height: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    flex: 1;
    min-height: 0;
}

[data-theme="light"] .matrix-wrapper {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.matrix-table {
    border-collapse: separate;
    border-spacing: 1px;
    width: 100%;
    margin: 0;
}

.matrix-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--on-surface);
    padding: 1rem 0.65rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 120px;
    vertical-align: bottom;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

[data-theme="light"] .matrix-table th {
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.matrix-table th .tactic-short {
    display: block;
    font-size: 0.62rem;
    opacity: 0.8;
    font-weight: 500;
    margin-top: 0.2rem;
    color: var(--primary);
}

.matrix-table th .tactic-count {
    display: block;
    font-size: 0.58rem;
    opacity: 0.7;
    font-weight: 500;
    margin-top: 0.1rem;
    color: var(--on-surface-tertiary);
}

.matrix-table td {
    vertical-align: top;
    padding: 0;
    background: rgba(15, 23, 42, 0.2);
    min-width: 120px;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .matrix-table td {
    background: rgba(255, 255, 255, 0.3);
    border-right: 1px solid rgba(0, 0, 0, 0.03);
}

.matrix-table td:last-child {
    border-right: none;
}

/* Technique Cells */
.technique-cell {
    padding: 0.65rem 0.65rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: transparent;
}

[data-theme="light"] .technique-cell {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.technique-cell:last-child { border-bottom: none; }

.technique-cell:hover {
    background: var(--surface-variant);
    z-index: 2;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

[data-theme="light"] .technique-cell:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.technique-cell.has-children {
    background: transparent;
    border-left: 3px solid var(--primary);
    padding-left: calc(0.65rem - 3px);
}

.technique-cell.has-children:hover {
    background: var(--surface-variant);
}

.technique-cell.annotated {
    font-weight: 600;
}

.technique-cell.annotated::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: currentColor;
    opacity: 0.8;
    box-shadow: 0 0 8px currentColor;
    border-radius: 2px 0 0 2px;
    z-index: 1;
}

.technique-cell.annotated.has-children::before {
    left: -3px; /* Offset for the primary left border */
}

.expand-btn {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: var(--on-surface-tertiary);
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-xs);
}

.expand-btn:hover {
    background: var(--surface-variant);
    color: var(--primary);
    border: 1px solid var(--border);
}

.technique-cell.annotated .expand-btn {
    color: var(--on-surface-secondary);
}

.expand-btn.expanded i {
    transform: rotate(180deg);
}

.tech-id {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--primary);
}

.tech-name {
    font-size: 0.65rem;
    color: var(--on-surface-secondary);
    line-height: 1.35;
}

.technique-cell.annotated .tech-name {
    color: var(--on-surface);
}

/* Sub-techniques */
.sub-techniques-container {
    margin-left: 0.4rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 0.4rem;
}

[data-theme="light"] .sub-techniques-container {
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.sub-toggle {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.4rem;
    font-size: 0.6rem;
    color: var(--on-surface-tertiary);
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-xs);
}

.sub-toggle:hover {
    background: var(--surface-variant);
    color: var(--primary);
}

.technique-cell.sub-technique {
    padding: 0.35rem 0.5rem;
    font-size: 0.6rem;
    border-left: 2px solid rgba(255, 255, 255, 0.08);
    margin-top: 2px;
    border-radius: 0 4px 4px 0;
}

[data-theme="light"] .technique-cell.sub-technique {
    border-left: 2px solid rgba(0, 0, 0, 0.05);
}

.technique-cell.sub-technique:hover {
    background: var(--surface-variant);
}

.technique-cell.sub-technique .tech-id {
    font-size: 0.55rem;
}

.technique-cell.sub-technique .tech-name {
    font-size: 0.6rem;
}

.matrix-sentinel-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.15);
    border-radius: 50%;
    pointer-events: none;
}

.matrix-sentinel-badge i {
    font-size: 0.6rem;
}

.matrix-badges {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
}

.matrix-archived-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    color: var(--accent-orange);
    background: rgba(251, 146, 60, 0.15);
    border-radius: 50%;
    pointer-events: none;
}

.matrix-archived-badge i {
    font-size: 0.6rem;
}

.matrix-partial-archived-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    color: var(--accent-orange);
    background: rgba(251, 146, 60, 0.08);
    border: 1px solid rgba(251, 146, 60, 0.2);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.7;
}

.matrix-partial-archived-badge i {
    font-size: 0.6rem;
}

.sub-connector {
    display: inline-block;
    width: 6px;
    height: 1px;
    background: var(--border);
    margin-right: 3px;
    vertical-align: middle;
}

/* Platform Filters */
.platform-chips {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.platform-chips .btn-check:checked + .btn {
    background: var(--primary-light);
    color: var(--primary) !important;
    border-color: rgba(88, 76, 244, 0.3);
    box-shadow: none;
}

.platform-chips .btn {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--on-surface-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.platform-chips .btn:hover {
    background: var(--surface-variant);
    color: var(--on-surface);
    border-color: var(--on-surface-tertiary);
}

/* Matrix Search */
.matrix-search {
    position: relative;
}

.matrix-search .input-group-text {
    background: var(--surface-subtle);
    border-color: var(--border);
}

.matrix-search .form-control {
    font-size: 0.8rem;
    background: var(--surface-subtle);
    border-color: var(--border);
    color: var(--on-surface);
}

.matrix-search .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
    background: var(--surface-elevated);
}

/* Matrix No Results */
#matrix-no-results {
    padding: 3rem 1rem;
}

#matrix-no-results i {
    font-size: 2.5rem;
    opacity: 0.3;
    color: var(--primary);
}

#matrix-no-results h5 {
    color: var(--on-surface-secondary);
}

#matrix-no-results p {
    color: var(--on-surface-tertiary);
}

/* Custom Dropdown for Platform Filters */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    z-index: 1050;
    box-shadow: var(--shadow-xl), 0 0 20px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    max-height: 350px;
    overflow-y: auto;
}

/* Matrix Legend Bar Glassmorphism */
.matrix-legend-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .matrix-legend-bar {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.matrix-legend-section {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-right: 1.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .matrix-legend-section {
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.custom-dropdown:hover .dropdown-content {
    display: block;
}

/* Vertical items inside custom dropdown */
.custom-dropdown .platform-chips {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.custom-dropdown .platform-chips .btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: var(--on-surface-secondary) !important;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.custom-dropdown .platform-chips .btn:hover {
    background: var(--surface-variant) !important;
    color: var(--on-surface) !important;
}

/* Custom Checkbox icons using pseudo-elements */
.custom-dropdown .platform-chips .btn::before {
    content: '\F272'; /* bi-square in Bootstrap Icons */
    font-family: 'bootstrap-icons' !important;
    margin-right: 0.5rem;
    font-size: 0.85rem;
    color: var(--on-surface-tertiary);
    flex-shrink: 0;
    display: inline-block;
}

.custom-dropdown .platform-chips .btn-check:checked + .btn {
    background: var(--primary-lighter) !important;
    color: var(--primary) !important;
}

.custom-dropdown .platform-chips .btn-check:checked + .btn::before {
    content: '\F26E'; /* bi-check-square-fill in Bootstrap Icons */
    color: var(--primary);
}
