/**
 * tooltip.css - Hệ thống tooltip click-based
 *
 *   - .info-tip: icon "i" tròn xanh sau mỗi label (18-20px)
 *   - .tip-popup: popup hiện khi click icon (max-width 320px)
 *   - .tip-close: nút X góc popup
 *   - .help-panel: section "HƯỚNG DẪN CHI TIẾT" mở mặc định
 *   - @keyframes tipFadeIn: animation popup fade-in
 *
 * Hoạt động trên cả desktop (click chuột) và mobile (tap).
 */

/* Tooltip với info icon - CLICK để hiện/ẩn (mobile-friendly) */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 14px;
    height: 14px;
    min-width: 14px;
    background: #94a3b8;
    color: white;
    border-radius: 50%;
    font-size: 9.5px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1;
    margin-left: 5px;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(100,116,139,0.25);
    flex-shrink: 0;
    border: none;
    padding: 0;
    vertical-align: middle;
    text-align: center;
}

.info-tip:hover { background: #1a5f8e; transform: scale(1.1); }

.info-tip.active { background: #d97706; box-shadow: 0 2px 8px rgba(217,119,6,0.5); transform: scale(1.15); }

/* Popup hiển thị khi click */
.tip-popup { position: fixed; background: #1a2332; color: white; padding: 12px 16px 12px 16px; border-radius: 8px; font-size: 13px; line-height: 1.6; font-weight: 400; max-width: 320px; min-width: 220px; z-index: 9999; box-shadow: 0 8px 24px rgba(0,0,0,0.35); animation: tipFadeIn 0.15s ease-out; }

.tip-popup::before { content: ''; position: absolute; top: -6px; left: 20px; width: 12px; height: 12px; background: #1a2332; transform: rotate(45deg); }

.tip-popup .tip-close { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; background: rgba(255,255,255,0.15); color: white; border: none; border-radius: 50%; font-size: 16px; cursor: pointer; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center; }

.tip-popup .tip-close:hover { background: rgba(255,255,255,0.3); }

.tip-popup .tip-content { padding-right: 22px; white-space: pre-wrap; }

@keyframes tipFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* Section Giải thích thông số (collapsible) - thiết kế nổi bật để user dễ thấy */
details.help-panel { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border: 2px solid #f59e0b; border-radius: 10px; padding: 0; margin-bottom: 16px; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15); }

details.help-panel summary { cursor: pointer; padding: 14px 18px; font-weight: 700; color: #78350f; font-size: 15px; user-select: none; outline: none; list-style: none; display: flex; align-items: center; gap: 10px; background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%); border-radius: 8px 8px 0 0; }

details.help-panel summary:hover { background: linear-gradient(135deg, #fcd34d 0%, #fbbf24 100%); }

details.help-panel summary::-webkit-details-marker { display: none; }

details.help-panel summary::before { content: '▶'; font-size: 11px; transition: transform 0.2s; color: #b45309; }

details.help-panel[open] summary::before { transform: rotate(90deg); }

details.help-panel:not([open]) summary { border-radius: 8px; }

.help-panel-body { padding: 16px 20px; font-size: 13px; line-height: 1.6; color: #44403c; }

.help-panel-body h4 { color: #92400e; margin-top: 12px; margin-bottom: 6px; font-size: 13.5px; }

.help-panel-body h4:first-child { margin-top: 0; }

.help-panel-body dl { margin: 6px 0; }

.help-panel-body dt { font-weight: 600; color: #1a2332; margin-top: 8px; }

.help-panel-body dd { margin: 2px 0 6px 14px; color: #4a5568; }

.help-panel-body code { background: #fef3c7; padding: 1px 5px; border-radius: 3px; font-family: 'SF Mono', 'Cascadia Code', Consolas, Menlo, Monaco, 'Courier New', monospace; font-size: 12px; color: #92400e; }

.help-panel-body table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12.5px; }

.help-panel-body th, .help-panel-body td { border: 1px solid #fcd34d; padding: 5px 8px; text-align: left; }

.help-panel-body th { background: #fef3c7; font-weight: 600; }

/* Help cards — mỗi mục hướng dẫn là 1 thẻ riêng đóng/mở độc lập (v3.9.1) */
.help-cards-wrapper { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); border: 2px solid #f59e0b; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15); }

.help-cards-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 4px 6px 10px 6px; border-bottom: 1px dashed #f59e0b; margin-bottom: 10px; }

.help-cards-title { font-weight: 700; color: #78350f; font-size: 15px; }

.help-cards-actions button { background: white; border: 1px solid #f59e0b; color: #92400e; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; margin-left: 4px; }

.help-cards-actions button:hover { background: #fef3c7; }

.help-note { background: white; border-left: 3px solid #d97706; padding: 8px 12px; margin-bottom: 10px; border-radius: 4px; font-size: 13px; line-height: 1.5; color: #44403c; }

details.help-card { background: white; border: 1px solid #fcd34d; border-radius: 6px; margin-bottom: 6px; overflow: hidden; }

details.help-card summary { cursor: pointer; padding: 8px 12px; font-weight: 600; color: #78350f; font-size: 13.5px; user-select: none; outline: none; list-style: none; display: flex; align-items: center; gap: 8px; background: #fef9e7; }

details.help-card summary:hover { background: #fef3c7; }

details.help-card summary::-webkit-details-marker { display: none; }

details.help-card summary::before { content: '▶'; font-size: 10px; transition: transform 0.2s; color: #b45309; }

details.help-card[open] summary::before { transform: rotate(90deg); }

details.help-card[open] summary { border-bottom: 1px solid #fcd34d; }

.help-card-body { padding: 10px 14px; font-size: 13px; line-height: 1.6; color: #44403c; }

.help-card-body dl { margin: 4px 0; }
.help-card-body dt { font-weight: 600; color: #1a2332; margin-top: 6px; }
.help-card-body dt:first-child { margin-top: 0; }
.help-card-body dd { margin: 2px 0 6px 14px; color: #4a5568; }
.help-card-body code { background: #fef3c7; padding: 1px 5px; border-radius: 3px; font-family: 'SF Mono', 'Cascadia Code', Consolas, Menlo, Monaco, 'Courier New', monospace; font-size: 12px; color: #92400e; }
.help-card-body table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12.5px; }
.help-card-body th, .help-card-body td { border: 1px solid #fcd34d; padding: 5px 8px; text-align: left; }
.help-card-body th { background: #fef3c7; font-weight: 600; }

/* ============================================================
   STEP CARDS — Workflow 5 bước (v3.10)
   Tách biệt với help-card (màu vàng) bằng tone xanh dương đậm
   ============================================================ */

.step-cards-wrapper {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #0284c7;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 20px;
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.12);
}

.step-cards-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
    padding: 4px 6px 12px 6px;
    border-bottom: 2px dashed #0284c7;
    margin-bottom: 14px;
}

.step-cards-title {
    font-weight: 700;
    color: #0c4a6e;
    font-size: 16px;
}

.step-cards-actions button {
    background: white;
    border: 1px solid #0284c7;
    color: #0c4a6e;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    margin-left: 4px;
}

.step-cards-actions button:hover { background: #e0f2fe; }

details.step-card {
    background: white;
    border: 2px solid #7dd3fc;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.08);
}

details.step-card summary {
    cursor: pointer;
    padding: 12px 16px;
    font-weight: 700;
    color: #0c4a6e;
    font-size: 15px;
    user-select: none;
    outline: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

details.step-card summary:hover {
    background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
}

details.step-card summary::-webkit-details-marker { display: none; }

details.step-card summary::before {
    content: '▶';
    font-size: 12px;
    transition: transform 0.2s;
    color: #0284c7;
}

details.step-card[open] summary::before { transform: rotate(90deg); }

details.step-card[open] summary { border-bottom: 2px solid #7dd3fc; }

.step-card-body {
    padding: 16px 18px;
}

/* Số thứ tự bước trong summary */
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    background: #0284c7;
    color: white;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    margin-right: 4px;
}

/* Badge "Tùy chọn" / "Bắt buộc" / "Mới" */
.step-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.step-badge.required { background: #fee2e2; color: #991b1b; }
.step-badge.optional { background: #fef3c7; color: #92400e; }
.step-badge.new      { background: #dcfce7; color: #166534; }

/* Footer mỗi step card — chứa nút điều hướng */
.step-footer {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.step-footer .btn {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: all 0.15s;
}

.step-footer .btn-primary {
    background: #0284c7;
    color: white;
}

.step-footer .btn-primary:hover {
    background: #0369a1;
}

.step-footer .btn-secondary {
    background: white;
    color: #0c4a6e;
    border: 1px solid #7dd3fc;
}

.step-footer .btn-secondary:hover {
    background: #f0f9ff;
}

/* Subscript cho ký hiệu kỹ thuật */
sub {
    font-size: 0.75em;
    vertical-align: sub;
    line-height: 0;
}

/* Vùng kết quả inline trong step card */
.step-inline-result {
    margin-top: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #22c55e;
    border-left: 4px solid #16a34a;
    border-radius: 6px;
    font-size: 13.5px;
}

.step-inline-result.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    border-left-color: #d97706;
}

.step-inline-result.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
    border-left-color: #dc2626;
}

.step-inline-result h4 {
    margin: 0 0 8px 0;
    color: #14532d;
    font-size: 14px;
}

.step-inline-result.warning h4 { color: #78350f; }
.step-inline-result.error h4 { color: #7f1d1d; }

.step-inline-result table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
    font-size: 13px;
}

.step-inline-result td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* Note ghi chú giữa các step */
.step-note {
    background: #f8fafc;
    border-left: 3px solid #94a3b8;
    padding: 8px 12px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 12.5px;
    color: #475569;
    line-height: 1.5;
}

/* Phase 3 (v3.10): Auto-filled field từ Thẻ 2 sang Thẻ 4 */
input[data-auto-filled="1"] {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-color: #86efac;
    transition: background 0.3s, border-color 0.3s;
}
input[data-manual-edit="1"] {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fcd34d;
}

/* v3.10: Catalog dây chống sét table */
.catalog-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.catalog-filter select {
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 13px;
    background: white;
}
.catalog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: white;
    border: 1px solid #e2e8f0;
}
.catalog-table thead th {
    background: #1e3a8a;
    color: white;
    padding: 6px 5px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #1e3a8a;
    line-height: 1.2;
}
.catalog-table tbody td {
    padding: 5px 6px;
    border: 1px solid #e2e8f0;
    text-align: center;
}
.catalog-table tbody tr:nth-child(even) td {
    background: #f8fafc;
}
.catalog-table tbody tr:hover td {
    background: #fef3c7;
}
.catalog-table .catalog-mat-row td {
    background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%) !important;
    color: #1e3a8a;
    font-size: 13px;
    padding: 6px 8px;
    text-align: left;
    border-top: 2px solid #93c5fd;
}

/* v3.10: Locked fields khi chọn từ catalog (Thẻ 2) */
input.catalog-locked, select.catalog-locked {
    background: #f1f5f9 !important;
    color: #475569 !important;
    cursor: not-allowed !important;
    border-color: #cbd5e1 !important;
    opacity: 0.85;
}
input.catalog-locked:focus, select.catalog-locked:focus {
    outline: none;
    box-shadow: none;
}
.catalog-lock-hint {
    font-size: 11px;
    color: #0c7d3e;
    font-weight: 600;
    margin-left: 4px;
}

/* v3.10: TAB NAVIGATION (3 tab ngang) */
.tab-nav {
    display: flex;
    gap: 4px;
    margin: 16px 0 0 0;
    border-bottom: 3px solid #1e3a8a;
    padding: 0 4px;
}
.tab-btn {
    padding: 12px 22px;
    background: #e2e8f0;
    color: #475569;
    border: none;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 14.5px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    border-bottom: none;
    margin-bottom: -3px;
}
.tab-btn:hover:not(.active) {
    background: #cbd5e1;
    color: #1e293b;
}
.tab-btn.active {
    background: #1e3a8a;
    color: white;
    border-color: #1e3a8a;
    box-shadow: 0 -2px 8px rgba(30, 58, 138, 0.25);
}
.tab-panel {
    display: none;
    animation: tabFadeIn 0.25s ease-in;
}
.tab-panel.active {
    display: block;
}
@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Catalog tab wrapper (khi catalog ở tab riêng) */
.catalog-tab-wrapper {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 22px;
    margin-top: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.catalog-tab-wrapper h2 {
    font-size: 18px;
    border-bottom: 2px solid #1e3a8a;
    padding-bottom: 8px;
}

/* v3.10: Project actions (Save/Load/Reset) */
.project-actions {
    float: right;
    display: flex;
    gap: 6px;
    margin-top: -2px;
}
.btn-mini {
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.btn-save {
    background: #ecfdf5;
    color: #065f46;
    border-color: #6ee7b7;
}
.btn-save:hover { background: #d1fae5; }
.btn-load {
    background: #eff6ff;
    color: #1e40af;
    border-color: #93c5fd;
}
.btn-load:hover { background: #dbeafe; }
.btn-reset {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fca5a5;
}
.btn-reset:hover { background: #fee2e2; }

/* v3.10 Phase 5: Bảng so sánh P2 vs P4 vs MAX */
.comparison-wrap { overflow-x: auto; margin: 8px 0; }
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
}
.comparison-table th, .comparison-table td {
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    text-align: center;
}
.comparison-table thead th {
    background: #1e3a8a;
    color: white;
    font-weight: 600;
}
.comparison-table thead th.p2-col { background: #475569; }
.comparison-table thead th.p4-col { background: #0c7d3e; }
.comparison-table thead th.max-col { background: #b45309; font-size: 13px; }
.comparison-table tbody td.max-cell {
    background: #fef3c7;
    color: #78350f;
    font-weight: 700;
    border-left: 2px solid #f59e0b;
}
.comparison-table tbody tr:hover td { background: #f8fafc; }
.comparison-table tbody tr:hover td.max-cell { background: #fde68a; }

/* v3.10: Modal Thư viện dự án */
.project-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    animation: modalFadeIn 0.2s;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.project-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.project-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 920px;
    width: 92%;
    max-height: 86vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.project-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
}
.project-modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-close {
    background: rgba(255,255,255,0.2); color: white; border: none;
    width: 32px; height: 32px; border-radius: 6px;
    font-size: 22px; line-height: 1; cursor: pointer;
    transition: background 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.35); }
.project-modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    flex: 1;
}
.library-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.library-table thead th {
    background: #f1f5f9; color: #1e293b;
    padding: 8px 10px; text-align: left;
    border-bottom: 2px solid #cbd5e1;
    font-weight: 600;
}
.library-table tbody td {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}
.library-table tbody tr:hover { background: #f8fafc; }
.lib-btn {
    padding: 5px 10px;
    font-size: 12px; font-weight: 600;
    border: 1px solid;
    border-radius: 4px;
    cursor: pointer;
    background: white;
    margin: 0 1px;
}
.lib-load { color: #1e40af; border-color: #93c5fd; }
.lib-load:hover { background: #dbeafe; }
.lib-export { color: #065f46; border-color: #6ee7b7; }
.lib-export:hover { background: #d1fae5; }
.lib-delete { color: #991b1b; border-color: #fca5a5; }
.lib-delete:hover { background: #fee2e2; }
.btn-library {
    background: #fef3c7;
    color: #78350f;
    border-color: #fcd34d;
}
.btn-library:hover { background: #fde68a; }
