* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

main {
    padding: 2rem 0;
    flex: 1;
}

/* =========================================
   TỐI ƯU THANH TRƯỢT (SCROLLBAR) MAC-STYLE
   ========================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1; 
    border-radius: 8px;
}
::-webkit-scrollbar-thumb {
    background: #bdc3c7; 
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
    background: #95a5a6; 
}

/* =========================================
   HEADER & ĐIỀU HƯỚNG
   ========================================= */
header {
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #2c3e50;
    font-size: 1.8rem;
}

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-menu a {
    text-decoration: none;
    color: #555;
    font-weight: 600;
    transition: color 0.3s;
}
.nav-menu a:hover { color: #3498db; }

/* =========================================
   HỆ THỐNG NÚT BẤM (CÓ KHIÊN BẢO VỆ QUILL)
   ========================================= */
button:not(.ql-toolbar button) {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
button:not(.ql-toolbar button):hover {
    background-color: #2980b9;
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.25);
    transform: translateY(-2px);
}
button:not(.ql-toolbar button):disabled { 
    background-color: #95a5a6; 
    cursor: not-allowed; 
    box-shadow: none; 
    transform: none; 
}

.btn-primary-sm {
    background: linear-gradient(135deg, #3498db, #2980b9);
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}
.btn-primary-sm:hover { 
    background: linear-gradient(135deg, #2980b9, #1f6391); 
}

/* =========================================
   BANNER TRANG CHỦ
   ========================================= */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, #3498db, #2c3e50);
    color: white;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.hero h2 { font-size: 2.5rem; margin-bottom: 1rem; }

/* =========================================
   BỘ LỌC CHUYÊN MỤC
   ========================================= */
.filter-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.search-box input {
    width: 100%; padding: 0.8rem 1rem; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem;
}
.category-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.category-tag {
    background: #f1f2f6; border: none; padding: 8px 18px; border-radius: 20px;
    cursor: pointer; font-weight: 600; color: #57606f; transition: all 0.2s;
    box-shadow: none; transform: none;
}
.category-tag.active, .category-tag:hover { 
    background: #3498db; color: white; box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.cat-badge {
    background-color: #e1f5fe; color: #0288d1; font-size: 0.75rem;
    font-weight: bold; padding: 4px 12px; border-radius: 12px; text-transform: uppercase;
}

/* =========================================
   TÌM KIẾM PHÒNG GIAO DỊCH (PGD)
   ========================================= */
.pgd-section { background: white; padding: 2.5rem; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); margin-bottom: 3rem; border-top: 4px solid #3498db; }
.pgd-header { text-align: center; margin-bottom: 2rem; }
.pgd-header h3 { color: #2c3e50; font-size: 1.6rem; margin-bottom: 0.5rem; }
.pgd-header p { color: #7f8c8d; font-size: 1rem; }

.pgd-search-wrapper { display: flex; align-items: center; gap: 15px; background: #f8f9fa; padding: 12px; border-radius: 50px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
.pgd-input-group { flex: 1; display: flex; align-items: center; background: white; border-radius: 50px; padding: 8px 8px 8px 25px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.pgd-icon { font-size: 1.4rem; color: #95a5a6; margin-right: 12px; }
.pgd-input-group input { flex: 1; border: none; outline: none; font-size: 1.15rem; background: transparent; padding: 12px 0; line-height: 1.5; }

.btn-search {
    background: linear-gradient(135deg, #3498db, #2980b9);
    padding: 14px 30px;
    border-radius: 40px;
    font-size: 1.05rem;
}
.btn-search:hover { background: linear-gradient(135deg, #2980b9, #1f6391); }

.pgd-divider { color: #95a5a6; font-weight: bold; font-size: 0.9rem; }
.btn-gps { 
    display: flex; align-items: center; gap: 8px; 
    background-color: white; color: #2c3e50; 
    border: 2px solid #ddd; padding: 14px 25px; 
    border-radius: 40px; box-shadow: none; 
    font-size: 1.05rem;
}
.btn-gps:hover { border-color: #2c3e50; background-color: #f8f9fa; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }

.pgd-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.pgd-location-card { 
    position: relative;
    background: white; border: 1px solid #eee; padding: 20px; border-radius: 12px; 
    transition: all 0.3s; box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}
.pgd-location-card:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.08); transform: translateY(-4px); border-color: #3498db; }

/* Popup Bản đồ PGD */
.pgd-route-popup {
    position: absolute; bottom: 105%; left: 50%; transform: translateX(-50%) translateY(10px);
    width: 280px; background: white; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    padding: 10px; opacity: 0; pointer-events: none; transition: all 0.3s ease-in-out; z-index: 999; border: 1px solid #eee;
}
.pgd-popup-title { font-size: 0.85rem; font-weight: bold; color: #2c3e50; margin-top: 6px; text-align: center; }
.pgd-location-card:hover .pgd-route-popup { opacity: 1; transform: translateX(-50%) translateY(0); }

.distance-badge { color: white; font-size: 0.8rem; font-weight: bold; padding: 4px 10px; border-radius: 20px; height: fit-content; }
.pgd-navigate-link { display: inline-block; margin-top: 10px; color: #3498db; text-decoration: none; font-size: 0.95rem; font-weight: bold; padding: 8px 15px; background: #e1f5fe; border-radius: 8px; transition: background 0.3s; }
.pgd-navigate-link:hover { background: #b3e5fc; }

/* =========================================
   FORM ĐĂNG BÀI & CẬP NHẬT
   ========================================= */
.upload-section { background: white; padding: 2rem; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); margin-bottom: 3rem; }
.upload-section h3 { margin-bottom: 1.5rem; color: #2c3e50; border-bottom: 2px solid #3498db; display: inline-block; padding-bottom: 0.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: #34495e; }
.form-group input, .form-group textarea, .form-group select { 
    width: 100%; padding: 0.9rem; border: 1px solid #ddd; border-radius: 8px; font-family: inherit; font-size: 1rem; transition: border-color 0.3s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: #3498db; box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1); }

/* =========================================
   TỐI ƯU BỘ SOẠN THẢO QUILL EDITOR
   ========================================= */
.ql-toolbar.ql-snow {
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    border-color: #ddd !important;
}

.ql-container.ql-snow {
    border-radius: 0 0 8px 8px;
    border-color: #ddd !important;
    font-family: inherit !important;
    font-size: 1.05rem !important;
    background-color: white;
}
.ql-editor {
    min-height: 200px;
    max-height: 350px !important;
    overflow-y: auto !important;
}
.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 15px auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* SỬA LỖI XUNG ĐỘT IFRAME: Chỉ áp dụng cho video ở bài viết đọc, KHÔNG đụng đến nút Toolbar */
.ql-editor iframe.ql-video,
.single-post-content iframe.ql-video {
    width: 100%;
    min-height: 400px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: none;
}

/* =========================================
   MODAL ĐĂNG NHẬP / ĐĂNG KÝ
   ========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 1000; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; backdrop-filter: blur(3px); }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-content { 
    background-color: #fff; 
    padding: 2.5rem 2rem; 
    border-radius: 16px; 
    width: 100%; 
    max-width: 450px; 
    position: relative; 
    box-shadow: 0 15px 30px rgba(0,0,0,0.2); 
    max-height: 95vh;
    overflow-y: auto; 
}
.modal-close-token { position: absolute; top: 12px; right: 18px; font-size: 1.8rem; font-weight: bold; color: #95a5a6; cursor: pointer; transition: color 0.3s; z-index: 10; }
.modal-close-token:hover { color: #e74c3c; }

.auth-tabs { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 2px solid #eee; padding-bottom: 10px; }
.tab-btn { background-color: transparent; color: #95a5a6; padding: 10px 20px; box-shadow: none; font-size: 1.05rem; }
.tab-btn:hover { background-color: #f1f2f6; transform: none; box-shadow: none; color: #34495e; }
.tab-btn.active { background-color: transparent; color: #3498db; border-bottom: 3px solid #3498db; border-radius: 0; }

#loginForm button[type="submit"] {
    background: linear-gradient(135deg, #3498db, #2980b9);
    padding: 14px;
    font-size: 1.1rem;
    border-radius: 8px;
    margin-top: 10px;
    letter-spacing: 0.5px;
}
#loginForm button[type="submit"]:hover { background: linear-gradient(135deg, #2980b9, #1f6391); }

#registerForm button[type="submit"] {
    background: linear-gradient(135deg, #2ecc71, #27ae60) !important;
    padding: 14px;
    font-size: 1.1rem;
    border-radius: 8px;
    margin-top: 10px;
    letter-spacing: 0.5px;
}
#registerForm button[type="submit"]:hover { background: linear-gradient(135deg, #27ae60, #1e8449) !important; }

/* =========================================
   HIỂN THỊ BÀI VIẾT (CARD)
   ========================================= */
.posts-section h3 { margin-bottom: 1.5rem; color: #2c3e50; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2rem; }
.clickable-card { cursor: pointer; display: flex; flex-direction: column; overflow: hidden; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.04); transition: transform 0.3s, box-shadow 0.3s; border: 1px solid #f1f2f6; }
.clickable-card:hover { transform: translateY(-6px); box-shadow: 0 12px 25px rgba(0,0,0,0.1); border-color: #e1f5fe; }
.post-thumb-wrapper { width: 100%; height: 200px; overflow: hidden; background-color: #eee; }
.post-card-thumb { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.clickable-card:hover .post-card-thumb { transform: scale(1.08); }
.post-title { font-size: 1.3rem; color: #2c3e50; margin-bottom: 0.8rem; line-height: 1.4; }
.post-snippet { color: #666; margin-bottom: 1rem; word-wrap: break-word; font-size: 0.95rem; }
.post-meta { font-size: 0.85rem; color: #999; border-top: 1px solid #eee; padding-top: 1rem; display: flex; justify-content: space-between; align-items: center; }

/* =========================================
   TRANG ĐỌC CHI TIẾT BÀI VIẾT
   ========================================= */
.single-post-wrapper { background: white; padding: 3.5rem; border-radius: 16px; box-shadow: 0 5px 25px rgba(0,0,0,0.05); margin-top: 2rem; }
.single-post-header { margin-bottom: 2.5rem; border-bottom: 1px solid #eee; padding-bottom: 1.5rem; text-align: center; }
.single-post-title { font-size: 2.5rem; color: #2c3e50; margin: 15px 0; line-height: 1.3; }
.single-post-meta { color: #7f8c8d; font-size: 1.05rem; }
.single-post-media-area { text-align: center; margin-bottom: 2.5rem; }
.single-post-img { max-width: 100%; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.single-post-video { width: 100%; max-height: 500px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.youtube-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.youtube-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.single-post-content { font-size: 1.15rem; line-height: 1.9; color: #34495e; white-space: pre-wrap; word-wrap: break-word; }

/* =========================================
   QUẢN TRỊ ADMIN (DASHBOARD)
   ========================================= */
.admin-manage-card { border: 1px solid #eee; padding: 25px; border-radius: 12px; margin-bottom: 20px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.03); transition: all 0.3s; }
.admin-manage-card:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.08); border-color: #ddd; }
.admin-manage-card .meta { font-size: 0.9rem; color: #7f8c8d; margin-top: 5px; }

.action-sm-btn { padding: 8px 16px; font-size: 0.85rem; border-radius: 6px; font-weight: bold; cursor: pointer; color: white; margin-right: 8px; margin-bottom: 8px; }

footer { background-color: #2c3e50; color: white; text-align: center; padding: 1.5rem 0; margin-top: auto; }

/* =========================================
   MODULE TIỆN ÍCH (TIPS & TRICKS)
   ========================================= */
.ti-search-panel { background: white; padding: 35px; border-radius: 16px; margin-bottom: 30px; display: flex; flex-direction: column; align-items: center; gap: 16px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); border: 1px solid #eee; }
.ti-input, .ti-select { width: 100%; max-width: 650px; padding: 16px 22px; border-radius: 16px; border: 1px solid #ddd; font-size: 1.05rem; font-family: inherit; outline: none; background-color: #f8fafc; transition: all 0.3s; color: #2c3e50; }
.ti-input:focus, .ti-select:focus { border-color: #2ecc71; background-color: white; box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.15); }
.ti-list { height: auto; padding: 10px; border-radius: 16px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.ti-list option { padding: 14px 20px; margin-bottom: 4px; border-radius: 10px; cursor: pointer; transition: 0.2s; font-size: 1.05rem; }
.ti-list option:hover { background-color: #f0fdf4; color: #15803d; font-weight: bold; }
.ti-card { background: white; border-radius: 24px; padding: 40px; display: none; box-shadow: 0 10px 25px rgba(0,0,0,0.1); border: 1px solid #eee; animation: slideUp 0.6s; }
.ti-section { margin-bottom: 35px; padding-bottom: 25px; border-bottom: 1px solid #eee; }
.ti-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.ti-label { color: #7f8c8d; font-weight: bold; font-size: 0.85rem; text-transform: uppercase; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.ti-label i { color: #2ecc71; font-size: 1rem; }
.ti-content { font-size: 1.1rem; line-height: 1.8; white-space: pre-wrap; color: #2c3e50; }
.ti-collapsed { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; position: relative; }
.ti-collapsed::after { content: ""; position: absolute; bottom: 0; right: 0; width: 100%; height: 50px; background: linear-gradient(transparent, white); }
.ti-btn-copy { background-color: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 0.9rem; font-weight: bold; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.ti-btn-copy:hover { background-color: #2ecc71; color: white; border-color: #2ecc71; transform: translateY(-1px); }
.ti-btn-download { display: inline-flex; align-items: center; gap: 10px; padding: 14px 35px; border-radius: 14px; text-decoration: none; font-weight: bold; color: white; background: linear-gradient(135deg, #f39c12, #e67e22); transition: 0.3s; }
.ti-btn-download:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(243, 156, 18, 0.4); filter: brightness(1.05); }
.ti-feedback { text-align: center; margin-top: 35px; padding-top: 35px; border-top: 1px dashed #ddd; }
.ti-btn-feedback { background: white; border: 1px solid #ddd; padding: 12px 24px; border-radius: 12px; cursor: pointer; margin: 0 8px; font-size: 0.95rem; font-weight: bold; color: #7f8c8d; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.ti-btn-feedback:hover:not(:disabled) { background: #f8f9fa; transform: translateY(-1px); color: #2c3e50; }
.ti-btn-feedback:disabled { cursor: not-allowed; opacity: 0.7; transform: none; }
.active-like { background: #f0fdf4 !important; color: #15803d !important; border-color: #bbf7d0 !important; }
.active-dislike { background: #fffbeb !important; color: #b45309 !important; border-color: #fde68a !important; }
.ti-badge-hot { background: #fee2e2; color: #b91c1c; padding: 4px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: bold; margin-left: 10px; }
.ti-badge-new { background: #dbeafe; color: #1d4ed8; padding: 4px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: bold; margin-left: 10px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive Mobile */
@media (max-width: 768px) { 
    header .container { flex-direction: column; gap: 1rem; } 
    .hero h2 { font-size: 2rem; } 
    .pgd-search-wrapper { flex-direction: column; border-radius: 12px; padding: 15px; }
    .pgd-divider { display: none; }
    .btn-gps, .pgd-input-group { width: 100%; }
    .single-post-wrapper { padding: 1.5rem; } 
    .single-post-title { font-size: 1.8rem; } 
    .pgd-route-popup { display: none; } 
    .ql-editor iframe.ql-video { min-height: 250px; }
}