/*
Theme Name: SMP Theme
Theme URI: https://yourdomain.com/
Author: SMP TEAM
Description: Theme tối giản quản lý bố cục, header, footer, menu và sidebar qua Customizer.
Version: 2.1.0
License: GNU General Public License v2 or later
Text Domain: smptheme
*/

/* ===========================================
   BASE RESET
=========================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: Arial, sans-serif;
    margin: 0; padding: 0;
    background-color: #f9f9f9;
    color: #333;
    line-height: 1.7; /* default — ghi đè bởi wp_add_inline_style */
    transition: background-color 0.2s;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration: none; }

/* ===========================================
   CONTAINER
=========================================== */
.container {
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    /* max-width inject từ Customizer */
}

/* ===========================================
   TOP BAR
=========================================== */
.site-top-bar {
    width: 100%;
    font-size: 0.85em;
    line-height: 1.4;
}
.top-bar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 6px;
    padding-bottom: 6px;
}
.top-bar-text { flex: 1 1 auto; }
.top-bar-text a { color: inherit; text-decoration: underline; }
.top-bar-widget { flex-shrink: 0; }
.topbar-widget-item .widget-title { display: none; }

/* ===========================================
   HEADER
=========================================== */
header {
    background: #23282d;
    color: #fff;
    position: relative;
    z-index: 900;
    /* padding inject từ Customizer */
}

/* Sticky Header */
header.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    animation: slideDown 0.25s ease;
}
@keyframes slideDown {
    from { transform: translateY(-100%); }
    to   { transform: translateY(0); }
}
body.has-sticky-header { padding-top: var(--header-height, 80px); }

/* Header layout: logo trái + menu phải (default) */
.header-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    /* padding inject từ Customizer */
}

/* Logo */
.site-branding { flex-shrink: 0; }
.site-branding a { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.site-logo img { max-height: 60px; width: auto; display: block; }
.site-branding-text h1 { margin: 0; font-size: 1.4em; line-height: 1.2; }
.site-branding-text p  { margin: 3px 0 0; font-size: 0.8em; opacity: 0.7; }

.header-custom-widget { font-size: 0.9em; flex-shrink: 0; }

/* ===========================================
   NAVIGATION — Menu chính
=========================================== */
.main-navigation { flex: 1; }

/* Layout: logo trái — menu phải */
.header-layout-logo-left .main-navigation { display: flex; justify-content: flex-end; }

/* Layout: logo giữa — menu dưới */
.header-layout-logo-center .header-wrap  { flex-direction: column; text-align: center; }
.header-layout-logo-center .site-branding { width: 100%; justify-content: center; display: flex; }
.header-layout-logo-center .main-navigation { width: 100%; }
.header-layout-logo-center nav ul { justify-content: center; }

/* Layout: menu trái — logo giữa */
.header-layout-menu-left .header-wrap { justify-content: space-between; }
.header-layout-menu-left .site-branding { order: 2; margin: 0 auto; }
.header-layout-menu-left .main-navigation { order: 1; flex: none; }
.header-layout-menu-left .header-custom-widget { order: 3; }

/* --- Nav UL Level 1 --- */
nav ul {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

nav ul li { position: relative; }

nav ul li a {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 0.95em;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s;
    /* color inject từ Customizer */
}

nav ul li a:hover,
nav ul li.current-menu-item > a,
nav ul li.current-menu-ancestor > a {
    /* bg + color inject từ Customizer */
}

/* Mũi tên dropdown */
nav ul li.menu-item-has-children > a::after {
    content: '▾';
    font-size: 0.75em;
    margin-left: 2px;
    opacity: 0.7;
    transition: transform 0.2s;
}
nav ul li.menu-item-has-children:hover > a::after,
nav ul li.menu-item-has-children.is-open > a::after {
    transform: rotate(180deg);
}

/* --- Dropdown Sub-menu --- */
nav ul .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    z-index: 9999;
    padding: 6px 0;
    flex-direction: column;
    gap: 0;
    animation: fadeInDown 0.15s ease;
}
nav ul li:hover > .sub-menu,
nav ul li.is-open > .sub-menu { display: flex; }

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

nav ul .sub-menu li { width: 100%; }
nav ul .sub-menu li a {
    color: #333 !important;
    padding: 8px 16px;
    border-radius: 0;
    font-weight: 400;
    font-size: 0.9em;
    background: transparent;
}
nav ul .sub-menu li a:hover { background: #f5f5f5; color: #000 !important; }

/* Sub-sub-menu (level 3) */
nav ul .sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-top: -6px;
}
nav ul .sub-menu li.menu-item-has-children > a::after { content: '›'; }

/* Highlight trang hiện tại */
nav ul li.current-menu-item > a {
    font-weight: 600;
}

/* --- Hamburger button --- */
.nav-toggle {
    display: none;
    background: none;
    border: 2px solid rgba(255,255,255,0.7);
    color: #fff;
    padding: 6px 11px;
    cursor: pointer;
    font-size: 1.2em;
    border-radius: 5px;
    line-height: 1;
    flex-shrink: 0;
    margin-left: auto;
    transition: border-color 0.2s;
}
.nav-toggle:hover { border-color: #fff; }

/* ===========================================
   LAYOUT — Boxed / Full-width
=========================================== */
body.layout-boxed .site-wrap {
    overflow: hidden;
    /* max-width + shadow inject */
}
body.layout-fullwidth .site-wrap { max-width: 100%; box-shadow: none; }

/* ===========================================
   LAYOUT — Main + Sidebar
=========================================== */
.main-content {
    display: flex;
    margin-top: 30px;
    gap: 30px;
}
.layout-sidebar-right  { flex-direction: row; }
.layout-sidebar-left   { flex-direction: row-reverse; }
.layout-no-sidebar .site-sidebar { display: none; }
.layout-no-sidebar .site-main { flex: 0 0 100%; max-width: 100%; }

.site-main {
    flex: 1; min-width: 0;
    background: #fff;
    padding: 24px;
    border: 1px solid #e5e5e5;
    border-radius: var(--border-radius, 6px);
}
.site-sidebar {
    flex: 0 0 300px; width: 300px;
    background: #fff;
    padding: 20px;
    border: 1px solid #e5e5e5;
    border-radius: var(--border-radius, 6px);
}

/* ===========================================
   BREADCRUMB
=========================================== */
.smptheme-breadcrumb {
    padding: 10px 0;
    font-size: 0.85em;
    color: #888;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
}
.smptheme-breadcrumb a { color: #555; text-decoration: underline; }
.smptheme-breadcrumb a:hover { color: #000; }
.smptheme-breadcrumb .sep { margin: 0 6px; opacity: 0.5; }
.smptheme-breadcrumb .current { color: #333; }

/* ===========================================
   ENTRY META & CONTENT
=========================================== */
.entry-meta { margin-bottom: 15px; color: #666; font-size: 0.9em; }
.entry-content.content-align-left   { text-align: left; }
.entry-content.content-align-center { text-align: center; }
.entry-content.content-align-right  { text-align: right; }

/* ===========================================
   FOOTER
=========================================== */
footer {
    background: #23282d;
    color: #fff;
    margin-top: 30px;
}
.footer-widgets-container {
    display: flex; gap: 30px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
}
.footer-column { flex: 1; min-width: 0; }
.footer-column ul { list-style: none; padding-left: 0; line-height: 1.8; margin: 0; }
.footer-column a { color: #ccc; text-decoration: none; }
.footer-column a:hover { color: #fff; }
.copyright-text { margin: 10px 0; padding: 0 5px; color: #fff; }
.footer-navigation ul {
    list-style: none; padding: 0; margin: 10px 0 0;
    display: flex; flex-wrap: wrap; gap: 12px;
}
.footer-navigation ul li a { color: #ccc; font-size: 0.9em; }
.footer-navigation ul li a:hover { color: #fff; }

/* ===========================================
   BACK TO TOP
=========================================== */
.back-to-top {
    position: fixed;
    bottom: 28px; right: 28px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #23282d;
    color: #fff;
    border: none; cursor: pointer;
    font-size: 1.3em; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.25s, transform 0.25s;
    transform: translateY(10px);
    z-index: 8888;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { transform: translateY(-2px); }

/* ===========================================
   PRELOADER
=========================================== */
#smp-preloader {
    position: fixed; inset: 0;
    background: #fff;
    z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.4s ease;
}
#smp-preloader.hidden { opacity: 0; pointer-events: none; }
.smp-spinner {
    width: 40px; height: 40px;
    border: 3px solid #e5e5e5;
    border-top-color: #23282d;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================
   RESPONSIVE — Tablet (≤ 900px)
=========================================== */
@media (max-width: 900px) {
    .site-sidebar { flex: 0 0 240px; width: 240px; }
}

/* ===========================================
   RESPONSIVE — Mobile (≤ 768px)
=========================================== */
@media (max-width: 768px) {
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }

    .main-navigation {
        width: 100%;
        overflow: hidden;
        max-height: 0;
        transition: max-height 0.32s ease;
    }
    .main-navigation.nav-open { max-height: 800px; }

    /* Reset mọi layout header về dạng column trên mobile */
    .header-wrap {
        flex-direction: row !important;
        flex-wrap: wrap;
    }
    .header-layout-menu-left .site-branding { order: 0; margin: 0; }
    .header-layout-menu-left .main-navigation { order: 2; width: 100%; }

    nav ul {
        flex-direction: column; gap: 0;
        border-top: 1px solid rgba(255,255,255,0.12);
        padding-top: 6px; margin-top: 8px;
    }
    nav ul li a { padding: 10px 12px; border-radius: 4px; }
    nav ul li a { border-bottom: 1px solid rgba(255,255,255,0.07); }

    /* Dropdown mobile: hiện dưới item cha */
    nav ul .sub-menu {
        position: static;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: rgba(0,0,0,0.15);
        padding: 0;
        margin-left: 16px;
        animation: none;
        display: none;
    }
    nav ul li.is-open > .sub-menu { display: flex; }
    nav ul li:hover > .sub-menu { display: none; }
    nav ul li.is-open > .sub-menu { display: flex; }
    nav ul .sub-menu li a { color: rgba(255,255,255,0.85) !important; font-size: 0.88em; }
    nav ul .sub-menu .sub-menu { margin-left: 14px; }

    .main-content { flex-direction: column !important; gap: 20px; margin-top: 20px; }
    .site-sidebar { flex: 0 0 auto; width: 100%; }

    .footer-widgets-container { flex-direction: column; gap: 20px; }
    .footer-navigation ul { flex-direction: column; gap: 6px; }

    .top-bar-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
    .top-bar-widget { width: 100%; }
}

/* ===========================================
   RESPONSIVE — Small Mobile (≤ 480px)
=========================================== */
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .site-main, .site-sidebar { padding: 14px; }
    .site-branding-text h1 { font-size: 1.1em; }
    .back-to-top { bottom: 16px; right: 16px; width: 38px; height: 38px; }
    footer { padding-left: 0; padding-right: 0; }
    .copyright-text { font-size: 0.85em; }
}

/* ===========================================
   ACCESSIBILITY
=========================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
    #smp-preloader { display: none !important; }
}
