:root {
    /* Tông màu Trắng Hiện Đại */
    --brand-color: #0284c7; /* Xanh dương đậm để dễ đọc và nổi bật trên nền trắng */
    --brand-dark: #0369a1;
    --bg-main: #ffffff; /* Nền trắng */
    --bg-panel: #ffffff; 
    --text-main: #0f172a; /* Chữ màu đen/xám đậm */
    --text-muted: #475569; /* Chữ xám nhạt cho Sapo */
    --border-color: #e2e8f0;
    
    /* Màu phân loại nhà máy */
    --color-high-cap: #ef4444; /* Đỏ */
    --color-planned: #22c55e; /* Xanh lá cây */
}

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100vh;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
}

h1, h2, h3, .serif { font-family: 'Lora', serif; }

/* ----- INTRO SCREEN ----- */
#intro-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-main);
    /* Overlay Trắng Sáng */
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.98)), url('https://images.unsplash.com/photo-1617788138017-80ad40651399?q=80&w=2070&auto=format&fit=crop');
    background-size: cover; background-position: center;
    z-index: 100;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 2rem; transition: opacity 0.6s ease, visibility 0.6s;
}
#intro-screen.hidden { opacity: 0; visibility: hidden; }
.intro-title {
    font-size: clamp(1.8rem, 3.5vw, 3rem); color: var(--brand-color); text-align: center;
    margin-bottom: 2rem; max-width: 900px; line-height: 1.3; font-weight: 700;
}
.intro-sapo {
    font-size: 1.1rem; line-height: 1.8; max-width: 800px;
    text-align: center; color: var(--text-muted); margin-bottom: 2.5rem; font-weight: 400;
}
.stats-grid {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem; margin-bottom: 3rem;
}
.stat-box {
    background: #ffffff; border: 1px solid var(--border-color);
    padding: 1.5rem 2rem; border-radius: 8px; text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}
.stat-num {
    display: block; font-size: 2.5rem; color: var(--brand-color);
    font-family: 'Lora', serif; font-weight: 600; margin-bottom: 0.5rem;
}
.stat-text { font-size: 0.9rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.btn-start {
    padding: 1rem 3rem; font-size: 1.1rem; background-color: var(--brand-color);
    color: #fff; border: none; border-radius: 4px; cursor: pointer;
    font-weight: 600; transition: all 0.3s; text-transform: uppercase;
}
.btn-start:hover { background-color: var(--brand-dark); transform: translateY(-2px); box-shadow: 0 10px 20px rgba(2, 132, 199, 0.2); }

/* ----- MAIN APP CONTAINER ----- */
#app-container { display: flex; height: calc(100vh - 80px); width: 100%; }

/* LEFT PANEL: INFO */
#info-panel {
    width: 48%; height: 100%; background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color); display: flex; flex-direction: column; overflow-y: auto;
}
#info-panel::-webkit-scrollbar { width: 6px; }
#info-panel::-webkit-scrollbar-track { background: #f8fafc; }
#info-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.factory-img {
    width: 100%; height: 300px; object-fit: cover;
    border-bottom: 3px solid var(--brand-color); transition: opacity 0.3s;
}
.info-content { padding: 2rem; opacity: 1; transition: opacity 0.3s; }
.info-content.fade { opacity: 0; }
.factory-title { color: var(--brand-color); font-size: 1.8rem; margin-bottom: 0.5rem; line-height: 1.4; font-weight: 700; }
.factory-meta {
    display: inline-block; font-size: 0.85rem; color: var(--brand-dark);
    background: #f0f9ff; border: 1px solid #bae6fd;
    padding: 4px 12px; border-radius: 20px; margin-bottom: 1.5rem; font-weight: 500;
}
.factory-text { font-size: 1.05rem; line-height: 1.8; color: var(--text-main); }
.factory-text p { margin-bottom: 0.8rem; }
.factory-text strong { color: #000; font-weight: 600; }

/* RIGHT PANEL: D3 GEOGRAPHIC MAP */
#map-panel {
    width: 52%; height: 100%; background-color: #f8fafc;
    position: relative; overflow: hidden;
}

#map-loading {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: var(--brand-color); font-weight: 500; font-size: 1.2rem;
}

/* SVG Map Styling */
svg { width: 100%; height: 100%; filter: drop-shadow(0 0 10px rgba(0,0,0,0.05)); }

.province { fill: #e2e8f0; stroke: #ffffff; stroke-width: 0.8px; transition: fill 0.3s; }
.province:hover { fill: #cbd5e1; }

.island-label { fill: #64748b; font-size: 12px; font-family: Roboto; font-weight: 500; pointer-events: none; }
.island-dot { fill: #94a3b8; stroke: none; }

.factory-dot {
    stroke: #fff; cursor: pointer; transition: fill 0.3s;
}

/* Tooltip bản đồ */
#map-tooltip {
    position: absolute; background: rgba(255, 255, 255, 0.95); border: 1px solid var(--brand-color);
    color: var(--text-main); padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; font-weight: 600;
    pointer-events: none; opacity: 0; transition: opacity 0.2s; z-index: 50;
    white-space: nowrap; transform: translate(-50%, -150%); box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Chú giải (Legend) */
#map-legend {
    position: absolute; bottom: 20px; right: 20px;
    background: rgba(255, 255, 255, 0.9); border: 1px solid var(--border-color);
    padding: 15px; border-radius: 8px; z-index: 40; backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.legend-item { display: flex; align-items: center; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-main); font-weight: 500;}
.legend-item:last-child { margin-bottom: 0; }
.legend-color { width: 12px; height: 12px; border-radius: 50%; margin-right: 10px; border: 1px solid #e2e8f0; }

/* BOTTOM PANEL: TIMELINE */
#timeline-container {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 80px;
    background-color: var(--bg-panel); border-top: 1px solid var(--border-color);
    display: flex; align-items: center; padding: 0 1rem; overflow-x: auto; white-space: nowrap;
}
#timeline-container::-webkit-scrollbar { height: 4px; }
#timeline-container::-webkit-scrollbar-track { background: #f8fafc; }
#timeline-container::-webkit-scrollbar-thumb { background: #cbd5e1; }

.timeline-btn {
    background: transparent; color: var(--text-muted); border: 1px solid var(--border-color);
    padding: 8px 16px; margin-right: 10px; border-radius: 20px;
    cursor: pointer; font-size: 0.9rem; transition: all 0.2s; font-weight: 500;
}
.timeline-btn:hover { border-color: var(--brand-color); color: var(--brand-color); }
.timeline-btn.active {
    background: var(--brand-color); color: #fff; border-color: var(--brand-color); font-weight: bold;
}

/* Nút Quay lại trang chủ */
#btn-home {
    position: absolute; top: 20px; right: 20px; z-index: 50;
    background: rgba(255, 255, 255, 0.95); border: 1px solid var(--brand-color);
    color: var(--brand-color); padding: 6px 12px; border-radius: 20px;
    cursor: pointer; font-size: 0.8rem; font-weight: 600;
    display: flex; align-items: center; gap: 6px; transition: all 0.3s;
    backdrop-filter: blur(5px); box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
#btn-home:hover {
    background: var(--brand-color); color: #fff;
}

@media (max-width: 900px) {
    #app-container { flex-direction: column-reverse; }
    #info-panel { width: 100%; height: 50%; border-right: none; border-top: 1px solid var(--brand-color); }
    .factory-img { height: 180px; }
    #map-panel { width: 100%; height: 50%; }
    #map-legend { bottom: 10px; right: 10px; padding: 10px; font-size: 0.8rem; }
}