.modal .switch {
    width: 50px;
    height: 28px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Global scrollbar styling - apply to scrollable elements */
html,
body,
.app-content,
.app-content-inner,
.table-container,
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.6) rgba(241, 245, 249, 0.5);
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Global scrollbar styling for webkit browsers */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.app-content::-webkit-scrollbar,
.app-content-inner::-webkit-scrollbar,
.table-container::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.app-content::-webkit-scrollbar-track,
.app-content-inner::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
    border-radius: 6px;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.app-content::-webkit-scrollbar-thumb,
.app-content-inner::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.6);
    border-radius: 6px;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
.app-content::-webkit-scrollbar-thumb:hover,
.app-content-inner::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.8);
}

html {
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #dce7f6 0%, #eef2f9 100%);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    position: relative;
}

.app-layout {
    min-height: 100vh;
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
}

.app-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 2.5rem;
    margin-left: 324px;
    width: calc(100% - 324px);
    max-width: calc(100% - 324px);
    overflow-x: auto;
    overflow-y: auto;
    box-sizing: border-box;
}

.app-content-inner {
    flex: 1;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2.5rem;
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 3rem;
    backdrop-filter: blur(20px);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    box-sizing: border-box;
}

.topbar {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    margin-bottom: 1.75rem;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.sidebar {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(236, 244, 255, 0.85));
    border-right: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    flex-direction: column;
    padding-top: 2.25rem;
    padding-left: 1.75rem;
    padding-right: 1rem;
    padding-bottom: 1.5rem;
    gap: 2.2rem;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 300px;
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
    z-index: 1000;
    box-shadow: 8px 0 35px rgba(15, 23, 42, 0.08);
    overflow-y: auto;
    overflow-x: visible;
    box-sizing: border-box;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0ea5e9;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-align: left;
    width: 100%;
    flex-shrink: 0;
}

.sidebar-brand span {
    color: #0f172a;
    display: inline-block;
    line-height: 1.15;
    max-width: 150px;
    white-space: normal;
    word-break: break-word;
}

.sidebar-brand:hover span {
    color: #2563eb;
}

.sidebar-brand:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.brand-logo-wrapper {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.12);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.55);
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    background: #fff;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding-bottom: 4rem;
    min-height: fit-content;
    box-sizing: border-box;
}

/* Ensure last sidebar item is fully visible */
.sidebar-nav .sidebar-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
}

.sidebar-nav .sidebar-item:last-child .sidebar-submenu {
    margin-bottom: 1rem;
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-item:not(.has-children) {
    gap: 0;
}

.sidebar-toggle {
    width: 100%;
    text-align: left;
}

.sidebar-item.has-children .sidebar-link {
    cursor: pointer;
}

.sidebar-item.has-children .sidebar-toggle.active {
    border-color: transparent;
}

.sidebar-item.has-children .chevron {
    transition: transform 0.2s ease;
}

.sidebar-item.open .sidebar-toggle .chevron {
    transform: rotate(90deg);
}

.sidebar-submenu {
    display: grid;
    gap: 0.6rem;
    margin-left: 0.5rem;
    margin-right: 0;
    margin-bottom: 0.5rem;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    min-width: 230px;
    width: calc(100% - 10px);
}

.sidebar-item.open .sidebar-submenu {
    max-height: 2000px;
    opacity: 1;
    pointer-events: auto;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
    border-radius: 0.9rem;
    text-decoration: none;
    font-weight: 500;
    color: rgba(15, 23, 42, 0.68);
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    transition: all 0.2s ease;
    flex-wrap: wrap;
}

.sidebar-sublink i {
    font-size: 0.9rem;
}

.sublink-icon {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(37, 99, 235, 0.85);
    font-size: 0.85rem;
}

.sidebar-sublink {
    min-height: 50px;
}

.sublink-label {
    flex: 1;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: calc(100% - 42px);
}

.sidebar-sublink:hover {
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.26);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.16);
    transform: translateX(4px);
}

.sidebar-sublink.active {
    color: #1d4ed8;
    background: rgba(219, 234, 254, 0.8);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
}

.sublink-bullet {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.4);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.sidebar-item.open .sidebar-sublink .sublink-bullet {
    background: rgba(37, 99, 235, 0.65);
}



.sidebar-item.sidebar-section {
    gap: 1rem;
    padding-top: 0.65rem;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 16px;
    font-weight: 800;
    color: rgba(15, 23, 42, 0.55);
    padding: 0.6rem 0.75rem;
    border-left: 4px solid rgba(148, 163, 184, 0.45);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    margin-bottom: 0.2rem;
}

.sidebar-section-title .icon-pill {
    background: rgba(148, 163, 184, 0.18);
    color: rgba(15, 23, 42, 0.65);
}

.sidebar-nav-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 0;
    padding-right: 4px;
    padding-bottom: 5rem;
    margin-right: -6px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-sizing: border-box;
}

.sidebar-nav-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
    border-radius: 999px;
}

.sidebar-section-links {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-left: 0.35rem;
}

.sidebar-subsection-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-left: 4px solid rgba(148, 163, 184, 0.45);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    margin-top: 0.75rem;
    margin-bottom: 0.2rem;
}

.subsection-title-text {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 16px;
    font-weight: 800;
    color: rgba(15, 23, 42, 0.55);
}

.sidebar-link.sidebar-section-link {
    gap: 0.85rem;
    padding: 0.95rem 1rem;
    border-color: rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.sidebar-link.sidebar-section-link .link-label {
    font-weight: 600;
    color: rgba(15, 23, 42, 0.82);
}

.sidebar-link.sidebar-section-link .icon-pill {
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.sidebar-link.sidebar-section-link.active .link-label {
    color: #1d4ed8;
}

.section-link-icon {
    width: 34px;
    height: 34px;
    border-radius: 0.9rem;
    background: rgba(59, 130, 246, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2563eb;
    font-size: 0.85rem;
}

.sidebar-link.sidebar-section-link.active .section-link-icon {
    background: rgba(37, 99, 235, 0.18);
    color: #1d4ed8;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.95rem;
    padding: 0.95rem 1.05rem;
    border-radius: 1.1rem;
    text-decoration: none;
    color: #0f172a;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.15);
    transition: all 0.2s ease;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.sidebar-link::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(14, 165, 233, 0.18));
    pointer-events: none;
}

.sidebar-link .icon-pill {
    width: 44px;
    height: 44px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0f2fe;
    color: #0ea5e9;
    font-size: 1.25rem;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.5);
}

.sidebar-link .chevron {
    margin-left: auto;
    color: rgba(15, 23, 42, 0.35);
    font-size: 0.75rem;
}

.sidebar-link:hover {
    transform: translateX(6px);
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
}

.sidebar-link:hover::before {
    opacity: 1;
}

.sidebar-link.active {
    color: #0f172a;
    border-color: transparent;
    transform: translateX(6px);
    box-shadow: 0 18px 42px rgba(37, 99, 235, 0.32);
}

.sidebar-link.active::before {
    opacity: 1;
}

.sidebar-link.active .icon-pill {
    background: rgba(255, 255, 255, 0.65);
    color: #2563eb;
}

.sidebar-link.active .chevron {
    color: rgba(37, 99, 235, 0.85);
}

.main-content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    color: #0f172a;
    overflow-x: auto;
    overflow-y: visible;
    box-sizing: border-box;
}

.main-content h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1.8rem;
}

.content-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.75rem;
    padding: 2.25rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
    border: 1px solid rgba(226, 232, 240, 0.35);
    margin-bottom: 2rem;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    box-sizing: border-box;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.section-title i {
    color: #2563eb;
}

.page-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.tabs {
    display: inline-flex;
    gap: 0.65rem;
    background: rgba(59, 130, 246, 0.12);
    border-radius: 999px;
    padding: 0.4rem;
    margin-bottom: 1.75rem;
}

.tabs .tab {
    text-decoration: none;
    color: rgba(30, 41, 59, 0.6);
    font-weight: 600;
    padding: 0.5rem 1.3rem;
    border-radius: 999px;
    transition: all 0.2s ease;
}

.tabs .tab:focus {
    outline: none;
    text-decoration: none;
}

.tabs .tab:hover {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
}

.tabs .tab:hover span,
.tabs .tab:hover i,
.tabs .tab:focus span,
.tabs .tab:focus i {
    text-decoration: none;
}

.tabs .tab.active {
    background: #ffffff;
    color: #2563eb;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    margin-bottom: 1.75rem;
}

.topbar-inner,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.messenger-toggle-top {
    position: relative;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    border: none;
    border-radius: 0.8rem;
    padding: 0.6rem 0.9rem;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
    overflow: visible;
}

.messenger-toggle-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.5);
    background: linear-gradient(135deg, #2fe576, #1ba085);
}

.messenger-icon-single {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: 0.85rem;
    background: linear-gradient(130deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0)), rgba(255, 255, 255, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.35), inset 0 -2px 5px rgba(0, 0, 0, 0.18), 0 6px 14px rgba(15, 70, 55, 0.2);
}

.messenger-icon-single i {
    position: relative;
    font-size: 1.1rem;
    color: #ffffff;
    z-index: 2;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.messenger-toggle-top:hover .messenger-icon-single {
    transform: scale(1.02);
}

.messenger-toggle-top .messenger-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border: 2.5px solid white;
    padding: 0 0.3rem;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    z-index: 10;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-footer .nav-link {
    justify-content: flex-start;
    padding: 0.5rem 0;
}

.notification-bell {
    position: relative;
}

.notification-bell .badge {
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    position: absolute;
    top: -8px;
    right: -8px;
}

.user-dropdown {
    position: relative;
}

.user-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

.user-toggle:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.user-toggle .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
}

.user-toggle .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    font-weight: 600;
    color: var(--primary-color);
}

.user-greeting {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.user-greeting .greeting {
    font-weight: 600;
}

.user-greeting .role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    padding: 0.75rem 0;
    min-width: 180px;
    display: none;
}

.user-dropdown.open .user-menu {
    display: block;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.2rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.user-menu-item:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
}

.main-content a {
    color: #4338ca;
    font-weight: 600;
    text-decoration: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.3rem;
    border-radius: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn i,
.btn span {
    pointer-events: none;
}

.btn:hover,
.btn:focus {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.18);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
}

.btn-primary:hover {
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.28);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
}

.btn-success:hover {
    box-shadow: 0 16px 30px rgba(16, 185, 129, 0.28);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    box-shadow: 0 12px 26px rgba(148, 163, 184, 0.25);
}

.btn-sm {
    padding: 0.45rem 1.05rem;
    font-size: 0.82rem;
    border-radius: 0.75rem;
}

.btn-link {
    background: none;
    color: var(--primary-color);
    padding: 0;
}

label {
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.4rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 0.9rem;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.94);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.65);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 1.4rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.data-table thead {
    background: rgba(15, 23, 42, 0.04);
    color: rgba(15, 23, 42, 0.65);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.78rem;
}

.data-table th,
.data-table td {
    padding: 1rem 1.4rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.08);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
}

.profile-page {
    display: flex;
    justify-content: center;
}

.profile-wrapper {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1100px;
}

.profile-sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.6rem;
    padding: 2rem 1.75rem;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-summary {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.profile-summary-avatar {
    width: 140px;
    height: 140px;
    border-radius: 1.25rem;
    margin: 0 auto;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(37, 99, 235, 0.18));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.55);
}

.profile-summary-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-summary .avatar-initial {
    font-size: 3rem;
    font-weight: 700;
    color: #2563eb;
}

.profile-summary h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.profile-summary p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-role {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
    font-weight: 600;
    font-size: 0.75rem;
}

.profile-nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.profile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    text-decoration: none;
    font-weight: 600;
    color: #1f2937;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.2s ease;
}

.profile-nav-link i {
    font-size: 1.05rem;
    color: #2563eb;
}

.profile-nav-link:hover {
    transform: translateX(4px);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 12px 25px rgba(59, 130, 246, 0.15);
}

.profile-nav-link.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(79, 70, 229, 0.24));
    color: #0f172a;
    border-color: transparent;
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.25);
}

.profile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.profile-form .form-group {
    margin-bottom: 1.15rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.avatar-upload {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.avatar-preview {
    width: 160px;
    height: 160px;
    border-radius: 1.25rem;
    background: rgba(226, 232, 240, 0.8);
    border: 1px dashed rgba(148, 163, 184, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-preview .avatar-placeholder {
    font-size: 2.4rem;
    font-weight: 700;
    color: #2563eb;
}

.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.upload-label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    background: #22c55e;
    color: #fff;
    border-radius: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 12px 24px rgba(34, 197, 94, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.upload-label:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(34, 197, 94, 0.32);
}

.upload-label input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-label span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.form-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

select option.role-edit-option {
    font-style: italic;
    color: #475467;
}

body.messenger-page .messenger-page-card {
    padding: 0;
    background: transparent;
    box-shadow: none;
}

body.messenger-page .messenger-page-wrapper {
    border-radius: 32px;
    overflow: hidden;
    background: var(--card-bg, #ffffff);
    min-height: calc(100vh - 220px);
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.1);
    border: 1px solid rgba(15, 23, 42, 0.05);
}

body.messenger-page #messengerOverlay {
    display: none !important;
}

body.messenger-page .messenger-container.messenger-page-view {
    position: relative;
    transform: none;
    width: 100%;
    height: 100%;
    box-shadow: none;
    border-left: none;
    background: linear-gradient(135deg, #0f8c6c, #0b7564 55%, #066a5a);
}

body.messenger-page .messenger-container.messenger-page-view .messenger-window {
    height: 100%;
    border-radius: 0;
}

body.messenger-page .messenger-container.messenger-page-view .messenger-content {
    height: calc(100% - 72px);
    display: flex;
    background: transparent;
    flex-direction: row;
}

body.messenger-page #messengerFloatBtn,
body.messenger-page #messengerClose {
    display: none !important;
}

body.messenger-page .messenger-header {
    border-radius: 0;
    box-shadow: none;
}

body.messenger-page .messenger-conversations {
    width: 330px;
    max-width: 330px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    background: transparent;
}

body.messenger-page .messenger-conversations .conversations-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

body.messenger-page #messengerChat {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: #f8fafc;
    border-top-left-radius: 24px;
    height: 800px;
}

body.messenger-page .messenger-chat .chat-header {
    background: #f8fafc;
    border-top-left-radius: 24px;
}

body.messenger-page .messenger-chat .chat-messages {
    background: #ffffff;
    border-radius: 12px;
    margin: 0 1rem 1rem;
    padding: 1rem;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

body.messenger-page .messenger-chat .chat-input-container {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fafc;
}

body.messenger-page .messenger-users,
body.messenger-page .messenger-call-history {
    width: 330px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

body.messenger-page .topbar .messenger-toggle-top {
    display: none !important;
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    flex: 1;
    padding-right: 2.5rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: #475467;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:focus {
    outline: none;
}


.user-management-users .user-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.user-management-users .user-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(248, 250, 252, 0.98);
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.7);
    padding: 0.55rem 0.75rem 0.55rem 1rem;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.user-management-users .user-search i {
    color: var(--text-secondary);
}

.user-management-users .user-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
}

.user-management-users .user-search i {
    color: var(--text-secondary);
}

.user-management-users .search-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: rgba(34, 197, 94, 0.2);
    color: #15a34a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
}

.user-management-users .user-top-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-management-users .icon-btn {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: none;
    background: rgba(34, 197, 94, 0.18);
    color: #15803d;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.user-card-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    align-items: stretch;

}

.user-card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 1.35rem;
    padding: 1.2rem 1.1rem;
    border: 1px solid rgba(226, 232, 240, 0.7);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 220px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.user-card:hover {
    transform: translateY(-6px);
    border-color: rgba(59, 130, 246, 0.35);
    box-shadow: 0 20px 44px rgba(59, 130, 246, 0.18);
}

.user-card .card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.75rem;
}

.role-pill.role-customer {
    background: rgba(22, 163, 74, 0.18);
    color: #166534;
}

.role-pill.role-staff {
    background: rgba(59, 130, 246, 0.18);
    color: #1d4ed8;
}

.role-pill.role-admin {
    background: rgba(147, 51, 234, 0.18);
    color: #6b21a8;
}

.card-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status-pill {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    background: rgba(34, 197, 94, 0.18);
    color: #15803d;
    cursor: pointer;
}

.ellipsis-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: rgba(226, 232, 240, 0.9);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.75);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
    min-width: 140px;
    padding: 0.5rem 0;
    display: none;
    z-index: 20;
}

.dropdown-menu a,
.dropdown-menu button {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    display: block;
}

.dropdown-menu a:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
}

.dropdown-menu .dropdown-danger {
    color: #b91c1c;
}

.dropdown-menu .dropdown-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.dropdown-menu.open {
    display: block;
}

.card-body {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.card-avatar {
    width: 78px;
    height: 78px;
    border-radius: 999px;
    overflow: hidden;
    border: 4px solid rgba(34, 197, 94, 0.16);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    background: linear-gradient(180deg, rgba(243, 244, 246, 0.88), rgba(226, 232, 240, 0.92));
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-avatar .avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
    position: absolute;
    inset: 0;
    z-index: 2;
}

.card-avatar .avatar-initials {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    border-radius: 50%;
    z-index: 1;
    transition: transform 0.15s ease;
}

.card-avatar:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(34, 197, 94, 0.22);
}

.card-body h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-body .email {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.card-meta span:first-child i {
    color: #ef4444;
}

.card-meta span:last-child i {
    color: #2563eb;
}

.create-card {
    text-decoration: none;
    border: 2px dashed rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.create-card:hover {
    transform: translateY(-4px);
    border-color: rgba(34, 197, 94, 0.55);
    box-shadow: 0 24px 48px rgba(34, 197, 94, 0.16);
}

.create-card .create-inner {
    text-align: center;
    color: #1d4ed8;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-items: center;
}

.create-card .plus-icon {
    font-size: 2.4rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: rgba(59, 130, 246, 0.18);
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.6);
}

.create-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.create-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.role-pill.role-default {
    background: rgba(148, 163, 184, 0.2);
    color: #475569;
}

.status-pill.active {
    background: rgba(16, 185, 129, 0.22);
    color: #047857;
}

.status-pill:not(.active) {
    background: rgba(239, 68, 68, 0.18);
    color: #b91c1c;
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
    transition: background-color 0.2s ease;
}

.switch-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    top: 3px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.15);
}

.switch input:checked+.switch-slider {
    background-color: rgba(16, 185, 129, 0.45);
}

.switch input:checked+.switch-slider::before {
    transform: translateX(22px);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem;
    border-radius: 1.5rem;
    border: 1px dashed rgba(148, 163, 184, 0.4);
    background: rgba(248, 250, 252, 0.8);
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .user-management-users .user-header {
        flex-direction: column;
        align-items: stretch;
    }

    .user-management-users .user-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 992px) {
    .profile-wrapper {
        flex-direction: column;
    }

    .profile-sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .profile-summary {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
        text-align: left;
    }

    .profile-summary-avatar {
        margin: 0;
    }

    .profile-nav {
        flex-direction: row;
    }
}

@media (max-width: 640px) {
    .profile-sidebar {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
    }

    .profile-nav {
        flex-direction: column;
    }

    .avatar-upload {
        flex-direction: column;
        align-items: stretch;
    }

    .avatar-preview {
        margin: 0 auto;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .btn {
        width: 100%;
    }
}

.main-content {
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 2rem;
    padding: 2.5rem 3rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 15px 40px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.6);
}

.content-panel {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 1.75rem;
    padding: 2rem;
    border: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.content-panel+.content-panel {
    margin-top: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.section-title i {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.12);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.85rem;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.3rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.875rem;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #34d399, #10b981);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(16, 185, 129, 0.25);
}

.btn-secondary {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
    border-radius: 0.75rem;
}

.btn-ghost:hover {
    color: #0ea5e9;
    border-color: rgba(14, 165, 233, 0.55);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-link {
    background: none;
    color: var(--primary-color);
    padding: 0;
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 0.5rem;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.dashboard-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tables */
.table-container {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 1.5rem;
    box-shadow: 0 16px 35px rgba(15, 23, 42, 0.12);
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 400px);
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(226, 232, 240, 0.6);
    position: relative;
}


.data-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* Ensure tables with fixed layout can expand beyond container when needed */
.data-table[style*="table-layout: fixed"] {
    min-width: 100%;
}

/* Ensure table cells don't collapse */
.data-table td,
.data-table th {
    min-width: 0;
}

.data-table thead {
    background: rgba(241, 245, 249, 0.85);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
}

.data-table td {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: rgba(241, 245, 249, 0.6);
}

/* Tabs */
.tabs {
    display: inline-flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.6rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.tab {
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: rgba(15, 23, 42, 0.55);
    font-weight: 600;
    border-radius: 1.2rem;
    transition: all 0.2s;
}

.tab:hover {
    color: #0ea5e9;
}

.tab.active {
    color: #0f172a;
    background: rgba(14, 165, 233, 0.15);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0.9rem;
    font-size: 0.95rem;
    background: rgba(248, 250, 252, 0.94);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(34, 197, 94, 0.55);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    transform: translateY(-1px);
}

.form-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.link-btn {
    background: none;
    border: none;
    color: #2563eb;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.link-btn:hover {
    text-decoration: underline;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-box {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header i {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

.login-form {
    margin-top: 2rem;
}

.auth-links {
    margin-top: 1.5rem;
    text-align: center;
}

.auth-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.auth-link:hover {
    text-decoration: underline;
}

.reset-link-hint {
    margin-top: 1rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 15, 24, 0.55);
    backdrop-filter: blur(6px);
    padding: 1.5rem;
    overflow: auto;
    align-items: center;
    justify-content: center;
}

/* Group call member modal - higher z-index to appear above messenger */
#groupCallMemberModal {
    z-index: 10010 !important;
}

@media (max-width: 768px) {

    /* In mobile view, ensure group call modal appears above messenger */
    #groupCallMemberModal {
        z-index: 10010 !important;
        position: fixed !important;
    }

    #groupCallMemberModal[style*="display: block"],
    #groupCallMemberModal[style*="display:flex"] {
        display: flex !important;
    }

    #groupCallMemberModal .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        width: calc(100% - 2rem);
        max-width: 500px;
    }
}

.modal.open {
    display: flex;
}

body.modal-open {
    overflow: hidden;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 1.25rem;
    width: min(600px, 100%);
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(226, 232, 240, 0.6);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3rem);
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
}

.close,
.modal-close {
    color: var(--text-secondary);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover,
.modal-close:hover {
    color: var(--text-primary);
}

.modal form,
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Group creation modal refinements */
#createGroupModal .modal-content {
    width: min(520px, calc(100vw - 2rem));
    border-radius: 1.5rem;
    border: 1px solid rgba(15, 70, 55, 0.08);
    box-shadow: 0 30px 65px rgba(15, 70, 55, 0.18);
    background: linear-gradient(180deg, #ffffff 0%, #f6f9fb 100%);
}

#createGroupModal .modal-header {
    border-bottom: none;
    padding-bottom: 0.5rem;
}

#createGroupModal .modal-header h3 {
    font-size: 1.35rem;
    font-weight: 600;
    color: #0f172a;
}

#createGroupModal .modal-body {
    padding-top: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#createGroupModal .form-group label {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.35rem;
}

#createGroupModal .form-control {
    border-radius: 0.95rem;
    padding: 0.85rem 1rem;
    border: 1px solid #dbe4ea;
    background: #f8fafc;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

#createGroupModal .form-control:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
    background: #fff;
}

#createGroupModal .group-members-search {
    margin-bottom: 0.75rem;
}

#createGroupModal .group-members-list {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: white;
    max-height: 320px;
    box-shadow: inset 0 1px 4px rgba(15, 23, 42, 0.05);
}

#createGroupModal .group-member-item {
    padding: 0.65rem 1rem;
}

#createGroupModal .group-member-item:hover {
    background: #f8fafc;
}

#createGroupModal .group-member-item.selected {
    background: rgba(34, 197, 94, 0.08);
}

#createGroupModal .group-member-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

#createGroupModal .group-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

#createGroupModal .group-member-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: #22c55e;
}

#createGroupModal .selected-members {
    border-radius: 1rem;
    background: #fff;
    border: 1px dashed rgba(34, 197, 94, 0.35);
    padding: 0.85rem 1rem;
    min-height: 56px;
}

#createGroupModal .selected-member-tag {
    background: rgba(34, 197, 94, 0.12);
    color: #065f46;
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

#createGroupModal .remove-member-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#createGroupModal .modal-footer {
    border-top: none;
    padding-top: 0;
    gap: 0.75rem;
}

#createGroupModal .btn-secondary {
    background: rgba(100, 116, 139, 0.12);
    color: #0f172a;
    border: none;
}

#createGroupModal .btn-primary {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    min-width: 140px;
}

#createGroupModal .btn-primary:disabled {
    opacity: 0.6;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-in_progress {
    background: #dbeafe;
    color: #1e40af;
}

.badge-completed {
    background: #d1fae5;
    color: #065f46;
}

.badge-new {
    background: #2563eb;
    color: #ffffff;
}

.badge-today_focus {
    background: #f97316;
    color: #ffffff;
}

.badge-followup {
    background: #22c55e;
    color: #ffffff;
}

.badge-converted {
    background: #10b981;
    color: #ffffff;
}

.badge-lost {
    background: #6b7280;
    color: #ffffff;
}

.status-text {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Utilities */
.page-actions {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-item {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.task-title {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.task-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notification-item {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.notification-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.notification-column {
    flex: 1 1 360px;
}

.notification-list-full {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notification-item-full {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.notification-item-full {
    justify-content: space-between;
}

.notification-item-full.unread {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
}

.notification-item-full.history {
    opacity: 0.85;
}

.notification-item-full .notification-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.notification-item-full .notification-content {
    flex: 1;
}

.notification-item-full .notification-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.notification-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.notification-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Lead Dashboard */
.lead-dashboard .lead-insights-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.lead-dashboard .dashboard-card.large {
    grid-column: span 2;
}

.lead-dashboard .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.lead-dashboard .card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lead-dashboard .lead-funnel {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.lead-dashboard .funnel-item {
    flex: 1 1 120px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.lead-dashboard .funnel-item.success {
    border-color: #10b981;
}

.lead-dashboard .funnel-item.muted {
    opacity: 0.8;
}

.lead-dashboard .funnel-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.lead-dashboard .funnel-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.lead-dashboard .trend-table table,
.lead-dashboard .list-table table {
    width: 100%;
    border-collapse: collapse;
}

.lead-dashboard .trend-table th,
.lead-dashboard .trend-table td,
.lead-dashboard .list-table th,
.lead-dashboard .list-table td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.lead-dashboard .trend-table tr:last-child td,
.lead-dashboard .list-table tr:last-child td {
    border-bottom: none;
}

.lead-dashboard .list-table .empty-state {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-secondary);
}

.lead-dashboard .payment-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.lead-dashboard .payment-card {
    border-radius: 0.75rem;
    padding: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.lead-dashboard .payment-card.highlight {
    border-color: var(--primary-color);
}

.lead-dashboard .payment-card.warning {
    border-color: #f97316;
}

.lead-dashboard .payment-card.info {
    border-color: #0ea5e9;
}

.lead-dashboard .payment-card .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.lead-dashboard .payment-card .value {
    font-size: 1.4rem;
    font-weight: 600;
}

.lead-dashboard .conversion-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: auto;
    height: 490px;
}

.lead-dashboard .conversion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.lead-dashboard .conversion-item:last-child {
    border-bottom: none;
}

.lead-dashboard .conversion-item .meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.lead-dashboard .conversion-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-end;
    font-size: 0.85rem;
}

.lead-dashboard .card-footer {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .lead-dashboard .dashboard-card.large {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .lead-dashboard .lead-insights-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .lead-dashboard .dashboard-card {
        padding: 1.1rem;
    }

    .lead-dashboard .lead-funnel {
        flex-direction: column;
    }

    .lead-dashboard .payment-status-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .lead-dashboard .trend-table,
    .lead-dashboard .list-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .lead-dashboard .trend-table table,
    .lead-dashboard .list-table table {
        min-width: 520px;
    }

    .lead-dashboard .conversion-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .lead-dashboard .conversion-meta {
        align-items: flex-start;
        text-align: left;
    }
}

@media (max-width: 480px) {
    .lead-dashboard .lead-insights-grid {
        gap: 0.75rem;
    }

    .lead-dashboard .funnel-item {
        padding: 0.85rem;
    }

    .lead-dashboard .payment-card .value {
        font-size: 1.2rem;
    }

    .lead-dashboard .trend-table table,
    .lead-dashboard .list-table table {
        min-width: 460px;
    }
}

@media (max-width: 768px) {
    .lead-dashboard .lead-insights-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lead-dashboard .dashboard-card {
        padding: 1.1rem;
    }

    .lead-dashboard .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .lead-dashboard .lead-funnel {
        flex-direction: column;
    }

    .lead-dashboard .payment-status-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .lead-dashboard .trend-table,
    .lead-dashboard .list-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .lead-dashboard .trend-table table,
    .lead-dashboard .list-table table {
        min-width: 520px;
    }

    .lead-dashboard .conversion-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .lead-dashboard .conversion-meta {
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .lead-dashboard .lead-insights-grid {
        gap: 0.85rem;
    }

    .lead-dashboard .funnel-item {
        padding: 0.85rem;
    }

    .lead-dashboard .payment-card .value {
        font-size: 1.25rem;
    }

    .lead-dashboard .trend-table table,
    .lead-dashboard .list-table table {
        min-width: 460px;
    }
}

/* Footer */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-top: 3rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Messenger Styles - WhatsApp-like Design */
.messenger-toggle {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    border: none;
    border-radius: 1rem;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
    transition: all 0.2s ease;
    position: relative;
}

.messenger-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(37, 211, 102, 0.4);
}

.messenger-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
    line-height: 1;
}


.messenger-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 440px;
    max-width: 100%;
    height: 100vh;
    z-index: 999;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #0f8c6c, #0b7564 55%, #066a5a);
    border-left: 1px solid #e4e6eb;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.messenger-container.floating {
    position: fixed !important;
    transform: none !important;
    top: 50px;
    right: auto;
    left: auto;
    max-width: 380px;
    height: 600px;
    border-left: none;
    border-radius: 18px;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.25);
    z-index: 10005 !important;
    cursor: default;
    display: block !important;
    visibility: visible !important;
}

.messenger-container.floating .messenger-window {
    border-radius: 18px;
    height: 100%;
    position: relative;
}

.messenger-container.floating .messenger-content {
    height: calc(100% - 72px);
    overflow: hidden;
}

.messenger-container.floating .messenger-conversations {
    height: 100%;
    overflow: hidden;
}

.messenger-container.floating .messenger-conversations .conversations-list {
    flex: 1;
    max-height: none;
    overflow-y: auto;
    padding-bottom: 0.75rem;
}

.messenger-container.floating .messenger-header {
    cursor: move;
    user-select: none;
}

.messenger-container.floating .messenger-header button {
    cursor: pointer;
}

.messenger-container.chat-active .messenger-header-brand {
    display: none !important;
}

.messenger-container.chat-active .messenger-header-left {
    gap: 0.5rem;
}

.messenger-resize-handle {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(15, 140, 108, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: nwse-resize;
    pointer-events: none;
    touch-action: none;
}

.messenger-resize-handle span {
    width: 12px;
    height: 12px;
    border-right: 2px solid #0f8c6c;
    border-bottom: 2px solid #0f8c6c;
    transform: rotate(0deg);
    pointer-events: none;
}

.messenger-container.floating .messenger-resize-handle {
    display: flex;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .messenger-container {
        width: 94vw;
        height: 60vh;
    }

    .messenger-container.floating {
        width: 92vw;
        max-width: 92vw;
        min-width: 260px;
        height: min(320px, 60vh) !important;
        left: 4vw !important;
    }

    .messenger-resize-handle {
        width: 32px;
        height: 32px;
    }

    .messenger-resize-handle span {
        width: 16px;
        height: 16px;
    }
}

.messenger-container.open {
    transform: translateX(0);
}

body.messenger-fullpage {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #e0e7ff, #f8fafc);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
}

body.messenger-fullpage #messengerOverlay {
    display: none !important;
}

body.messenger-fullpage #messengerContainer {
    position: relative;
    top: 0;
    right: 0;
    left: 0;
    width: min(100%, 1100px);
    transform: none;
    border-left: none;
    border-radius: 24px;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}

body.messenger-fullpage .messenger-window {
    border-radius: 24px;
    height: 85vh;
    max-height: 900px;
}

body.messenger-fullpage .messenger-content {
    height: calc(100% - 72px);
}

body.messenger-fullpage .messenger-header-actions .messenger-popout {
    display: none;
}

/* Messenger Overlay */
.messenger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
    display: none;
    opacity: 0;
    /* Prevent invisible overlay from blocking page interactions */
    pointer-events: none;
    transition: opacity 0.3s ease, display 0.3s ease;
}

.messenger-overlay.active {
    display: block;
    opacity: 1;
    /* Allow interactions only when overlay is active */
    pointer-events: auto;
}

/* Prevent messenger container from blocking interactions when closed */
.messenger-container {
    /* By default don't intercept pointer events unless explicitly open */
    pointer-events: none;
}
.messenger-container.open {
    pointer-events: auto;
}

/* Messenger Mobile Styles */
@media (max-width: 768px) {
    .messenger-container {
        width: 100%;
        border-left: none;
        z-index: 10000;
    }

    .messenger-overlay {
        z-index: 9999;
        background: rgba(0, 0, 0, 0.6);
    }

    .messenger-header {
        padding: 0.875rem 1rem;
        min-height: 56px;
    }

    .messenger-header h3 {
        font-size: 1rem;
    }

    .messenger-back,
    .messenger-close {
        font-size: 1.1rem;
        padding: 0.4rem;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        z-index: 1000 !important;
        pointer-events: auto !important;
        touch-action: manipulation;
        cursor: pointer;
        position: relative;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
    }

    /* Force back button to be visible on mobile when chat is active */
    .messenger-header-left {
        gap: 0.5rem !important;
    }

    .messenger-header-left .messenger-back {
        display: flex !important;
        margin-right: 0.5rem;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 100 !important;
    }

    /* Show back button when chat view is displayed - mobile */
    .messenger-back.chat-active-back,
    #messengerChat[style*="flex"]~.messenger-header .messenger-back,
    .messenger-container:has(#messengerChat[style*="flex"]) .messenger-back {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Mobile-specific: Always show back button when chat is visible */
    @media (max-width: 768px) {

        /* Override any inline styles for back button on mobile */
        #messengerBack.chat-active-back,
        #messengerBack:not([style*="none"]) {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        /* Ensure back button shows when chat is displayed */
        body:has(#messengerChat[style*="flex"]) .messenger-back,
        .messenger-container:has(.messenger-chat[style*="flex"]) .messenger-back {
            display: flex !important;
            visibility: visible !important;
        }

        /* Standalone messenger page - show back button on mobile when chat is active */
        body.messenger-page .messenger-back.chat-active-back,
        body.messenger-page #messengerChat[style*="flex"]~.messenger-header .messenger-back,
        body.messenger-page .messenger-chat[style*="flex"]~* .messenger-back {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        /* Force back button visibility in standalone mode on mobile when chat is displayed */
        body.messenger-page #messengerChat[style*="flex"]+.messenger-header .messenger-back,
        body.messenger-page .messenger-container:has(#messengerChat[style*="flex"]) .messenger-back.chat-active-back {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
        }

        /* Show back button in standalone page when chat-active-back class is present */
        body.messenger-page .messenger-header-left .messenger-back.chat-active-back {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
        }
    }

    .messenger-search {
        padding: 0.5rem 0.875rem;
    }

    .messenger-search input {
        font-size: 0.875rem;
        padding: 0.5rem 0.875rem;
    }

    .conversation-item,
    .user-item {
        padding: 0.625rem 0.875rem;
        min-height: 64px;
        gap: 0.625rem;
    }

    .conversation-avatar,
    .user-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
    }

    .conversation-name,
    .user-name {
        font-size: 0.9375rem;
    }

    .conversation-preview {
        font-size: 0.8125rem;
    }

    .conversation-time {
        font-size: 0.6875rem;
    }

    .conversation-unread {
        min-width: 18px;
        height: 18px;
        font-size: 0.65rem;
        padding: 0 0.3rem;
    }

    .messenger-action-buttons {
        bottom: 0.75rem;
        right: 0.75rem;
        gap: 0.625rem;
    }

    .messenger-new-chat,
    .messenger-new-group {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }

    .chat-header {
        padding: 0.75rem 1rem;
        min-height: 56px;
    }

    .chat-user-info {
        gap: 0.625rem;
    }

    .chat-user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .chat-user-name {
        font-size: 0.9375rem;
    }

    .chat-user-status {
        font-size: 0.75rem;
    }

    .chat-messages {
        padding: 0.75rem 0.875rem;
    }

    .message {
        max-width: 85%;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
    }

    .message-bubble {
        font-size: 0.875rem;
        line-height: 1.4;
    }

    .message-time {
        font-size: 0.6875rem;
        margin-top: 0.25rem;
    }

    .chat-input-container {
        padding: 0.625rem 0.875rem;
        gap: 0.625rem;
    }

    .chat-input {
        font-size: 0.9375rem;
        padding: 0.625rem 0.875rem;
        max-height: 120px;
    }

    .chat-send-btn,
    .chat-attachment-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .chat-voice-call-btn,
    .chat-video-call-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .reply-preview,
    .edit-preview {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .message-context-menu {
        min-width: 160px;
        font-size: 0.875rem;
    }

    .context-menu-item {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    .typing-indicator {
        padding: 0.5rem 0.875rem;
    }

    .typing-dots {
        width: 6px;
        height: 6px;
    }

    .call-interface {
        padding: 1rem;
    }

    .call-avatar {
        width: 120px;
        height: 120px;
        font-size: 3rem;
    }

    .call-controls {
        gap: 1rem;
    }

    .call-control-btn {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    .call-history-sidebar {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid #e9edef;
        padding: 0.5rem;
        overflow-x: auto;
    }

    .call-history-type-filter {
        flex-direction: row;
        padding: 0.75rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        min-width: 80px;
    }

    .call-history-type-filter.active {
        border-left: none;
        border-bottom-color: #25d366;
    }

    .call-history-time-filters {
        padding: 0.625rem 0.875rem;
        gap: 0.5rem;
    }

    .call-history-time-filter {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    .call-history-item {
        padding: 0.75rem 0.875rem;
    }

    .call-history-avatar {
        width: 48px;
        height: 48px;
    }

    .call-history-name {
        font-size: 0.875rem;
    }

    .call-history-details {
        font-size: 0.75rem;
    }

    .group-members-list {
        max-height: 250px;
    }

    .group-member-item {
        padding: 0.625rem 0.875rem;
    }

    .group-member-avatar {
        width: 36px;
        height: 36px;
    }

    .group-member-name {
        font-size: 0.875rem;
    }

    .group-member-username {
        font-size: 0.75rem;
    }

    .messenger-header {
        padding: 0.9rem 1.1rem;
        border-radius: 1rem 1rem 0 0;
    }

    .messenger-header-brand {
        gap: 0.6rem;
    }

    .messenger-header-icon {
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
    }

    .messenger-header-action {
        padding: 0.4rem;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
    }

    .messenger-header-action span {
        display: none;
    }

    /* Touch-friendly improvements */
    .conversation-item,
    .user-item {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
    }

    .chat-send-btn,
    .chat-attachment-btn,
    .messenger-back,
    .messenger-close {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
        min-width: 44px;
        min-height: 44px;
    }

    /* Prevent text selection on mobile */
    .conversation-item,
    .user-item,
    .message {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Better scrolling on mobile */
    .conversations-list,
    .users-list,
    .chat-messages,
    .call-history-list {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Safe area for notched devices */
    .messenger-container {
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .messenger-header {
        padding-top: max(0.875rem, calc(0.875rem + env(safe-area-inset-top, 0)));
    }
}

@media (max-width: 480px) {
    .messenger-header {
        padding: 0.75rem 0.875rem;
        padding-top: max(0.75rem, calc(0.75rem + env(safe-area-inset-top, 0)));
    }

    .messenger-header h3 {
        font-size: 0.9375rem;
    }

    .messenger-header-subtitle {
        font-size: 0.78rem;
    }

    .messenger-header-icon,
    .messenger-header-action,
    .messenger-header-icon-btn {
        width: 36px;
        height: 36px;
    }

    .conversation-item,
    .user-item {
        padding: 0.5rem 0.75rem;
        min-height: 60px;
    }

    .conversation-avatar,
    .user-avatar {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .conversation-name,
    .user-name {
        font-size: 0.875rem;
    }

    .conversation-preview {
        font-size: 0.75rem;
    }

    .message {
        max-width: 90%;
        padding: 0.5rem 0.625rem;
    }

    .message-bubble {
        font-size: 0.8125rem;
    }

    .chat-input-container {
        padding: 0.5rem 0.75rem;
    }

    .chat-input {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .messenger-new-chat,
    .messenger-new-group {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .messenger-action-buttons {
        bottom: 0.625rem;
        right: 0.625rem;
        gap: 0.5rem;
    }

    .call-avatar {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .call-control-btn {
        width: 52px;
        height: 52px;
        font-size: 1.15rem;
    }

    .call-history-time-filters {
        padding: 0.5rem 0.75rem;
    }

    .call-history-time-filter {
        padding: 0.3125rem 0.625rem;
        font-size: 0.75rem;
    }
}

/* Dashboard mobile adjustments */
@media (max-width: 768px) {
    .topbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .topbar-inner {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .app-content {
        padding: 0.75rem;
    }

    .app-content-inner {
        padding: 1.25rem;
        border-radius: 1rem;
    }

    .dashboard {
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .stat-card {
        padding: 0.85rem;
        gap: 0.65rem;
        border-radius: 0.7rem;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .stat-content h3 {
        font-size: 1.25rem;
    }

    .stat-content p {
        font-size: 0.78rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-card {
        padding: 1.1rem;
    }

    .task-item,
    .notification-item {
        padding: 0.85rem 0.6rem;
    }

    .btn.btn-link {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
        gap: 0.45rem;
    }

    .dashboard-card h2 {
        font-size: 1.1rem;
    }

    .task-item,
    .notification-item {
        padding: 0.75rem 0.5rem;
    }

    .stat-content h3 {
        font-size: 1.12rem;
    }

    .topbar-inner {
        gap: 0.5rem;
    }
}

/* Lead dashboard mobile fixes */
@media (max-width: 768px) {
    .lead-dashboard .lead-insights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .lead-dashboard .dashboard-card {
        padding: 0.9rem;
    }

    .lead-dashboard .lead-funnel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .lead-dashboard .payment-status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .lead-dashboard .funnel-item,
    .lead-dashboard .payment-card {
        padding: 0.7rem;
    }

    .lead-dashboard .funnel-label,
    .lead-dashboard .payment-card .label {
        font-size: 0.7rem;
    }

    .lead-dashboard .funnel-value,
    .lead-dashboard .payment-card .value {
        font-size: 1.05rem;
    }

    .lead-dashboard .trend-table,
    .lead-dashboard .list-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .lead-dashboard .trend-table table,
    .lead-dashboard .list-table table {
        min-width: 100%;
    }

    .lead-dashboard .conversion-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .lead-dashboard .conversion-meta {
        align-items: flex-start;
        text-align: left;
    }

    .lead-management-card {
        padding: 1rem;
    }

    .lead-management-card .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.7rem;
    }

    .lead-management-card .section-actions {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 0.5rem;
    }

    .lead-management-card .section-actions .btn {
        flex: 1 1 calc(50% - 0.5rem);
        justify-content: center;
    }

    .lead-management-card .tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .lead-management-card .tabs .tab {
        flex: 1 1 calc(50% - 0.4rem);
        text-align: center;
        font-size: 0.85rem;
        padding: 0.45rem 0.5rem;
    }

    .lead-management-card .table-container {
        width: 100%;
        overflow-x: auto;
        overflow-y: auto;
        max-height: calc(100vh - 300px);
        -webkit-overflow-scrolling: touch;
    }

    .lead-management-card .data-table {
        min-width: 520px;
    }

    .subscription-card {
        padding: 1rem;
        border-radius: 1rem;
    }

    .subscription-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .subscription-tabs .tab {
        flex: 1 1 calc(50% - 0.45rem);
        text-align: center;
        font-size: 0.85rem;
        padding: 0.45rem 0.5rem;
    }

    .subscription-card .table-container {
        width: calc(100% + 1rem);
        margin: 0 -0.5rem;
        overflow-x: auto;
        overflow-y: auto;
        max-height: calc(100vh - 300px);
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    .subscription-card .data-table {
        min-width: 600px;
    }
}

@media (max-width: 480px) {

    .lead-dashboard .lead-insights-grid,
    .lead-dashboard .lead-funnel,
    .lead-dashboard .payment-status-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
        gap: 0.45rem;
    }

    .lead-dashboard .dashboard-card h2 {
        font-size: 1.05rem;
    }

    .lead-dashboard .payment-card .value {
        font-size: 1.15rem;
    }

    .lead-management-card .section-actions .btn {
        flex: 1 1 100%;
    }

    .lead-management-card .tabs {
        gap: 0.35rem;
    }

    .lead-management-card .tabs .tab {
        flex: 1 1 48%;
        font-size: 0.8rem;
    }

    .lead-management-card .table-container {
        margin: 0 -0.4rem;
    }

    .subscription-tabs {
        gap: 0.35rem;
    }

    .subscription-tabs .tab {
        flex: 1 1 48%;
        font-size: 0.8rem;
    }

    .subscription-card .table-container {
        width: calc(100% + 0.8rem);
        margin: 0 -0.4rem;
        padding-bottom: 0.4rem;
    }
}

@media (max-width: 360px) {

    .stats-grid,
    .lead-dashboard .lead-insights-grid,
    .lead-dashboard .lead-funnel,
    .lead-dashboard .payment-status-grid {
        grid-template-columns: 1fr;
    }

    .lead-management-card .tabs .tab {
        flex: 1 1 100%;
    }

    .subscription-tabs .tab {
        flex: 1 1 100%;
    }

    .subscription-card .table-container {
        width: 100%;
        margin: 0;
    }
}

/* ============================================
   APP-WIDE MOBILE RESPONSIVE STYLES
   ============================================ */

/* Hide mobile menu toggle on desktop */
.mobile-menu-toggle {
    display: none;
}

/* Tablet and below (992px) */
@media (max-width: 992px) {
    .app-layout {
        grid-template-columns: 260px 1fr;
    }

    .app-content {
        padding: 1.5rem;
    }

    .app-content-inner {
        padding: 2rem;
        border-radius: 1.5rem;
    }

    .sidebar {
        padding: 1.5rem 1.25rem;
        gap: 1.5rem;
    }

    .sidebar-link {
        padding: 0.75rem 0.875rem;
        font-size: 0.9rem;
    }

    .sidebar-link .icon-pill {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .main-content h1 {
        font-size: 1.75rem;
    }

    .content-card {
        padding: 1.5rem;
        border-radius: 1.25rem;
    }

    .topbar {
        padding-bottom: 1rem;
        margin-bottom: 1.25rem;
    }

    .topbar-inner {
        gap: 1rem;
    }
}

/* Mobile landscape and below (768px) */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
        position: relative;
    }

    .app-layout {
        grid-template-columns: 1fr;
        position: relative;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        max-height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
        overflow-x: hidden;
        padding-top: calc(1rem + env(safe-area-inset-top, 0));
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
        box-sizing: border-box;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-nav-scroll {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        flex: 1 1 0;
        min-height: 0;
        padding-right: 12px;
        margin-right: -4px;
        padding-bottom: 5rem;
        box-sizing: border-box;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .app-content {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .app-content-inner {
        padding: 1.5rem;
        border-radius: 1.25rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .topbar {
        padding-bottom: 0.875rem;
        margin-bottom: 1rem;
        position: sticky;
        top: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        z-index: 100;
        padding-top: calc(0.5rem + env(safe-area-inset-top, 0));
    }

    .topbar-inner {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .main-content h1 {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
    }

    .content-card {
        padding: 1.25rem;
        border-radius: 1rem;
        margin-bottom: 1.25rem;
    }

    .section-title {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .page-actions {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .page-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .tabs {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.375rem;
    }

    .tabs .tab {
        padding: 0.4375rem 1rem;
        font-size: 0.875rem;
    }

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        cursor: pointer;
        padding: 0;
        margin-right: 0.75rem;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
    }

    .mobile-menu-toggle i {
        font-size: 1.25rem;
        color: var(--text-primary);
    }

    .mobile-menu-toggle:hover {
        background: #f1f5f9;
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    /* Sidebar adjustments */
    .sidebar-brand {
        font-size: 0.85rem;
    }

    .brand-logo-wrapper {
        width: 60px;
        height: 60px;
    }

    .sidebar-link {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
        gap: 0.75rem;
        max-width: 100%;
        box-sizing: border-box;
    }

    .sidebar-link:hover {
        transform: none;
        /* Disable translateX on mobile to prevent overflow */
    }

    .sidebar-link .icon-pill {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    .sidebar-sublink {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        margin-left: 2.5rem;
        max-width: calc(100% - 2.5rem);
        box-sizing: border-box;
    }

    .sidebar-sublink:hover {
        transform: none;
        /* Disable translateX on mobile */
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
        display: block;
    }

    table {
        font-size: 0.875rem;
        min-width: 600px;
        width: 100%;
        max-width: 100%;
    }

    table th,
    table td {
        padding: 0.625rem 0.5rem;
        font-size: 0.8125rem;
    }

    /* Prevent horizontal overflow from all elements */
    * {
        max-width: 100%;
    }

    img,
    video,
    iframe,
    embed,
    object {
        max-width: 100%;
        height: auto;
    }

    /* Ensure all containers respect viewport */
    .main-content,
    .content-card,
    .card,
    .form-group,
    .form-control,
    .btn,
    .topbar,
    .topbar-inner {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Fix any elements that might cause overflow */
    .page-actions {
        flex-wrap: wrap;
        max-width: 100%;
    }

    .tabs {
        max-width: 100%;
        flex-wrap: wrap;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control {
        font-size: 0.9375rem;
        padding: 0.625rem 0.875rem;
    }

    label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }

    /* Buttons */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
        min-height: 44px;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
        min-height: 40px;
    }

    /* Cards and grids */
    .card {
        padding: 1rem;
        border-radius: 1rem;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* User dropdown */
    .user-toggle {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .messenger-toggle-top {
        padding: 0.5rem 0.75rem;
    }

    .messenger-icon-wrapper {
        width: 28px;
        height: 28px;
    }

    .messenger-icon-chat {
        font-size: 1rem;
    }

    .messenger-icon-call {
        font-size: 0.85rem;
        width: 18px;
        height: 18px;
    }
}

/* Small mobile (480px and below) */
@media (max-width: 480px) {

    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .app-content {
        padding: 0.75rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .app-content-inner {
        padding: 1rem;
        border-radius: 1rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .sidebar {
        width: 100%;
        max-width: 85vw;
    }

    .topbar {
        padding: 0.75rem 0.5rem;
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0));
    }

    .topbar-inner {
        gap: 0.5rem;
    }

    .main-content h1 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .content-card {
        padding: 1rem;
        border-radius: 0.875rem;
        margin-bottom: 1rem;
    }

    .section-title {
        font-size: 0.9375rem;
    }

    .sidebar-link {
        padding: 0.625rem 0.75rem;
        font-size: 0.8125rem;
    }

    .sidebar-link .icon-pill {
        width: 32px;
        height: 32px;
        font-size: 0.9375rem;
    }

    .form-control {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }

    .tabs .tab {
        padding: 0.375rem 0.875rem;
        font-size: 0.8125rem;
    }

    .user-toggle {
        padding: 0.4375rem 0.625rem;
        font-size: 0.8125rem;
    }

    .messenger-toggle-top {
        padding: 0.4375rem 0.625rem;
    }

    .brand-logo-wrapper {
        width: 52px;
        height: 52px;
    }

    table {
        font-size: 0.75rem;
    }

    table th,
    table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }
}

.messenger-window {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    border-radius: 0;
}

.messenger-header {
    position: relative;
    background: linear-gradient(135deg, #0f8c6c, #0b7564 55%, #066a5a);
    color: white;
    padding: 1.1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 30px rgba(5, 60, 50, 0.35);
    border-radius: 1.25rem 1.25rem 0 0;
    overflow: hidden;
}

.messenger-header::after {
    content: '';
    position: absolute;
    right: -60px;
    top: -60px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 70%);
    opacity: 0.55;
}

.messenger-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.messenger-header-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.messenger-header-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: white;
    box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), inset 0 -2px 6px rgba(0, 0, 0, 0.15);
}

.messenger-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.messenger-back,
.messenger-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
}

.messenger-back:hover,
.messenger-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.messenger-back:active,
.messenger-close:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.messenger-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.messenger-header-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

.messenger-header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    position: relative;
    z-index: 1;
}

.messenger-header-action {
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.35), 0 6px 15px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.messenger-header-action i {
    font-size: 1rem;
}

.messenger-header-action:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: translateY(-1px);
}

.messenger-header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.messenger-header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.messenger-header-icon-btn.active {
    background: rgba(37, 99, 235, 0.35);
    color: #fff;
}

.messenger-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
}

.messenger-search {
    padding: 0.625rem 1rem;
    background: white;
    border-bottom: 1px solid #e4e6eb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.messenger-search i {
    color: #667781;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.messenger-search input {
    flex: 1;
    border: none;
    outline: none;
    background: #f0f2f5;
    padding: 0.625rem 1rem;
    border-radius: 1.5rem;
    font-size: 0.9rem;
    color: #111b21;
    transition: background 0.2s;
    min-width: 0;
}

.messenger-search input:focus {
    background: #e9edef;
}

.messenger-search input::placeholder {
    color: #667781;
    opacity: 0.8;
}

.messenger-conversations,
.messenger-users {
    flex: 1;
    overflow: hidden;
    background: white;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.conversations-list,
.users-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 0;
}

.conversation-item,
.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.2s;
    min-height: 72px;
    flex-shrink: 0;
}

.conversation-item:hover,
.user-item:hover {
    background: #f5f6f6;
}

.conversation-item.active {
    background: #e9edef;
    border-left: 4px solid #ff9500;
    padding-left: calc(1rem - 4px);
}

.conversation-avatar,
.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    background: #dfe5e9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #667781;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.conversation-avatar img,
.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conversation-info,
.user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.125rem;
}

.conversation-name,
.user-name {
    font-weight: 600;
    font-size: 1rem;
    color: #111b21;
    margin: 0;
    line-height: 1.3;
}

.conversation-preview {
    font-size: 0.875rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.3;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
    justify-content: center;
}

.conversation-meta-top {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.conversation-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.conversation-menu-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.conversation-menu-btn:hover {
    background: rgba(148, 163, 184, 0.18);
    color: #0f172a;
}

.conversation-time {
    font-size: 0.75rem;
    color: #667781;
    white-space: nowrap;
    margin: 0;
}

.conversation-unread {
    background: #25d366;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0 0.35rem;
}

.messenger-action-buttons {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.75rem;
    z-index: 10;
}

.messenger-new-chat,
.messenger-new-group {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.messenger-new-group {
    background: linear-gradient(135deg, #667781, #54656f);
    box-shadow: 0 4px 12px rgba(102, 119, 129, 0.4);
}

.messenger-new-chat:hover,
.messenger-new-group:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5);
}

.messenger-new-group:hover {
    box-shadow: 0 6px 16px rgba(102, 119, 129, 0.5);
}

/* Group Conversation Styles */
.conversation-group .conversation-avatar {
    background: linear-gradient(135deg, #667781, #54656f);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-group .conversation-avatar i {
    font-size: 1.25rem;
}

.conversation-member-count {
    font-size: 0.75rem;
    color: #667781;
    font-weight: normal;
    margin-left: 0.5rem;
}

.conversation-member-count i {
    font-size: 0.6875rem;
}

/* Group Creation Modal Styles */
.group-members-search {
    margin-bottom: 0.75rem;
}

.group-members-list {
    border: 1px solid #e9edef;
    border-radius: 0.5rem;
    background: white;
    max-height: 300px;
    overflow-y: auto;
}

.group-member-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f2f5;
}

.group-member-item:last-child {
    border-bottom: none;
}

.group-member-item:hover {
    background: #f5f6f6;
}

.group-member-item.selected {
    background: #e9edef;
}

.group-member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #dfe5e9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.group-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.group-member-avatar-initial {
    font-size: 1rem;
    font-weight: 600;
    color: #54656f;
}

.group-member-info {
    flex: 1;
    min-width: 0;
}

.group-member-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-member-username {
    font-size: 0.8125rem;
    color: #667781;
}

.group-member-checkbox {
    flex-shrink: 0;
}

.group-member-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.selected-members {
    min-height: 40px;
}

.selected-member-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: #e9edef;
    border-radius: 1.5rem;
    font-size: 0.875rem;
    color: #111b21;
}

.remove-member-btn {
    background: none;
    border: none;
    color: #667781;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.remove-member-btn:hover {
    background: #c4c4c4;
    color: white;
}

/* Group Image Upload Styles */
.group-image-upload {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.group-image-preview {
    position: relative;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 2px solid #e9edef;
    background: #f0f2f5;
}

.group-image-preview img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.group-image-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: background 0.2s;
    z-index: 10;
}

.group-image-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

#groupImageSelectBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px dashed #c4c4c4;
    background: #f8f9fa;
    color: #667781;
    transition: all 0.2s;
}

#groupImageSelectBtn:hover {
    background: #e9edef;
    border-color: #25d366;
    color: #25d366;
}

.messenger-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #efeae2;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='grid' width='100' height='100' patternUnits='userSpaceOnUse'%3E%3Cpath d='M 100 0 L 0 0 0 100' fill='none' stroke='%23e5ddd5' stroke-width='1'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100' height='100' fill='url(%23grid)'/%3E%3C/svg%3E");
}

.chat-header {
    background: #f0f2f5;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    min-height: 60px;
    flex-shrink: 0;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-action-btn {
    background: none;
    border: none;
    color: #667781;
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover {
    background: #e9edef;
    color: #111b21;
}

.chat-action-btn:active {
    transform: scale(0.95);
}

.deleted-messages-controls {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ff9800;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-view-normal {
    background: white;
    color: #ff9800;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.btn-view-normal:hover {
    background: #f5f5f5;
}

.deleted-count-info {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.conversation-deleted-badge {
    background: #ff9800;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    margin-top: 0.25rem;
    transition: background 0.2s;
}

.conversation-deleted-badge:hover {
    background: #f57c00;
}

.conversation-item.has-deleted-messages {
    border-left: 3px solid #ff9800;
    background: #fffbf0;
}

.conversation-item.has-deleted-messages:hover {
    background: #fff3e0;
}

.message-deleted-view {
    opacity: 0.95;
}

.message-deleted-bubble {
    background: #fff3e0 !important;
    border: 1px solid #ff9800 !important;
}

.message-deleted-label {
    font-size: 0.75rem;
    color: #ff9800;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-deleted-info {
    font-size: 0.7rem;
    color: #ff9800;
    margin-top: 0.5rem;
    font-style: italic;
}

.message-original {
    color: #333 !important;
    font-style: italic;
}

.message-restore-btn-inline {
    background: #25d366;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    transition: background 0.2s;
}

.message-restore-btn-inline:hover {
    background: #20ba5a;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: #dfe5e9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #667781;
    flex-shrink: 0;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-user-details h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111b21;
}

.chat-user-details span {
    font-size: 0.8rem;
    color: #667781;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    scroll-behavior: smooth;
    align-items: stretch;
}

.message {
    display: flex;
    margin-bottom: 0.25rem;
    align-items: flex-end;
    gap: 0.4rem;
    position: relative;
    overflow: visible;
    max-width: 75%;
    animation: messageSlide 0.3s ease;
    width: fit-content;
    min-width: 0;
    flex-direction: column;
}

.message.sent {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    justify-content: flex-end;
}

.message.received {
    align-self: flex-start;
    margin-right: auto;
    margin-left: 0;
    justify-content: flex-start;
}

@media (max-width: 480px) {
    .message {
        max-width: 85%;
    }
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message:hover .message-actions {
    opacity: 1;
    visibility: visible;
}

/* Removed duplicate - moved above */

.message-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    min-width: 0;
    line-height: 1.4;
    flex-shrink: 1;
}

.message-bubble:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    padding: 0.25rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

.message.sent .message-actions {
    right: 100%;
    margin-right: 0.35rem;
}

.message.received .message-actions {
    left: 100%;
    margin-left: 0.35rem;
}

@media (max-width: 480px) {
    .message-actions {
        gap: 0.2rem;
    }

    .message.sent .message-actions {
        right: 100%;
        margin-right: 0.25rem;
    }

    .message.received .message-actions {
        left: 100%;
        margin-left: 0.25rem;
    }
}

.message-action-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #667781;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.message-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #111b21;
}

.message-action-btn i {
    font-size: 0.85rem;
}

.message-menu-wrapper {
    position: relative;
}

.message-menu-dropdown {
    position: absolute;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 150px;
    overflow: hidden;
    top: 100%;
    margin-top: 0.25rem;
}

.message.sent .message-menu-dropdown {
    right: 0;
}

.message.received .message-menu-dropdown {
    left: 0;
}

.message-menu-item {
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #111b21;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.message-menu-item:hover {
    background: #f0f2f5;
}

.message-menu-item i {
    width: 18px;
    color: #667781;
}

.message-menu-danger {
    color: #ef4444;
}

.message-menu-danger i {
    color: #ef4444;
}

.message-menu-danger:hover {
    background: #fee2e2;
}

.message-reply {
    border-left: 3px solid #25d366;
    padding-left: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(37, 211, 102, 0.1);
    border-radius: 0.25rem;
    padding: 0.4rem 0.6rem;
}

.message-reply-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #25d366;
    margin-bottom: 0.15rem;
}

.message-reply-text {
    font-size: 0.75rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-deleted {
    display: inline-flex;
    flex-direction: column;
    gap: 0.15rem;
    font-style: italic;
    color: #8d6e63;
    opacity: 0.9;
}

.message-deleted-label-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #ff9800;
    font-weight: 600;
}

.message-deleted-label-inline small {
    font-size: 0.7rem;
    color: #a66300;
    font-weight: 500;
}

.message-deleted-preview {
    font-size: 0.75rem;
    color: #a66300;
    font-style: italic;
}

.message-edited {
    font-size: 0.65rem;
    color: #667781;
    margin-left: 0.25rem;
}

.message.sent .message-bubble {
    background: #d9fdd3;
    border-bottom-right-radius: 0.25rem;
}

.message.received .message-bubble {
    background: white;
    border-bottom-left-radius: 0.25rem;
}

.message-text {
    font-size: 0.9375rem;
    color: #111b21;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.message.received .message-footer {
    justify-content: flex-start;
}

.message-time {
    font-size: 0.6875rem;
    color: #667781;
    white-space: nowrap;
    margin-top: 0.125rem;
}

.message-status {
    font-size: 0.7rem;
    margin-left: 0.15rem;
}

.message-status-delivered {
    color: #667781;
}

.message-status-read {
    color: #53bdeb;
}

.message-sender-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #667781;
    margin-bottom: 0.125rem;
    padding: 0 0.5rem;
}

.message.sent .message-sender-name {
    text-align: right;
}

.message.received .message-sender-name {
    text-align: left;
}

.message.sent .message-footer {
    justify-content: flex-end;
}

.chat-input-container {
    background: #f0f2f5;
    padding: 0.5rem 1rem 0.75rem;
    border-top: 1px solid #e4e6eb;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reply-preview,
.edit-preview {
    background: #e9edef;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid #25d366;
}

.reply-preview-content,
.edit-preview-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.reply-preview-info,
.edit-preview-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.reply-preview-info i {
    color: #25d366;
    font-size: 0.9rem;
}

.edit-preview-info i {
    color: #2563eb;
    font-size: 0.9rem;
}

.reply-preview-text {
    flex: 1;
    min-width: 0;
}

.reply-preview-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #25d366;
    margin-bottom: 0.15rem;
}

.reply-preview-message {
    font-size: 0.8rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close,
.edit-preview-close {
    background: none;
    border: none;
    color: #667781;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.reply-preview-close:hover,
.edit-preview-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: white;
    border-radius: 1.5rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e4e6eb;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: #25d366;
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.1);
}

.chat-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9375rem;
    padding: 0.5rem 0;
    background: transparent;
    color: #111b21;
    line-height: 1.5;
    min-height: 20px;
    max-height: 120px;
    resize: none;
    font-family: inherit;
}

.chat-input-wrapper input::placeholder {
    color: #667781;
    opacity: 0.8;
}

.chat-send-btn {
    background: #25d366;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(37, 211, 102, 0.2);
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #128c7e;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(37, 211, 102, 0.3);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    background: #b1b3b5;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.chat-send-btn i {
    font-size: 1rem;
    transition: transform 0.2s;
}

.chat-send-btn:hover:not(:disabled) i {
    transform: translateX(1px) translateY(-1px);
}

.chat-attachment-btn,
.chat-audio-btn {
    background: none;
    border: none;
    color: #667781;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.chat-attachment-btn:hover,
.chat-audio-btn:hover {
    background: #f0f2f5;
    color: #111b21;
}

.chat-attachment-btn:active,
.chat-audio-btn:active {
    transform: scale(0.95);
}

.chat-audio-btn.recording {
    color: #ef4444;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.attachment-preview {
    padding: 0.5rem 1rem;
    background: #f0f2f5;
    border-top: 1px solid #e4e6eb;
}

.attachment-preview-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.attachment-preview-content i {
    font-size: 1.5rem;
    color: #667781;
    flex-shrink: 0;
}

.attachment-preview-info {
    flex: 1;
    min-width: 0;
}

.attachment-preview-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-preview-size {
    font-size: 0.75rem;
    color: #667781;
    margin-top: 0.125rem;
}

.attachment-preview-close {
    background: none;
    border: none;
    color: #667781;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-preview-close:hover {
    background: #f0f2f5;
    color: #111b21;
}

.message-attachment {
    margin-top: 0.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    max-width: 100%;
}

.message-attachment-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 0.5rem;
    display: block;
    cursor: pointer;
    object-fit: cover;
}

.message-attachment-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f0f2f5;
    border-radius: 0.5rem;
    text-decoration: none;
    color: #111b21;
    transition: background 0.2s;
}

.message-attachment-file:hover {
    background: #e9edef;
}

.message-attachment-file i {
    font-size: 1.5rem;
    color: #667781;
    flex-shrink: 0;
}

.message-attachment-file-info {
    flex: 1;
    min-width: 0;
}

.message-attachment-file-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-attachment-file-size {
    font-size: 0.75rem;
    color: #667781;
    margin-top: 0.125rem;
}

.message-attachment-file-download {
    color: #25d366;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.typing-indicator {
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
    animation: typingIndicatorSlide 0.3s ease;
}

@keyframes typingIndicatorSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.typing-indicator-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f0f2f5;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    max-width: fit-content;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667781;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0;
}

@keyframes typingDot {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 0.875rem;
    color: #667781;
    font-style: italic;
}

/* Audio Recording UI */
.audio-recording-ui {
    padding: 0.75rem 1rem;
    background: #f0f2f5;
    border-top: 1px solid #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-recording-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}

.audio-recording-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.audio-recording-waveform {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 40px;
}

.waveform-bar {
    width: 4px;
    background: #25d366;
    border-radius: 2px;
    animation: waveform 1.2s ease-in-out infinite;
}

.waveform-bar:nth-child(1) {
    height: 20px;
    animation-delay: 0s;
}

.waveform-bar:nth-child(2) {
    height: 30px;
    animation-delay: 0.1s;
}

.waveform-bar:nth-child(3) {
    height: 25px;
    animation-delay: 0.2s;
}

.waveform-bar:nth-child(4) {
    height: 35px;
    animation-delay: 0.3s;
}

.waveform-bar:nth-child(5) {
    height: 20px;
    animation-delay: 0.4s;
}

@keyframes waveform {

    0%,
    100% {
        transform: scaleY(0.5);
        opacity: 0.7;
    }

    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

.audio-recording-timer {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111b21;
    min-width: 50px;
    text-align: center;
}

.audio-recording-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-recording-cancel,
.audio-recording-send {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.audio-recording-cancel {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.audio-recording-cancel:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.1);
}

.audio-recording-send {
    color: #25d366;
    background: rgba(37, 211, 102, 0.1);
}

.audio-recording-send:hover {
    background: rgba(37, 211, 102, 0.2);
    transform: scale(1.1);
}

/* Audio Message Player */
.message-attachment-audio {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0.5rem;
}

.message-audio-player {
    width: 100%;
    max-width: 300px;
    height: 40px;
    outline: none;
}

.message-audio-player::-webkit-media-controls-panel {
    background-color: rgba(255, 255, 255, 0.9);
}

.message-audio-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #667781;
}

.message-audio-info i {
    font-size: 0.875rem;
}

.message-audio-duration {
    font-weight: 500;
}

/* Call Interface */
.call-interface {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: callFadeIn 0.3s ease;
}

/* Ringtone Animation */
@keyframes callPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.call-interface.incoming .call-avatar {
    animation: callPulse 1s ease-in-out infinite;
}

@keyframes callFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.call-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
}

.call-header {
    text-align: center;
    color: white;
}

.call-user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #25d366;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 600;
    color: white;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.2);
}

.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-user-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.call-user-details h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.call-user-details span {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

.call-duration {
    font-size: 1.25rem;
    font-weight: 600;
    color: #25d366;
    margin-top: 0.5rem;
}

.call-video-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16/9;
    border-radius: 1rem;
    overflow: hidden;
    background: #000;
}

.call-video-container #remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-video-container #localVideo {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 200px;
    height: 150px;
    border-radius: 0.5rem;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: #000;
}

.call-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.call-control-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.call-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.call-control-btn:active {
    transform: scale(0.95);
}

.call-control-btn.muted {
    background: rgba(239, 68, 68, 0.3);
}

.call-control-btn.disabled {
    background: rgba(239, 68, 68, 0.3);
}

.call-end-btn {
    background: #ef4444;
    width: 64px;
    height: 64px;
}

.call-end-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.call-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.call-action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.call-accept-btn {
    background: #25d366;
}

.call-accept-btn:hover {
    background: #128c7e;
    transform: scale(1.1);
}

.call-reject-btn {
    background: #ef4444;
}

.call-reject-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.empty-state-messenger {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #667781;
}

.empty-state-messenger i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #b1b3b5;
}

.empty-state-messenger p {
    margin: 0;
    font-size: 0.9rem;
}

/* Scrollbar styling for messenger */
.messenger-conversations::-webkit-scrollbar,
.messenger-users::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.messenger-conversations::-webkit-scrollbar-track,
.messenger-users::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messenger-conversations::-webkit-scrollbar-thumb,
.messenger-users::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.messenger-conversations::-webkit-scrollbar-thumb:hover,
.messenger-users::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Message Context Menu */
.message-context-menu {
    position: fixed;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    min-width: 150px;
    overflow: hidden;
}

.context-menu-item {
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #111b21;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: #f0f2f5;
}

.context-menu-item i {
    width: 18px;
    color: #667781;
}

.context-menu-danger {
    color: #ef4444;
}

.context-menu-danger i {
    color: #ef4444;
}

.context-menu-danger:hover {
    background: #fee2e2;
}

.context-menu-success {
    color: #25d366;
}

.context-menu-success i {
    color: #25d366;
}

.context-menu-success:hover {
    background: #d4f4dd;
}

.message-restore-btn {
    color: #25d366 !important;
}

.message-restore-btn:hover {
    background: rgba(37, 211, 102, 0.1) !important;
    color: #25d366 !important;
}

.message-view-original-btn {
    color: #667781 !important;
}

.message-view-original-btn:hover {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #111b21 !important;
}

.message-original-preview {
    color: #333 !important;
    font-style: italic;
    background: rgba(255, 152, 0, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    display: inline-block;
    border-left: 3px solid #ff9800;
}

.message-text.showing-original {
    position: relative;
}

.message-text.showing-original::after {
    content: '(Click to hide)';
    font-size: 0.7rem;
    color: #ff9800;
    margin-left: 0.5rem;
    font-style: normal;
}

.group-actions-menu {
    position: fixed;
    min-width: 180px;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
    z-index: 12000;
    padding: 0.35rem 0;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.group-actions-menu button {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.92rem;
    color: #0f172a;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.group-actions-menu button i {
    width: 18px;
    text-align: center;
    color: inherit;
}

.group-actions-menu button:hover {
    background: rgba(15, 23, 42, 0.05);
}

.group-actions-menu button.group-action-danger {
    color: #dc2626;
}

.group-actions-menu button.group-action-danger:hover {
    background: rgba(220, 38, 38, 0.12);
}

div#messengerConversations {
    overflow: auto;
    height: 800px;
    padding-bottom: 80px;
}

div#notificationHistory {
    overflow: auto;
    height: 700px;
}

button#chatVideoCallBtn {
    display: none !important;
}

button#chatVideoCallBtn {
    display: none !important;
}

button#chatChangeGroupImageBtn {
    display: none !important;
}

aside#sidebar {
    overflow: auto;
    height: 700px !important;
}

/*form#rolePermsForm {*/
/*    overflow: auto;*/
/*    height: 800px;*/
/*}*/
@media (max-width: 768px) {
    .main-content {
        padding: 0px;
    }

    .profile-summary {
        flex-direction: column;
    }

    .page-header {
        padding: 30px 0px 0px 30px;
    }
}

/*dasktop screen*/
@media (min-width: 1600px) {
    aside#sidebar {
        overflow: auto !important;
        height: 1200px !important;
    }

    .sidebar {
        max-height: 100vh !important;
    }
}