/* =============================================================================
   DIAGRAMS.CSS - Interaction Diagram Visualization
   =============================================================================
   Contains: Pillar Grid, SVG Interaction Lines, Legend Chips, Table Layout,
             Layer Styles, Hover Effects, Animations
   ============================================================================= */

/* =============================================================================
   VISUAL INTERACTION DIAGRAM - Pillar Interactions Visualization
   ============================================================================= */

.interaction-diagram-section {
    background: linear-gradient(135deg, rgba(19, 19, 26, 0.95), rgba(26, 10, 31, 0.95));
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.interaction-diagram-section h4 {
    color: var(--accent-gold);
    font-family: var(--font-heading);
    margin-bottom: 15px;
    text-align: center;
}

/* Diagram Container */
.interaction-diagram {
    position: relative;
    overflow-x: auto;
    padding: 20px 10px;
}

/* Pillar Grid */
.pillar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    min-width: 600px;
    margin-bottom: 20px;
}

/* Individual Pillar Column */
.pillar-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(19, 19, 26, 0.8);
    border-radius: 8px;
    padding: 10px 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pillar-column.pillar-year {
    border-top: 3px solid #9C27B0;
}

.pillar-column.pillar-month {
    border-top: 3px solid #3F51B5;
}

.pillar-column.pillar-day {
    border-top: 3px solid #FF9800;
}

.pillar-column.pillar-hour {
    border-top: 3px solid #009688;
}

.pillar-column.pillar-luck {
    border-top: 3px solid #E91E63;
}

.pillar-column.pillar-year-luck {
    border-top: 3px solid #00BCD4;
}

.pillar-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: bold;
}

/* Can/Chi Cells */
.pillar-can,
.pillar-chi {
    width: 100%;
    text-align: center;
    padding: 8px 4px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    margin: 2px 0;
}

.pillar-can {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.pillar-chi {
    background: rgba(33, 150, 243, 0.15);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* SVG Container for Lines */
.interaction-svg-container {
    position: relative;
    width: 100%;
    min-height: 150px;
}

.interaction-svg {
    width: 100%;
    height: 150px;
}

/* Interaction Lines - Different styles for different types */
.interaction-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

/* HỢP - Green solid with circles */
.line-hop {
    stroke: #4CAF50;
    stroke-dasharray: none;
}

/* XUNG - Red dashed */
.line-xung {
    stroke: #F44336;
    stroke-dasharray: 8, 4;
}

/* HÌNH - Orange dotted */
.line-hinh {
    stroke: #FF9800;
    stroke-dasharray: 4, 4;
}

/* HẠI - Purple dashed */
.line-hai {
    stroke: #9C27B0;
    stroke-dasharray: 6, 3;
}

/* PHÁ - Brown dot-dash */
.line-pha {
    stroke: #795548;
    stroke-dasharray: 10, 3, 3, 3;
}

/* BÁN TAM HỢP - Blue long dash */
.line-ban-hop {
    stroke: #2196F3;
    stroke-dasharray: 12, 6;
}

/* TAM HỘI / TAM HỢP - Gold thick solid */
.line-tam-hoi,
.line-tam-hop {
    stroke: var(--accent-gold);
    stroke-width: 3;
}

/* Endpoints */
.endpoint-circle {
    fill: currentColor;
    r: 5;
}

.endpoint-x {
    stroke: currentColor;
    stroke-width: 2;
}

/* Legend */
.interaction-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-line {
    width: 30px;
    height: 3px;
    border-radius: 2px;
}

.legend-hop {
    background: #4CAF50;
}

.legend-xung {
    background: repeating-linear-gradient(90deg, #F44336 0, #F44336 8px, transparent 8px, transparent 12px);
}

.legend-hinh {
    background: repeating-linear-gradient(90deg, #FF9800 0, #FF9800 4px, transparent 4px, transparent 8px);
}

.legend-hai {
    background: repeating-linear-gradient(90deg, #9C27B0 0, #9C27B0 6px, transparent 6px, transparent 9px);
}

.legend-pha {
    background: #795548;
}

.legend-ban-hop {
    background: repeating-linear-gradient(90deg, #2196F3 0, #2196F3 12px, transparent 12px, transparent 18px);
}

/* ===== COMPACT LEGEND ===== */
.interaction-legend-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    padding: 8px;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.legend-chip.legend-can-hop {
    background: linear-gradient(135deg, #FFD700 0%, #FFA000 100%);
}

.legend-chip.legend-hop {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
}

.legend-chip.legend-xung {
    background: linear-gradient(135deg, #F44336 0%, #C62828 100%);
}

.legend-chip.legend-hai {
    background: linear-gradient(135deg, #9C27B0 0%, #6A1B9A 100%);
}

.legend-chip.legend-hinh {
    background: linear-gradient(135deg, #FF9800 0%, #E65100 100%);
}

.legend-chip.legend-ban-hop {
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
}

.legend-chip.legend-can-khac {
    background: linear-gradient(135deg, #FF5722 0%, #E64A19 100%);
}

.legend-chip.legend-can-sinh {
    background: linear-gradient(135deg, #00BCD4 0%, #0097A7 100%);
}

.legend-chip.legend-pha {
    background: linear-gradient(135deg, #795548 0%, #5D4037 100%);
}

.legend-chip.legend-am-hop {
    background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
}

.legend-chip.legend-tam-hop {
    background: linear-gradient(135deg, #3F51B5 0%, #303F9F 100%);
}

.legend-chip.legend-tam-hoi {
    background: linear-gradient(135deg, #8BC34A 0%, #689F38 100%);
}

/* ===== INTEGRATED TABLE LAYOUT ===== */
.interaction-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--card-bg, #1a1a2e);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.interaction-table th,
.interaction-table td {
    width: 25%;
    text-align: center;
    vertical-align: middle;
}

.pillar-header {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary, #888);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pillar-cell {
    padding: 12px 8px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 6px;
    margin: 4px;
}

.pillar-cell.pillar-can {
    background: rgba(255, 193, 7, 0.1);
}

.pillar-cell.pillar-chi {
    background: rgba(100, 200, 150, 0.1);
}

/* Header row styling */
.header-row th {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary, #aaa);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px;
}

.svg-zone-row {
    background: transparent;
}

.svg-zone-cell {
    padding: 10px 0;
    position: relative;
}

/* Zone at TOP (above pillars) */
.svg-zone-top {
    background: linear-gradient(180deg,
            rgba(255, 193, 7, 0.05) 0%,
            rgba(255, 193, 7, 0.02) 100%);
    border-bottom: 1px solid rgba(255, 193, 7, 0.15);
    border-radius: 12px 12px 0 0;
}

/* Zone at BOTTOM (below pillars) */
.svg-zone-bottom {
    background: linear-gradient(0deg,
            rgba(100, 200, 150, 0.05) 0%,
            rgba(100, 200, 150, 0.02) 100%);
    border-top: 1px solid rgba(100, 200, 150, 0.15);
    border-radius: 0 0 12px 12px;
}

.can-zone-row .svg-zone-cell {
    background: linear-gradient(180deg,
            rgba(255, 193, 7, 0.03) 0%,
            transparent 100%);
    border-bottom: 1px dashed rgba(255, 193, 7, 0.2);
}

.chi-zone-row .svg-zone-cell {
    background: linear-gradient(0deg,
            rgba(100, 200, 150, 0.03) 0%,
            transparent 100%);
}

.zone-label-inline {
    font-size: 0.7rem;
    color: var(--text-secondary, #888);
    text-align: left;
    padding: 0 12px 4px;
    opacity: 0.8;
    font-weight: 500;
}

.interaction-svg-inline {
    width: 100%;
    display: block;
    min-height: 40px;
}

.no-interaction-msg {
    text-align: center;
    color: var(--text-secondary, #888);
    font-size: 0.8rem;
    padding: 8px;
    opacity: 0.6;
    font-style: italic;
}

/* SVG Interaction Labels */
.interaction-label {
    font-weight: 600;
    font-size: 10px;
    pointer-events: none;
}

.label-hop {
    fill: #4CAF50;
}

.label-xung {
    fill: #F44336;
}

.label-hinh {
    fill: #FF9800;
}

.label-hai {
    fill: #9C27B0;
}

.label-pha {
    fill: #795548;
}

.label-ban-hop {
    fill: #2196F3;
}

/* SVG Endpoint Circles */
.endpoint-hop {
    fill: #4CAF50;
}

.endpoint-xung {
    fill: #F44336;
}

.endpoint-hinh {
    fill: #FF9800;
}

.endpoint-hai {
    fill: #9C27B0;
}

.endpoint-pha {
    fill: #795548;
}

.endpoint-ban-hop {
    fill: #2196F3;
}

/* SVG Container min-height override */
.interaction-svg-container {
    min-height: 60px;
    position: relative;
}

.interaction-svg {
    width: 100%;
    min-height: 60px;
}

/* Zone styles */
.svg-zone-can {
    background: rgba(var(--accent-gold-rgb, 255, 193, 7), 0.05);
    border-radius: 8px 8px 0 0;
    padding: 8px 0;
    margin-bottom: 4px;
}

.svg-zone-chi {
    background: rgba(var(--accent-rgb, 100, 150, 200), 0.02);
    border-radius: 0 0 8px 8px;
    padding: 8px 0;
}

.zone-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: left;
    padding-left: 12px;
    margin-bottom: 4px;
    opacity: 0.95;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* CAN HỢP - Gold/Amber solid line */
.line-can-hop {
    stroke: var(--accent-gold, #FFC107);
    stroke-width: 2.5;
    stroke-dasharray: none;
}

.label-can-hop {
    fill: var(--accent-gold, #FFC107);
    font-weight: 700;
}

.endpoint-can-hop {
    fill: var(--accent-gold, #FFC107);
}

/* Legend for Can Hợp */
.legend-can-hop {
    background: linear-gradient(90deg, var(--accent-gold, #FFC107) 0%, var(--accent-gold, #FFC107) 100%);
}

/* Tooltip hover effect on paths */
.interaction-line:hover {
    stroke-width: 4;
    cursor: pointer;
    opacity: 0.9;
}

/* Native SVG title tooltip enhancement */
.interaction-svg path title {
    font-size: 12px;
}

/* ===== INTERACTION DIAGRAM UPGRADE (UI/UX) ===== */

/* 1. Glassmorphism for Pillar Cells */
.pillar-cell {
    position: relative;
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: default;
    overflow: visible;
    z-index: 1;
}

.pillar-cell:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Specific colors per pillar type with glass effect */
.pillar-cell.pillar-can {
    border-left: 3px solid #FFD700;
}

.pillar-cell.pillar-chi {
    border-left: 3px solid #4CAF50;
}

/* 2. Focused & Dimmed States (For Hover Logic) */
.pillar-cell.focused {
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.pillar-cell.dimmed {
    opacity: 0.3;
    filter: grayscale(0.5);
}

/* SVG Line Interactions */
svg path {
    transition: all 0.3s ease;
    stroke-linecap: round;
}

svg path.focused {
    filter: drop-shadow(0 0 6px currentColor);
    z-index: 10;
}

svg path.dimmed {
    opacity: 0.1;
    filter: grayscale(1);
}

/* 3. Animation for Strong Interactions (Tam Hop/Tam Hoi) */
@keyframes flow {
    0% {
        stroke-dashoffset: 20;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

.interaction-strong {
    animation: flow 2s linear infinite;
}

/* 4. Legend Styling Upgrade */
.interaction-legend-compact {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* =============================================================================
   LAYERED SVG DIAGRAM STYLES (Redesigned)
   ============================================================================= */

/* Layered SVG container */
.interaction-svg-layered {
    width: 100%;
    min-height: 50px;
    display: block;
}

/* Layer-specific styles */
.layer-nc {
    opacity: 0.85;
    transition: all 0.25s ease;
}

.layer-dv {
    opacity: 0.95;
    transition: all 0.25s ease;
}

/* Hover effects for layered lines */
.layer-nc:hover {
    stroke-width: 3 !important;
    opacity: 1;
    filter: drop-shadow(0 0 4px currentColor);
}

.layer-dv:hover {
    stroke-width: 4 !important;
    opacity: 1;
    filter: drop-shadow(0 0 6px currentColor);
}

/* 5-column table layout */
.interaction-table-5col th,
.interaction-table-5col td {
    width: 20%;
}

/* ĐV column highlight */
.pillar-dv {
    background: rgba(233, 30, 99, 0.15) !important;
    border: 1px solid rgba(233, 30, 99, 0.3);
}

.pillar-dv.pillar-header {
    color: #E91E63 !important;
    font-weight: 700;
}

/* TT column highlight (for Niên Vận) */
.pillar-tt {
    background: rgba(0, 188, 212, 0.15) !important;
    border: 1px solid rgba(0, 188, 212, 0.3);
}

.pillar-tt.pillar-header {
    color: #00BCD4 !important;
    font-weight: 700;
}

/* Layer legend styling */
.layer-legend {
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    display: inline-block;
}

/* SVG zone row backgrounds */
.svg-zone-row.svg-zone-can td {
    background: linear-gradient(180deg,
            rgba(255, 215, 0, 0.08) 0%,
            rgba(255, 215, 0, 0.02) 100%);
    border-bottom: 1px solid rgba(255, 215, 0, 0.15);
}

.svg-zone-row.svg-zone-chi td {
    background: linear-gradient(0deg,
            rgba(76, 175, 80, 0.08) 0%,
            rgba(76, 175, 80, 0.02) 100%);
    border-top: 1px solid rgba(76, 175, 80, 0.15);
}