/* Guest Theme Color Scheme */
.guest-theme {
    --guest-primary: #0d9488;
    /* Teal */
    --guest-secondary: #06b6d4;
    /* Cyan */
    --guest-accent: #14b8a6;
    /* Teal variant */
    --guest-bg-light: #f0fdfa;
    /* Light teal tint */
    --guest-text: #134e4a;
    /* Dark teal for text */
}

/* Guest Header Gradient */
.bg-guest-header {
    background: linear-gradient(135deg, #0d9488 0%, #0891b2 100%) !important;
}

/* Guest Footer Gradient */
.bg-guest-footer {
    background: linear-gradient(135deg, #f0fdfa 0%, #e0f2fe 100%) !important;
    color: #134e4a !important;
    border-top: 1px solid #99f6e4 !important;
}

.bg-guest-footer .text-white {
    color: #134e4a !important;
}

.bg-guest-footer a {
    color: #0d9488 !important;
}

.bg-guest-footer a:hover {
    color: #0891b2 !important;
}

/* CSS Variables */
:root {
    --header-height: 56px;
    --footer-height: 50px;
    --sidebar-left-width: 280px;
    --sidebar-right-width: 300px;
}

/* User Type Selector Styles */
.user-type-selector-container {
    margin-right: 0.5rem;
    margin-left: 0.5rem;
}

.user-type-toggle {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-type-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.user-type-icon-circle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-type-icon-circle i {
    font-size: 16px;
    color: #ffffff;
}

.user-type-selector-container .dropdown-menu {
    min-width: 180px;
    background: #0d9488;
    border: 1px solid #0f766e;
    box-shadow: 0 10px 20px rgba(13, 148, 136, 0.3);
    margin-top: 0.5rem;
}

.user-type-selector-container .dropdown-item {
    color: #ffffff;
    padding: 0.5rem 1rem;
    transition: background-color 0.2s ease;
}

.user-type-selector-container .dropdown-item:hover,
.user-type-selector-container .dropdown-item.active {
    background-color: #0f766e;
    color: #ffffff;
}

.user-type-selector-container .dropdown-item i {
    color: #ffffff !important;
}

/* Base Styles */
body {
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
    width: 100%;
}

/* Header Styles */
.header {
    height: var(--header-height);
    transition: box-shadow 0.3s ease;
    z-index: 1030;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    /* Background is set by bg-guest-header or bg-dark class */
}

/* Ensure guest header gradient overrides */
.header.bg-guest-header {
    background: linear-gradient(135deg, #0d9488 0%, #0891b2 100%) !important;
}

/* Header Navigation */
.header-nav {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    /* margin-top: 3px; Removed for alignment */
    /*for debuging only*/
    /*border:5px solid #Fc3e50;*/
}

.header-nav .nav-link {
    padding: 0.5rem 1rem;
    color: #fff !important;
    text-decoration: none;
    transition: background-color 0.2s;
    margin-top: 0px;
    /*for debuging only*/
    /*border:1px solid #007bff;*/
}

/*Highlight when hover*/
.header-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

/*space between icon and text*/
.header-nav .nav-item .nav-link i {
    margin-right: 5px;
}

/* Ensure centering containers have height on desktop */
@media (min-width: 768px) {

    .header-collapse,
    #mainMenu {
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
    }
}

#homebutton {
    position: relative;
    top: 0px;
    width: 48px;
}


/* Sidebar Base Styles */
.sidebar {
    position: fixed;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1031;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
}

/* Left Sidebar */
.sidebar-left {
    left: 0;
    width: var(--sidebar-left-width);
    transform: translateX(-100%);
    background-color: #2c3e50;
}

.sidebar-left .nav-item {
    margin: 2px 8px;
}

.sidebar-left .nav-link {
    color: #e9ecef !important;
    padding: 10px 15px;
    border-radius: 5px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-left .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
}

.sidebar-left .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
    font-weight: 500;
}

.sidebar-left .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1em;
    color: #8395a7;
}

.sidebar-left .nav-title {
    padding: 12px 15px;
    font-size: 0.85em;
    text-transform: uppercase;
    font-weight: 600;
    color: #8395a7;
    margin-top: 10px;
}

/* Submenu Styles */
.sidebar-left .nav-group {
    margin-bottom: 5px;
}

.sidebar-left .nav-group-items {
    padding-left: 20px;
}

.sidebar-left .nav-group-items .nav-link {
    padding: 8px 15px;
    font-size: 0.95em;
    color: #bdc3c7 !important;
}

.sidebar-left .nav-group-items .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-left .nav-group-items .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
}

/* Show States */
.sidebar.show {
    transform: translateX(0) !important;
}

/* Right Sidebar */
.sidebar-end {
    right: 0;
    width: var(--sidebar-right-width);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    background-color: #212529;
    /* Dark background for admin right sidebar */
}

.sidebar-end.show {
    transform: translateX(0);
}

/* Right Sidebar - Admin Friends List */
#right-sidebar .sidebar-body {
    background-color: #212529;
    /* Ensure full background coverage */
    min-height: 100%;
}

#right-sidebar #online-friends-list-container {
    background-color: #212529;
    /* Match sidebar background */
}

/* Friend List Item Hover Effect */
#right-sidebar .friend-list-item {
    cursor: pointer;
    background-color: transparent;
}

#right-sidebar .friend-list-item:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    /* Bright hover effect */
}

#right-sidebar .friend-list-item:active {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

/* Main Content */

.main-content {
    top: -5px;
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    padding: 20px;
    position: relative;
    transition: margin 0.3s ease-in-out;
}

/* Footer Styles */
.c-footer {
    height: var(--footer-height);
    position: relative;
    padding: 1rem;
    transition: margin 0.3s ease-in-out;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* Overlay Styles */
.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1025;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s linear 0.3s, opacity 0.3s ease;
}

.sidebar-overlay.show {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

/* Flash Messages */
.flash-message {
    margin: 10px 0;
    padding: 10px 15px;
    border-radius: 4px;
    position: relative;
    animation: fadeIn 0.5s;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.flash-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.flash-message .close-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
    color: inherit;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .sidebar {
        width: 85%;
        max-width: 320px;
    }

    .sidebar-left {
        left: 0;
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0) !important;
    }

    .sidebar-end {
        width: 85%;
        max-width: 320px;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .main-content,
    .main-content.sidebar-left-expanded,
    .c-footer,
    .c-footer.sidebar-left-expanded {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }
}

/* Desktop Styles */
@media (min-width: 769px) {
    .sidebar-left {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0) !important;
    }

    .main-content.sidebar-left-expanded {
        margin-left: var(--sidebar-left-width);
    }

    .c-footer.sidebar-left-expanded {
        margin-left: var(--sidebar-left-width);
    }
}

/* Dropdown Styles */
.dropdown-menu {
    margin-top: 0.5rem;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Post Card */
.post-card {
    margin-bottom: 20px;
}

/* Button Styles */
.btn-link.text-white {
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

.btn-link.text-white:hover {
    background-color: rgba(255, 255, 255, 0.1);
}


/* Transition Styles */
.sidebar,
/*.main-content,*/
.c-footer {
    will-change: transform, margin, visibility;
}

/*สำหรับกล่องข้อความ*/
#recipientTags .badge {
    color: #fff;
    /* เปลี่ยนสีตัวอักษรเป็นสีขาว */
    background-color: #007bff;
    /* พื้นหลังสีฟ้า */
}

#recipientTags .badge .btn {
    color: #000;
    /* ปุ่ม X เป็นสีขาว */
}

#recipientTags .badge .btn:hover {
    color: #000;
    /* เปลี่ยนสีปุ่ม X เป็นสีดำเมื่อ hover */
}

.message-avatar .avatar-placeholder {
    font-size: 0.8rem;
    /* Adjust font size for placeholder */
}

.list-group-item.unread {
    background-color: #f8f9fa;
    /* Light background for unread */
    font-weight: bold;
    /* Make text bold for unread */
}

.list-group-item .subject {
    color: #212529;
    /* Ensure subject text is readable */
}

.card-footer {
    background-color: #fff;
    /* Ensure footer background is white */
    border-top: 1px solid #dee2e6;
    /* Add a top border */
}


@media (max-width: 767px) {

    /* Hide the 'First' button link */
    .dt-paging .page-link.first {
        display: none !important;
    }

    /* Hide the 'Last' button link */
    .dt-paging .page-link.last {
        display: none !important;
    }
}

/*------------------------------------Dropdown Menu multi level submenu-------------------------------------*/
.dropdown-menu {
    z-index: 1100;
}

.dropdown-submenu:hover>.dropdown-menu,
.dropdown-submenu:focus-within>.dropdown-menu {
    display: block;
}

.dropdown-submenu>.dropdown-toggle {
    color: rgb(128, 128, 0);
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Caret (::after) ชิดขวาสุดของแถว */
.dropdown-submenu>.dropdown-toggle::after {
    display: inline-block;
    margin-left: auto;
    flex-shrink: 0;
    vertical-align: middle;
}

.icon-text {
    display: flex;
    align-items: center;
    column-gap: 0;
}

.icon-text i {
    flex-shrink: 0;
    margin-right: 0;
    padding-right: 0;
}

.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 129px;
    margin-top: -6px;
}

/* แสดงเมนูเมื่อมีคลาส show */
.dropdown-menu.show {
    display: block;
}

/*------------------------------------end Dropdown Menu multi level submenu-------------------------------------*/
/* Hiding of titles removed here as handled by header-nav specific rule in tablet range */

.nav-link {
    top: 0px;
    height: 40px;
    min-width: 40px;
}

@media (max-width: 550px) {

    /*ต้้งแต่ 0-550px **/
    .header {
        padding-top: 0px;
        margin-top: 0px;
        height: 57px;
    }

    .header-nav {
        padding-top: 0px;
        padding-bottom: 0px;
        margin-top: 0px;
        margin-bottom: 0px;
        height: 32px;
    }


    .dropdown-menu {
        position: static;
        float: none;
    }


    .dropdown-submenu>.dropdown-menu {
        left: 0;
        margin-left: 1rem;
    }

    .submenu-indicator {
        margin-left: auto;
        font-size: 0.8rem;
        transition: transform 0.3s ease;
    }

    .dropdown-submenu.show>a .submenu-indicator {
        transform: rotate(90deg);
    }

    .dropdown-submenu>a.dropdown-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .dropdown-submenu>.dropdown-menu {
        position: static;
        margin-left: 1rem;
    }

    .dropdown-submenu>a.dropdown-item .submenu-indicator {
        margin-left: 10px;
    }
}

@media (max-width: 720px) {

    /* Layout only for mobile (0-720px) */
    .header-collapse {
        width: 100%;
        background: #042f2e !important;
        min-height: auto !important;
        height: auto !important;
        position: absolute;
        top: 100%;
        left: 0;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
        z-index: 1010;
        padding: 5px 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: 3px solid #0d9488;
    }

    /* Style dropdowns inside the collapse menu on mobile */
    .header-collapse .dropdown-menu {
        background: #042f2e !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6) !important;
        padding: 10px 0 !important;
        margin-top: 0 !important;
        min-width: 200px !important;
    }

    /* Mobile specific stacking and padding */
    .header-collapse #mainMenu {
        flex-direction: column !important;
        width: 100%;
    }

    .header-collapse .nav-link,
    .header-collapse .dropdown-toggle {
        padding: 10px 12px;
        border-bottom: none !important;
    }

    .header-collapse .dropdown-item {
        padding: 10px 20px !important;
    }

    .header-collapse .header-nav {
        position: static !important;
        display: flex !important;
        flex-direction: column !important;
        /* Changed from row to column for mobile */
        flex-wrap: wrap !important;
        width: 100% !important;
        height: auto !important;
        margin-top: 0 !important;
        padding: 5px 15px !important;
        /* Moved from 1130px query */
    }
}

@media (max-width: 1130px) {
    /* Styling for both mobile and tablet (0-1130px) */

    /* Override the default hiding of titles in this range */
    .header-nav .dropdown-menu-title {
        display: inline-block !important;
    }

    /* Styles for top-right header dropdowns (Profile/Notification) */
    .header-nav .dropdown-menu {
        background: #042f2e !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6) !important;
        margin-top: 5px !important;
    }

    /* Force white text for ALL elements inside header dropdowns in this range */
    .header-nav .dropdown-item,
    .header-nav .dropdown-header,
    .header-nav .text-muted,
    .header-nav .dropdown-menu i,
    .header-nav .dropdown-menu span,
    .header-nav .dropdown-menu div:not(.avatar) {
        color: #fff !important;
    }

    /* Force display of menu titles that are hidden on smaller screens */
    .header-nav .dropdown-menu-title {
        display: inline-block !important;
    }

    /* Make dividers visible on dark background */
    .header-collapse .dropdown-divider,
    .header-nav .dropdown-divider {
        border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
    }

    .header-nav .dropdown-item:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: #fff !important;
    }

    /* Color improvements only for Tablet range, NO padding changes here */
    .header-collapse .dropdown-item {
        color: #fff !important;
    }

    .header-collapse .dropdown-item:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
    }

    .header-collapse .header-nav {
        position: static !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        width: 100% !important;
        height: auto !important;
        margin-top: 0 !important;
        padding: 5px 15px !important;
    }

    .header-collapse .nav-link,
    .header-collapse .dropdown-toggle {
        color: #fff !important;
    }
}

/* Navbar toggler styling */
.navbar-toggler {
    padding: 8px 12px;
    background: transparent;
}

.navbar-toggler:focus {
    outline: none;
    box-shadow: none;
}

/* Hide menu collapse by default on mobile, show when expanded */
.header-collapse:not(.show) {
    display: none;
}

.header-collapse.show {
    display: block !important;
}
}

@media (min-width: 720px) {

    /*ต้้งแต่ 720px ขึ้นไป**/
    .submenu-indicator {
        margin-left: auto;
        font-size: 0.8rem;
        transition: transform 0.3s ease;
    }

    .dropdown-submenu.show>a .submenu-indicator {
        transform: rotate(90deg);
    }

    .dropdown-submenu>a.dropdown-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .dropdown-submenu>.dropdown-menu {
        left: 129px;
        top: 0;
        margin-top: -6px;
    }
}

/* Ensure profile dropdown is readable on all breakpoints (including lg+) */
#profile-dropdown-menu {
    background: #042f2e !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6) !important;
}
#profile-dropdown-menu .dropdown-item,
#profile-dropdown-menu .dropdown-header,
#profile-dropdown-menu .text-muted,
#profile-dropdown-menu i,
#profile-dropdown-menu span,
#profile-dropdown-menu div:not(.avatar) {
    color: #fff !important;
}
#profile-dropdown-menu .dropdown-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
}
#profile-dropdown-menu .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}