/**
 * Progress Matrix - Compact Matrix View Styles
 * Phase 2 of COMPACT_MATRIX_VIEW_IMPLEMENTATION_PLAN.md
 * Created: 2026-01-07
 *
 * Provides dense table-like visualization for projects with 10+ floors
 * Based on tests/compact-matrix-demo.html
 */

/* ==========================================================================
   Matrix Container
   ========================================================================== */

.progress-matrix-matrix-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* Allow flex shrinking */
}

.matrix-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Wrapper for synchronized horizontal scrolling of headers + body */
.matrix-scroll-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: auto; /* Horizontal scroll here */
    overflow-y: hidden;
    min-height: 0;
}

.matrix-scroll-content {
    display: flex;
    flex-direction: column;
    min-width: max-content; /* Prevent shrinking */
}

/* ==========================================================================
   Dynamic Header (Breadcrumb Navigation)
   ========================================================================== */

.matrix-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.matrix-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.matrix-back-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.matrix-back-button:hover {
    background: rgba(255,255,255,0.25);
}

.matrix-back-button.hidden {
    display: none;
}

.matrix-breadcrumb {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.matrix-breadcrumb-dim {
    opacity: 0.7;
}

.matrix-breadcrumb-separator {
    color: rgba(255,255,255,0.5);
}

.matrix-level-indicator {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* ==========================================================================
   Legend
   ========================================================================== */

.matrix-legend {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
}

.matrix-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #64748b;
}

.matrix-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.matrix-legend-dot.completed { background: #10b981; }
.matrix-legend-dot.in-progress { background: #3b82f6; }
.matrix-legend-dot.delayed { background: #ef4444; }
.matrix-legend-dot.pending { background: #e2e8f0; }

/* ==========================================================================
   Column Headers
   ========================================================================== */

.matrix-column-headers {
    display: flex;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0; /* Don't shrink headers */
}

.matrix-floor-label-header {
    flex: 0 0 72px; /* 60px + 20% = 72px */
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    height: 40px;
    padding: 2px;
    font-size: 10px; /* Increased 1px */
    font-weight: 400; /* Not bold */
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-right: 2px solid #cbd5e1;
    position: sticky;
    left: 0;
    z-index: 12;
    box-sizing: border-box;
}

.matrix-col-header {
    flex: 0 0 84px; /* 70px + 20% = 84px */
    width: 84px;
    min-width: 84px;
    max-width: 84px;
    height: 40px;
    padding: 2px;
    font-size: 10px;
    font-weight: 500; /* Slightly bold */
    color: #374151;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1.2;
    border-right: 1px solid #e5e7eb;
    /* Force text wrapping */
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.matrix-col-header:hover {
    background: #f0f9ff;
    color: #0369a1;
}

/* Removed down arrow - was hard to read */

/* ==========================================================================
   Matrix Body
   ========================================================================== */

.matrix-body {
    flex: 1;
    overflow-y: auto; /* Vertical scroll only */
    overflow-x: visible; /* Horizontal scroll handled by wrapper */
    min-height: 0;
}

/* ==========================================================================
   Matrix Row
   ========================================================================== */

.matrix-row {
    display: flex;
    border-bottom: 1px solid #f1f5f9;
}

.matrix-row:hover {
    background: #fafafa;
}

/* ==========================================================================
   Floor Label Cell - Sticky for horizontal scroll
   ========================================================================== */

.matrix-floor-cell {
    flex: 0 0 72px; /* 60px + 20% = 72px - MUST match header */
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    height: 40px;
    padding: 2px;
    font-size: 12px; /* Match cell body */
    font-weight: 400; /* Not bold */
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-right: 2px solid #cbd5e1;
    position: sticky;
    left: 0;
    z-index: 5;
    box-sizing: border-box;
}

.matrix-floor-cell .floor-num {
    font-size: 12px; /* Match cell body */
    font-weight: 400; /* Not bold */
}

/* ==========================================================================
   Data Cell (50x50 size)
   ========================================================================== */

.matrix-cell {
    flex: 0 0 84px; /* 70px + 20% = 84px - MUST match header */
    width: 84px;
    min-width: 84px;
    max-width: 84px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border-right: 1px solid #f1f5f9;
    position: relative;
}

.matrix-cell:hover {
    transform: scale(1.1);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 6px;
}

/* Placeholder cell (no data for this floor/trade) */
.matrix-cell.placeholder {
    background: #fafafa;
    cursor: default;
}

.matrix-cell.placeholder:hover {
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   Status Colors
   ========================================================================== */

.matrix-cell.status-completed {
    background: #10b981;
    color: white;
}

.matrix-cell.status-in-progress {
    background: #3b82f6;
    color: white;
}

.matrix-cell.status-delayed {
    background: #ef4444;
    color: white;
}

.matrix-cell.status-pending {
    background: #f1f5f9;
    color: #94a3b8;
}

.matrix-cell.status-not-started {
    background: #f1f5f9;
    color: #94a3b8;
}

/* ==========================================================================
   Cell Content
   ========================================================================== */

/* Checkmark for 100% */
.matrix-cell .checkmark {
    font-size: 18px;
}

/* Duration text for Level 2 */
.matrix-cell .duration {
    font-size: 9px;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 2px;
}

/* Delayed icon */
.matrix-cell .delay-icon {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 10px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.matrix-footer {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #64748b;
}

.matrix-show-all-toggle {
    color: #3b82f6;
    cursor: pointer;
    font-weight: 500;
}

.matrix-show-all-toggle:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.matrix-empty {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
}

.matrix-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.matrix-empty-text {
    font-size: 14px;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.matrix-loading {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
}

.matrix-loading .loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: matrix-spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes matrix-spin {
    to { transform: rotate(360deg); }
}

.matrix-loading .loading-text {
    font-size: 14px;
}
