@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #ff4500;
    --primary-hover: #ff5722;
    --bg-dark: #000000;
    --bg-sidebar: #0a0a0a;
    /* Darker than previous 0f0f0f to allow chat list contrast */
    --bg-chat-list: #0a0a0a;
    --bg-active: #1a1a1a;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --border-color: #2a2a2a;
    --message-sent: #2a2a2a;
    --message-received: #1e1e1e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

/* Image Protection Global */
.protected-img {
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Desktop: Shift profile photo slightly left for better corner alignment */
@media (min-width: 769px) {
    .p-photo-small {
        margin-left: -8px;
    }
}

/* App Container (Matches .app-layout in index.php) */
.app-layout {
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;
}

/* Sidebar (Chat List Panel - Matches .sidebar in index.php) */
.sidebar {
    width: 350px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

/* Sidebar Header */
.sidebar-header {
    padding: 15px 20px 0;
    /* Adjusted top padding */
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #0a0a0a;
}

.brand-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 40px;
}

.brand-logo img {
    height: 30px;
}

/* Settings Icon */
.settings-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.settings-icon:hover {
    color: #fff;
}

/* Search Box */
.search-box {
    width: 100%;
    background-color: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 10px 15px;
    color: #ccc;
    outline: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

.search-box:focus {
    border-color: var(--primary-color);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.filter-pill {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #151515;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid #2a2a2a;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-pill:hover,
.filter-pill.active {
    background: rgba(255, 69, 0, 0.1);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-badge {
    background: var(--bg-active);
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 4px;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.chat-item {
    display: flex;
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.chat-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.chat-item.active {
    background: linear-gradient(90deg, rgba(255, 69, 0, 0.08) 0%, rgba(0, 0, 0, 0) 100%);
    border-left: 3px solid var(--primary-color);
}

.avatar-container {
    position: relative;
    margin-right: 15px;
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #222;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ccc;
    font-size: 1.1rem;
    border: 1px solid #333;
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: #4caf50;
    border-radius: 50%;
    border: 2px solid var(--bg-sidebar);
    display: none;
}

.online-dot.visible {
    display: block;
}

.chat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    /* Added explicit color to ensure visibility */
    color: var(--text-main);
}

.chat-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-name {
    font-weight: 600;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-time {
    font-size: 0.7rem;
    color: #666;
}

.unread-count {
    background-color: var(--primary-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0 5px;
}

.chat-preview {
    font-size: 0.85rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Chat Area (Matches .main-chat in index.php) */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    position: relative;
    transition: transform 0.3s ease-in-out;
}

.main-header {
    height: 50px;
    /* Reduced from 60px */
    border: 1px solid #333;
    /* Floating border */
    border-radius: 30px;
    /* Rounded pill shape */
    margin: 15px 20px 0 20px;
    /* Floating margin */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background-color: rgba(20, 20, 20, 0.95);
    /* Slightly transparent dark */
    backdrop-filter: blur(10px);
    /* Glass effect */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    /* Drop shadow for depth */
    z-index: 50;
    /* Ensure it stays on top */
    position: relative;
    /* Anchor for absolute children */
}

.back-btn {
    display: none;
    /* Mobile only */
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

.close-chat-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    /* Absolute positioning to stick to right */
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}

.close-chat-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Header Avatar */
.header-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: #222;
    background-size: cover;
    background-position: center;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #aaa;
    font-size: 1rem;
    overflow: hidden;
}

.header-user {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

.header-status {
    font-size: 0.75rem;
    color: #666;
    margin-right: 5px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Optional: Subtler pattern or just plain dark */
    background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.message {
    max-width: 60%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message.received {
    align-self: flex-start;
    background-color: var(--message-received);
    border-bottom-left-radius: 2px;
}

.message.sent {
    align-self: flex-end;
    background-color: var(--message-sent);
    border-bottom-right-radius: 2px;
    border: 1px solid #333;
}

.message-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: right;
    margin-top: 4px;
}

.message-img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 0;
    cursor: pointer;
    filter: blur(20px);
    transition: filter 0.3s;
    display: block;
    /* Remove inline gap */
    min-height: 200px;
    /* Prevent layout shift on refresh */
    object-fit: cover;
    background: #111;
    /* Placeholder color */
}

.message-img.revealed {
    filter: blur(0);
}

/* Image Message Specifics */
.message.message-img-container {
    padding: 3px;
    background: transparent !important;
    border: none !important;
    max-width: min(60%, 380px);
    width: fit-content;
}

.message.message-img-container.sent {
    align-self: flex-end;
    margin-left: auto;
}

.message.message-img-container.received {
    align-self: flex-start;
    margin-right: auto;
}

.message.message-img-container .message-img {
    max-width: 100%;
    width: 100%;
    min-width: 200px;
}

.message.message-img-container .message-time {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.6rem;
    backdrop-filter: blur(2px);
    margin: 0;
}

.input-zone {
    padding: 15px 20px;
    background-color: #0c0c0c;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.msg-input {
    flex: 1;
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 20px;
    padding: 10px 15px;
    color: #e0e0e0;
    outline: none;
    font-size: 0.95rem;
}

.msg-input:focus {
    border-color: #555;
    background: #202020;
}

.send-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    transition: 0.2s;
}

.send-btn:hover {
    transform: scale(1.1);
}

.tools-container {
    position: relative;
}

.tools-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #aaa;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.tools-btn:hover,
.tools-btn.active {
    background: #252525;
    color: #fff;
    border-color: #555;
}

/* Tools Menu - Dropdown */
.tools-menu {
    position: absolute;
    bottom: 55px;
    /* Above the input bar */
    left: 0;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 8px;
    width: 200px;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    overflow: hidden;
    flex-direction: column;
}

.tools-menu.show {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.tool-item {
    padding: 12px 15px;
    font-size: 0.9rem;
    color: #ccc;
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.tool-item:last-child {
    border-bottom: none;
}

.tool-item:hover {
    background: #2a2a2a;
    color: #fff;
}

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

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

.nearby-member-age {
    font-size: 0.75rem;
    color: #888;
}

.nearby-member-distance {
    font-size: 0.7rem;
    color: #666;
    margin-top: -4px;
}

.nearby-new-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Private Access Button States */
.tool-item.access-granted {
    background: rgba(0, 204, 102, 0.15) !important;
    color: #00cc66 !important;
    border-left: 3px solid #00cc66;
}

.tool-item.access-rejected {
    background: rgba(255, 68, 68, 0.15) !important;
    color: #ff4444 !important;
    border-left: 3px solid #ff4444;
}

.loader {
    border: 3px solid #333;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 50;
        height: 100%;
    }

    .main-chat {
        display: none;
        width: 100%;
    }

    .app-layout.chat-open .sidebar {
        display: none;
    }

    .app-layout.chat-open .main-chat {
        display: flex;
    }

    .main-header {
        margin: 10px 10px 0 10px;
        /* Smaller margins on mobile */
        border-radius: 20px;
        height: 55px;
        /* Slightly smaller */
    }

    .back-btn {
        display: block;
        margin-right: 15px;
    }
}

.load-more-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #666;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    border-top: 1px solid #222;
    transition: 0.2s;
}

.load-more-btn:hover {
    color: #aaa;
    background: #111;
}

/* Settings Menu */
.settings-menu {
    position: absolute;
    top: 40px;
    /* Below icon */
    left: 0;
    background: #151515;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 5px;
    width: 160px;
    display: none;
    z-index: 1000;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.settings-menu.show {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #ccc;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 4px;
}

.menu-item:hover {
    background: #222;
    color: #fff;
}

/* RE-APPLYING BUBBLE STYLE FOR PROFILE DROPDOWN */
.profile-dropdown-container {
    position: relative;
    z-index: 2000;
}

.profile-dropdown {
    position: absolute;
    top: 55px;
    /* Fixed distance from header */
    left: 0;
    width: 320px;
    background: #000;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    display: none;
    flex-direction: column;
    z-index: 2001;
    animation: fadeIn 0.15s ease-out;
}

.profile-dropdown.show {
    display: flex;
}

/* Triangle/Bubble Pointer */
.profile-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 16px;
    height: 16px;
    background: #000;
    border-top: 1px solid #333;
    border-left: 1px solid #333;
    transform: rotate(45deg);
}

.p-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.p-photo-small {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: #222;
    background-size: cover;
    background-position: center;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.p-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

#p_age {
    color: #888;
    font-size: 0.85rem;
    margin-top: 2px;
}

.p-badges {
    margin-top: 6px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.badge {
    background: rgba(255, 69, 0, 0.15);
    color: #ff4500;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.p-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: 12px;
}

.p-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid #222;
}

.p-stat:last-child {
    border: none;
}

.p-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.p-lbl {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    margin-top: 2px;
}

.p-meta {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.p-meta div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.p-meta i {
    width: 16px;
    text-align: center;
    color: #666;
}

.p-gallery-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 10px;
    padding-top: 10px;
    border-top: 1px solid #252525;
}

.p-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.p-gallery-item {
    aspect-ratio: 1;
    background-color: #222;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: 0.2s;
}

.p-gallery-item:hover {
    opacity: 0.8;
}

/* No account screen (from index.php compatibility) */
.no-account-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-dark);
}

.no-account-box {
    text-align: center;
    padding: 40px;
    background: #111;
    border: 1px solid #222;
    border-radius: 16px;
    max-width: 400px;
}

.no-account-icon {
    font-size: 50px;
    color: #333;
    margin-bottom: 20px;
}

.contact-info {
    margin: 20px 0;
    color: #888;
    font-size: 0.9rem;
}

.contact-info a {
    color: var(--primary-color);
}

.logout-btn-block {
    display: inline-block;
    padding: 10px 20px;
    background: #222;
    color: #fff;
    border-radius: 8px;
    margin-top: 10px;
}

/* Custom Modal */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.custom-modal {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 20px;
    border-radius: 12px;
    width: 350px;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.custom-modal h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #fff;
}

.modal-input {
    background: #0a0a0a;
    border: 1px solid #333;
    color: #fff;
    padding: 10px;
    border-radius: 6px;
    outline: none;
    font-size: 0.95rem;
}

.modal-input:focus {
    border-color: var(--primary-color);
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    border: none;
    font-weight: 500;
}

.modal-btn.cancel {
    background: #2a2a2a;
    color: #aeaeae;
}

.modal-btn.cancel:hover {
    background: #3a3a3a;
    color: #fff;
}

.modal-btn.confirm {
    background: var(--primary-color);
    color: #fff;
}

.modal-btn.confirm:hover {
    background: var(--primary-hover);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
}

.toast {
    background: #1e1e1e;
    border: 1px solid #333;
    border-left: 4px solid var(--primary-color);
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    overflow: hidden;
    animation: slideInRight 0.3s ease-out forwards;
}

.toast.success {
    border-left-color: #4caf50;
}

.toast.error {
    border-left-color: #f44336;
}

.toast.info {
    border-left-color: var(--primary-color);
}

.toast.hide {
    animation: slideOutRight 0.3s ease-in forwards;
}

.toast-title {
    font-weight: 700;
    color: #fff;
    font-size: 0.95rem;
}

.toast-message {
    font-size: 0.85rem;
    color: #ccc;
    line-height: 1.4;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    width: 0%;
    /* Will animate via JS or CSS */
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Report Button */
.report-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    backdrop-filter: blur(4px);
    transition: 0.2s;
}

.report-btn:hover {
    background: rgba(231, 76, 60, 0.8);
    border-color: #e74c3c;
}

.report-btn i {
    font-size: 0.8rem;
    color: #ffd700;
}

/* Message Menu (3 Dots) */
/* Message Menu (3 Dots) */
.msg-menu-container {
    position: absolute;
    right: -40px;
    /* Outside bubble */
    top: 50%;

    transform: translateY(-50%);
    opacity: 1;
    /* Always visible */
    transition: opacity 0.2s;
    z-index: 10;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    /* No background */
}

/* For received messages (left side), maybe move it to right as well? 
   Yes, standard UX is menu on right or side. 
   If message is on far right, right: -25px might be offscreen.
   Let's check .message max-width is 60%, so there is space. */

.message:hover .msg-menu-container {
    opacity: 1;
}


.msg-menu-btn {
    color: #666;
    cursor: pointer;
    font-size: 1.4rem;
}

.msg-menu-btn:hover {
    color: #fff;
}

/* Ensure message content is relative */
.message-content {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Ensure message allows overflow for the menu */
.message {
    overflow: visible !important;
}

.msg-menu-dropdown {
    position: absolute;
    top: 20px;
    /* Default fallback */
    right: 0;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 4px;
    min-width: 140px;
    display: none;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    margin-top: 5px;
}

/* Conditional Alignment */
.message.sent .msg-menu-dropdown {
    right: 0;
    left: auto;
}

.message.received .msg-menu-dropdown {
    left: 0;
    right: auto;
}

.msg-menu-dropdown.show {
    display: block;
    animation: fadeIn 0.2s;
}


.msg-menu-item {
    padding: 10px 14px;
    font-size: 0.95rem;
    color: #ddd;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.msg-menu-item:hover {
    background: #333;
    color: #fff;
}

@media (max-width: 768px) {
    .msg-menu-container {
        opacity: 1;
        /* Always show on mobile */
        right: -50px;
        /* More to the right on mobile */
        top: 60%;
        /* Lower on mobile */
    }
}

/* --- MOBILE PROFILE BOTTOM SHEET & BACKDROP --- */
@media (max-width: 768px) {
    .profile-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        border-top: 1px solid #333 !important;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
        z-index: 9999 !important;
        max-height: 85vh;
        overflow-y: auto;
        padding: 20px 20px 40px 20px !important;
        /* Balanced padding + safe area bottom */
        display: flex !important;
        visibility: hidden;
        background: #000 !important;
        /* Ensure opaque background */
    }

    .profile-dropdown::before {
        display: none !important;
    }

    .profile-dropdown.show {
        transform: translateY(0) !important;
        visibility: visible !important;
    }

    /* Overlay Backdrop */
    .mobile-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        /* Semi-transparent black */
        z-index: 9998;
        display: none;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .mobile-backdrop.show {
        display: block;
        opacity: 1;
    }

    /* Drag Handle */
    .sheet-handle-bar {
        width: 40px;
        height: 4px;
        background: #444;
        border-radius: 2px;
        margin: 0 auto 15px auto;
        display: block;
        flex-shrink: 0;
    }
}

/* Explicit Dashboard Container to prevent centering issues */
.dashboard-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 30px;
    text-align: left;
    display: block;
}

/* --- SETTINGS PAGE GRID --- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
}

.settings-card {
    background: var(--bg-sidebar);
    /* Use sidebar bg or card bg variable */
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: fit-content;
    width: 100%;
}

.settings-card .card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-card .tgl-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.settings-card .tgl-group:last-child {
    border-bottom: none;
}

.settings-card .tgl-label {
    display: block;
    color: #e0e0e0;
    font-weight: 600;
    margin-bottom: 4px;
}

.settings-card .tgl-desc {
    display: block;
    color: #888;
    font-size: 0.8rem;
}

/* Dark Theme Inputs */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    color: #bbb;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-input,
.form-textarea {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #333;
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* --- NOTIFICATION BELL SYSTEM --- */
.notification-bell-icon {
    position: relative;
    cursor: pointer;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s;
}

.notification-bell-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.notification-bell-icon i {
    font-size: 1.2rem;
    color: #fff;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Animated NEW notification indicator (LED) */
.notification-new-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    background: #e74c3c;
    border-radius: 50%;
    animation: pulse-glow 2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
}

@keyframes pulse-glow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 4px rgba(231, 76, 60, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}


.notification-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 350px;
    max-height: 500px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.notification-dropdown.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.notification-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: rgba(52, 152, 219, 0.05);
    border-left: 3px solid #3498db;
}

.notification-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 5px;
}

.notification-message {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 8px;
    line-height: 1.4;
}

.notification-time {
    font-size: 0.75rem;
    color: #666;
}

.notification-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.notification-empty i {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.3;
}

@media (max-width: 480px) {
    .notification-dropdown {
        position: fixed;
        top: 55px;
        left: 5vw;
        right: 5vw;
        width: 90vw;
        max-height: 70vh;
        border-radius: 12px;
    }
}

/* System Gallery Bubble */
.system-gallery-bubble {
    position: absolute;
    bottom: 55px;
    /* Above the input bar */
    left: 0;
    width: 380px;
    /* Slightly wider */
    height: 400px;
    /* Fixed height for scroll */
    max-height: 50vh;
    /* Responsive max height */
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    z-index: 101;
    /* Higher than tools menu */
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUpBubble 0.2s ease-out;
}

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

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

.gallery-bubble-header {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
    background: #151515;
    color: #fff;
    flex-shrink: 0;
}

.gallery-bubble-header i {
    cursor: pointer;
    color: #888;
    transition: 0.2s;
}

.gallery-bubble-header i:hover {
    color: #fff;
}

.gallery-bubble-grid {
    padding: 10px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    flex: 1;
}

.gallery-bubble-grid::-webkit-scrollbar {
    width: 6px;
}

.gallery-bubble-grid::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.sys-gallery-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid #333;
    cursor: pointer;
    transition: transform 0.2s;
}

.sys-gallery-item:hover {
    transform: scale(1.02);
    border-color: #f39c12;
}

/* Mobile responsive override */
@media (max-width: 480px) {
    .system-gallery-bubble {
        width: 300px;
        /* Narrower on mobile */
        height: 350px;
        bottom: 60px;
        /* Slightly higher on mobile */
    }
}

/* ============================================
   NEARBY MEMBERS BUBBLE STYLES
   ============================================ */

.nearby-bubble {
    position: absolute;
    bottom: 75px;
    left: 60px;
    width: 500px;
    max-height: 600px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    z-index: 200;
    animation: slideUp 0.3s ease-out;
}

.nearby-bubble-header {
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
    border-radius: 12px 12px 0 0;
}

.nearby-bubble-header span {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

.nearby-bubble-header i {
    color: #666;
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.2s;
}

.nearby-bubble-header i:hover {
    color: #fff;
}

.nearby-bubble-grid {
    padding: 15px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-height: 550px;
}

.nearby-bubble-grid::-webkit-scrollbar {
    width: 6px;
}

.nearby-bubble-grid::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 3px;
}

.nearby-member-card {
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    position: relative;
}

.nearby-member-card:hover {
    background: #1a1a1a;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 69, 0, 0.2);
}

.nearby-member-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: #222;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #666;
    font-weight: 700;
    position: relative;
}

.nearby-online-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #4caf50;
    border: 2px solid #0a0a0a;
    border-radius: 50%;
}

/* Mobile Responsive for Nearby Bubble */
@media (max-width: 768px) {
    .nearby-bubble {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        z-index: 9999;
    }

    .nearby-bubble-header {
        padding: 20px;
        border-radius: 0;
    }

    .nearby-bubble-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 20px;
        max-height: calc(100vh - 70px);
    }

    .nearby-member-card {
        padding: 15px;
    }

    .nearby-member-photo {
        width: 100px;
        height: 100px;
    }
}
