/* Trang Thư Viện Xà Gồ Mái — Giao diện 3 Cột Cân Đối, Trực Quan & Tối Ưu Diện Tích */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #F4F6F9;
    font-family: var(--font-sans);
}

.main-container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0.5rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}

/* Header & Title Bar */
.purlin-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
    flex-shrink: 0;
}

.purlin-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.purlin-title-group h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0F172A;
    margin: 0;
}

.purlin-top-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filter Toolbar (1 hàng gọn gàng) */
.filter-section {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
}

.filter-item label {
    white-space: nowrap;
    color: #475569;
    font-weight: 600;
    font-size: 0.78rem;
}

.filter-item select, .filter-item input {
    padding: 0.25rem 0.45rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #FFFFFF;
    color: #1E293B;
    outline: none;
    transition: border-color 0.15s ease;
}

.filter-item select:focus, .filter-item input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.15);
}

/* Bảng Danh Sách Dự Án — Hiển thị 5–7 dự án thoáng đãng */
.purlin-main-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    flex: 0 0 auto;
    height: 220px;
    min-height: 170px;
    max-height: 245px;
    overflow-y: auto;
    overflow-x: auto;
    margin-bottom: 0.5rem;
    overscroll-behavior: contain;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.purlin-main-table-wrap table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

.purlin-main-table-wrap th {
    background: #F8FAFC;
    color: #334155;
    padding: 6px 10px;
    border-bottom: 1px solid #CBD5E1;
    border-right: 1px solid #E2E8F0;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
    white-space: nowrap;
    text-align: left;
}

.purlin-main-table-wrap th.num {
    text-align: right;
}

.purlin-main-table-wrap th.center {
    text-align: center;
}

.purlin-main-table-wrap td {
    padding: 6px 10px;
    border-bottom: 1px solid #F1F5F9;
    border-right: 1px solid #F8FAFC;
    white-space: nowrap;
    color: #1E293B;
}

.purlin-main-table-wrap td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.purlin-main-table-wrap td.center {
    text-align: center;
}

.purlin-main-table-wrap tbody tr {
    transition: background 0.1s ease;
}

.purlin-main-table-wrap tbody tr:hover {
    background: #F1F5F9;
    cursor: pointer;
}

.purlin-main-table-wrap tr.active {
    background: #E0F2FE !important;
    color: #0369A1 !important;
}

.purlin-main-table-wrap tr.active td {
    color: #0369A1 !important;
    font-weight: 500;
}

.purlin-main-table-wrap tr.active td strong {
    color: #0284C7;
}

/* 3-Column Split: Cột 1 (Thông số) | Cột 2 (Vật tư / Nối chồng) | Cột 3 (Sơ đồ SVG) */
.purlin-workspace-grid {
    display: grid;
    grid-template-columns: 310px 440px 1fr;
    gap: 0.65rem;
    flex: 1 1 auto;
    min-height: 290px;
    margin-bottom: 0.5rem;
}

@media (max-width: 1400px) {
    .purlin-workspace-grid {
        grid-template-columns: 290px 400px 1fr;
    }
}

@media (max-width: 1100px) {
    .purlin-workspace-grid {
        grid-template-columns: 1fr 1fr;
    }
    .live-plan-card {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .purlin-workspace-grid {
        grid-template-columns: 1fr;
    }
    .live-plan-card {
        grid-column: span 1;
    }
}

.detail-card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    margin-bottom: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.detail-card-header {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid #E2E8F0;
    padding-bottom: 0.3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.tab-detail-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.tab-bar {
    display: flex;
    gap: 4px;
}

.tab-btn {
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    padding: 3px 8px;
    font-size: 0.78rem;
    cursor: pointer;
    border-radius: 4px;
    color: #64748B;
    font-weight: 500;
    transition: all 0.15s ease;
}

.tab-btn:hover {
    background: #E2E8F0;
    color: #1E293B;
}

.tab-btn.active {
    background: #0D2B4E;
    border-color: #0D2B4E;
    color: #FFFFFF;
    font-weight: 600;
}

.tab-pane-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.tab-pane-scroll table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #F8FAFC;
}

/* Live Plan Container (Auto-stretches to fill entire right side) */
.live-plan-card {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.svg-plan-canvas-wrap {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 240px;
    background: #FFFFFF;
    border: 1px solid #F1F5F9;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.svg-plan-canvas-wrap svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Action Bar Bottom */
.action-bar-flex {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    flex-shrink: 0;
}

@media print {
    .no-print {
        display: none !important;
    }
    body {
        background: #FFFFFF;
    }
    .main-container {
        padding: 0;
    }
    .purlin-workspace-grid {
        display: block;
    }
    .purlin-main-table-wrap {
        height: auto;
        max-height: none;
    }
}
