/* ════════════════════════════════════════════════════════════
   DARK MODE - SHOPDINOSAW - VERSION 2.0
   Fix: Header không bị ngược màu + Search button nổi bật
   ════════════════════════════════════════════════════════════ */

/* ---- CSS Variables cho Light Mode (Mặc định) ---- */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --bg-tertiary: #f0f5f4;
    --text-primary: #1a3530;
    --text-secondary: #4a7a6e;
    --text-muted: #7aa89e;
    --border-color: #e0e0e0;
    --border-light: #c8ddd9;
    --accent-primary: #2F5D50;
    --accent-hover: #4A8F7E;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-hover: rgba(47, 93, 80, 0.18);
    --overlay: rgba(0, 0, 0, 0.5);
    
    /* Product colors */
    --product-bg: #fff;
    --product-bg-hover: #f9fdfb;
    --product-border: #e4efec;
    
    /* Alert colors */
    --alert-success-bg: #f0faf6;
    --alert-success-text: #2F5D50;
    --alert-success-border: #b2dfdb;
    --alert-error-bg: #fff0f0;
    --alert-error-text: #c0392b;
    --alert-error-border: #f5c6c6;
    
    /* Input colors */
    --input-bg: #fff;
    --input-border: #c8ddd9;
    --input-focus: #4A8F7E;
}

/* ---- CSS Variables cho Dark Mode ---- */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2a2a2a;
    --text-primary: #e8e8e8;
    --text-secondary: #b8b8b8;
    --text-muted: #888888;
    --border-color: #3a3a3a;
    --border-light: #4a4a4a;
    --accent-primary: #4A8F7E;
    --accent-hover: #5fa693;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(74, 143, 126, 0.3);
    --overlay: rgba(0, 0, 0, 0.7);
    
    /* Product colors */
    --product-bg: #242424;
    --product-bg-hover: #2a2a2a;
    --product-border: #3a3a3a;
    
    /* Alert colors */
    --alert-success-bg: #1a3530;
    --alert-success-text: #4A8F7E;
    --alert-success-border: #2F5D50;
    --alert-error-bg: #3a1a1a;
    --alert-error-text: #e74c3c;
    --alert-error-border: #c0392b;
    
    /* Input colors */
    --input-bg: #2a2a2a;
    --input-border: #4a4a4a;
    --input-focus: #5fa693;
}

/* ---- Áp dụng dark mode tự động theo thiết bị ---- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1a1a1a;
        --bg-secondary: #242424;
        --bg-tertiary: #2a2a2a;
        --text-primary: #e8e8e8;
        --text-secondary: #b8b8b8;
        --text-muted: #888888;
        --border-color: #3a3a3a;
        --border-light: #4a4a4a;
        --accent-primary: #4A8F7E;
        --accent-hover: #5fa693;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-hover: rgba(74, 143, 126, 0.3);
        --overlay: rgba(0, 0, 0, 0.7);
        --product-bg: #242424;
        --product-bg-hover: #2a2a2a;
        --product-border: #3a3a3a;
        --alert-success-bg: #1a3530;
        --alert-success-text: #4A8F7E;
        --alert-success-border: #2F5D50;
        --alert-error-bg: #3a1a1a;
        --alert-error-text: #e74c3c;
        --alert-error-border: #c0392b;
        --input-bg: #2a2a2a;
        --input-border: #4a4a4a;
        --input-focus: #5fa693;
    }
}

/* ════════════════════════════════════════════════════════════
   GLOBAL STYLES
   ════════════════════════════════════════════════════════════ */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ════════════════════════════════════════════════════════════
   HEADER & MENU - FIX KHÔNG BỊ NGƯỢC MÀU
   ════════════════════════════════════════════════════════════ */

/* Header - LUÔN giữ màu xanh gốc, KHÔNG đổi theo theme */
.menu_bar,
#header3 {
    background: #2F5D50 !important; /* Force màu gốc */
}

/* Light mode: Header giữ nguyên */
:root .menu_bar,
:root #header3 {
    background: #2F5D50 !important;
}

/* Dark mode: Header cũng giữ nguyên */
[data-theme="dark"] .menu_bar,
[data-theme="dark"] #header3 {
    background: #2F5D50 !important;
}

/* Tất cả text trong header LUÔN TRẮNG */
.menu_bar,
.menu_bar *,
#header3,
#header3 *,
.menu,
.menu * {
    color: #fff !important;
}

.menu_bar a,
#header3 a,
.menu a,
.logo a,
.logo strong,
.logo span {
    color: #fff !important;
}

/* Navigation menu */
#nav {
    background: #2F5D50 !important;
}

#nav a,
#menu-container a,
.menu-item a {
    color: #fff !important;
}

/* Mobile menu drawer */
#nav-drawer-header {
    background: rgba(0, 0, 0, 0.15) !important;
    color: #fff !important;
}

#nav-drawer-header span,
#nav-drawer-close {
    color: #fff !important;
}

/* Submenu */
.submenu,
.submenu li {
    background: #2F5D50 !important;
}

.submenu a {
    color: #fff !important;
}

.submenu a:hover {
    background: rgba(0, 0, 0, 0.2) !important;
}

/* Cart badge */
.cart .badge {
    background: #fff !important;
    color: #2F5D50 !important;
}

/* User name, login text */
.user-name,
.login-text,
.header-link {
    color: #fff !important;
}

/* ════════════════════════════════════════════════════════════
   SEARCH BAR - LÀM NỔI TRONG DARK MODE
   ════════════════════════════════════════════════════════════ */

/* Search input - Light mode */
.search-bar input,
.search input[type="text"],
.search input[type="search"] {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #1a3530 !important;
}

.search-bar input::placeholder,
.search input::placeholder {
    color: #7aa89e !important;
}

/* Search input - Dark mode: Nền sáng để dễ nhìn */
[data-theme="dark"] .search-bar input,
[data-theme="dark"] .search input[type="text"],
[data-theme="dark"] .search input[type="search"] {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .search-bar input::placeholder,
[data-theme="dark"] .search input::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

[data-theme="dark"] .search-bar input:focus,
[data-theme="dark"] .search input:focus {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Search button - Light mode */
.search-bar button,
.search button,
#search-btn-desktop,
#search-btn-mobile,
button[type="submit"] i.fa-search {
    background: #4A8F7E !important;
    color: #fff !important;
}

.search-bar button:hover,
.search button:hover,
#search-btn-desktop:hover,
#search-btn-mobile:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Search button - Dark mode: NỔI BẬT HẠN */
[data-theme="dark"] .search-bar button,
[data-theme="dark"] .search button,
[data-theme="dark"] #search-btn-desktop,
[data-theme="dark"] #search-btn-mobile {
    background: rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] button[type="submit"] i.fa-search {
    background: none !important;
}

[data-theme="dark"] .search-bar button:hover,
[data-theme="dark"] .search button:hover,
[data-theme="dark"] #search-btn-desktop:hover,
[data-theme="dark"] #search-btn-mobile:hover {
    background: rgba(255, 255, 255, 0) !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
}

/* Search icon */
[data-theme="dark"] .search i,
[data-theme="dark"] .search-bar i {
    color: #fff !important;
}

/* ════════════════════════════════════════════════════════════
   SEARCH OVERLAY (Mobile popup search)
   ════════════════════════════════════════════════════════════ */
#search-overlay {
    background: var(--overlay) !important;
}

.search-overlay-content {
    background: var(--bg-primary) !important;
}

#search-overlay-close {
    background: transparent !important;
    color: var(--text-primary) !important;
}

#search-overlay-close:hover {
    background: var(--bg-tertiary) !important;
}

.search-overlay-form input {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
}

.search-overlay-form button {
    background: var(--accent-primary) !important;
    color: #fff !important;
}

/* Nav overlay */
#nav-overlay {
    background: var(--overlay) !important;
}

/* ════════════════════════════════════════════════════════════
   PRODUCTS
   ════════════════════════════════════════════════════════════ */
.product {
    background: var(--product-bg) !important;
    border-color: var(--product-border) !important;
    color: var(--text-primary) !important;
}

.product:hover {
    background: var(--product-bg-hover) !important;
}

.product .namepr {
    color: var(--text-primary) !important;
}

.product .price {
    color: var(--accent-primary) !important;
}

/* ════════════════════════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════════════════════════ */
.main-content {
    background: var(--bg-secondary) !important;
    box-shadow: 0 2px 10px var(--shadow) !important;
}

.main h2,
.title_content {
    color: var(--text-primary) !important;
}

/* ════════════════════════════════════════════════════════════
   PAGES
   ════════════════════════════════════════════════════════════ */
.cart-page,
.account-page,
.product-detail-page,
.search-results-page {
    background: var(--bg-primary) !important;
}

.cart-items,
.cart-summary,
.account-sidebar,
.account-content,
.product-detail,
.product-description,
.order-card {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

.cart-item {
    border-bottom-color: var(--border-color) !important;
}

.cart-title,
.account-user-info h3,
.product-title,
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
}

.cart-header,
.order-header,
.account-sidebar {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* ════════════════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════════════════ */
input,
textarea,
select {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--input-focus) !important;
    box-shadow: 0 0 0 3px rgba(74, 143, 126, 0.1) !important;
}

input:disabled,
textarea:disabled,
select:disabled {
    background: var(--bg-tertiary) !important;
    color: var(--text-muted) !important;
}

/* ════════════════════════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════════════════════════ */
.alert-success,
.auth-alert-success {
    background: var(--alert-success-bg) !important;
    color: var(--alert-success-text) !important;
    border-color: var(--alert-success-border) !important;
}

.alert-error,
.auth-alert-error {
    background: var(--alert-error-bg) !important;
    color: var(--alert-error-text) !important;
    border-color: var(--alert-error-border) !important;
}

/* ════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════ */
.btn-primary,
.btn-buy-now,
.auth-btn {
    background: var(--accent-primary) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-buy-now:hover,
.auth-btn:hover {
    background: var(--accent-hover) !important;
}

.btn-secondary,
.btn-add-cart {
    background: var(--bg-primary) !important;
    color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}

.btn-secondary:hover,
.btn-add-cart:hover {
    background: var(--bg-tertiary) !important;
}

/* ════════════════════════════════════════════════════════════
   TEXT COLORS
   ════════════════════════════════════════════════════════════ */
.text-muted,
.result-count {
    color: var(--text-muted) !important;
}

p, span, div:not(.menu_bar):not(#header3):not(.menu):not(#nav) {
    color: var(--text-secondary);
}

/* Breadcrumb */
.breadcrumb a {
    color: var(--accent-hover) !important;
}

.breadcrumb span {
    color: var(--text-muted) !important;
}

/* ════════════════════════════════════════════════════════════
   FOOTER - FIX KHÔNG ĐỔI MÀU
   ════════════════════════════════════════════════════════════ */

/* Footer - FORCE màu cố định */
.footer {
    background: #2F5D50 !important; /* Màu sáng cố định */
    color: #ffffff !important;
    border-top: 1px solid #e0e0e0 !important;
}

/* Light mode - Footer sáng */
:root .footer {
    background: #2F5D50 !important;
    color: #f8f8f8 !important;
    border-top: 1px solid #000000 !important;
}

/* Dark mode - Footer TỐI */
[data-theme="dark"] .footer {
    background: #1a1a1a !important;
    color: #b8b8b8 !important;
    border-top: 1px solid #3a3a3a !important;
}

/* Footer headings */
.footer h3,
.footer h4,
.footer strong {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .footer h3,
[data-theme="dark"] .footer h4,
[data-theme="dark"] .footer strong {
    color: #e8e8e8 !important;
}

/* Footer links */
.footer a {
    color: #ffffff !important;
    transition: color 0.2s;
}

.footer a:hover {
    color: #707070 !important;
}

[data-theme="dark"] .footer a {
    color: #b8b8b8 !important;
}

[data-theme="dark"] .footer a:hover {
    color: #4A8F7E !important;
}

/* Footer text */
.footer p,
.footer span,
.footer li {
    color: #ffffff !important;
}

[data-theme="dark"] .footer p,
[data-theme="dark"] .footer span,
[data-theme="dark"] .footer li {
    color: #888888 !important;
}

/* Social icons */
.footer .social-icons a {
    background: #e0e0e0 !important;
    color: #ffffff !important;
}

.footer .social-icons a:hover {
    background: #2F5D50 !important;
    color: #fff !important;
}

[data-theme="dark"] .footer .social-icons a {
    background: #3a3a3a !important;
    color: #4A8F7E !important;
}

[data-theme="dark"] .footer .social-icons a:hover {
    background: #4A8F7E !important;
    color: #fff !important;
}

/* Loại trừ footer khỏi transition */
.footer,
.footer * {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease !important;
}


/* ════════════════════════════════════════════════════════════
   AUTH PAGE
   ════════════════════════════════════════════════════════════ */
.auth-wrap {
    background: var(--bg-primary) !important;
}

.auth-card {
    background: var(--bg-secondary) !important;
    box-shadow: 0 2px 12px var(--shadow) !important;
}

.auth-tab {
    color: var(--text-muted) !important;
}

.auth-tab.active {
    color: var(--accent-primary) !important;
    border-bottom-color: var(--accent-primary) !important;
}

.auth-field label {
    color: var(--text-primary) !important;
}

.auth-switch {
    color: var(--text-secondary) !important;
}

.auth-switch a {
    color: var(--accent-primary) !important;
}

/* ════════════════════════════════════════════════════════════
   DARK MODE TOGGLE BUTTON (Floating) - FIX
   ════════════════════════════════════════════════════════════ */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2F5D50; /* Force màu cố định */
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 9999;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Light mode */
:root .theme-toggle {
    background: #2F5D50 !important;
}

/* Dark mode */
[data-theme="dark"] .theme-toggle {
    background: #4A8F7E !important;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Light mode hover */
:root .theme-toggle:hover {
    background: #4A8F7E !important;
}

/* Dark mode hover */
[data-theme="dark"] .theme-toggle:hover {
    background: #5fa693 !important;
}

.theme-toggle i {
    transition: transform 0.3s ease;
}

.theme-toggle:active i {
    transform: rotate(360deg);
}

/* Icons */
.theme-toggle .icon-moon {
    display: block;
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

@media (max-width: 768px) {
    .theme-toggle {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}

/* ════════════════════════════════════════════════════════════
   ACCOUNT PAGE TOGGLE
   ════════════════════════════════════════════════════════════ */
.account-theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid var(--border-color);
}

.account-theme-toggle i {
    color: var(--accent-primary) !important;
    font-size: 16px;
}

.account-theme-toggle span {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary) !important;
}

.theme-switch {
    position: relative;
    width: 52px;
    height: 28px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: 0.4s;
    border-radius: 28px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .theme-slider {
    background: var(--accent-primary);
}

input:checked + .theme-slider:before {
    transform: translateX(24px);
}

/* ════════════════════════════════════════════════════════════
   TRANSITIONS
   ════════════════════════════════════════════════════════════ */
body,
.product,
.main-content,
.cart-summary,
.auth-card {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease;
}

button,
a,
input,
.theme-toggle,
.btn {
    transition: all 0.3s ease;
}

/* Loại trừ header/menu - KHÔNG transition */
.menu_bar,
#header3,
#nav,
.menu,
.menu_bar *,
#header3 *,
#nav * {
    transition: none !important;
}