/* ==========================================================================
   BLOCK 1: GLOBAL STYLES & VARIABLES
   ========================================================================== */

/* Google Sans-style clean fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap');

:root {
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --color-primary: #1a73e8;
    --color-success: #34a853;
    --color-danger: #ea4335;
    --color-warning: #fbbc04;
    --color-text: #202124;
    --color-text-secondary: #5f6368;
    --color-border: #dadce0;
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
}

/* Dark Mode Theme */
[data-theme="dark"] {
    --color-primary: #8ab4f8;
    --color-success: #81c995;
    --color-danger: #f28b82;
    --color-warning: #fdd663;
    --color-text: #e8eaed;
    --color-text-secondary: #9aa0a6;
    --color-border: #3c4043;
    --color-bg: #202124;
    --color-surface: #292a2d;
}

[data-theme="dark"] body {
    background-color: var(--color-bg);
    color: var(--color-text);
}

[data-theme="dark"] .auth-card,
[data-theme="dark"] .settings-section,
[data-theme="dark"] .card,
[data-theme="dark"] .profile-header-card,
[data-theme="dark"] .balance-card {
    background: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

[data-theme="dark"] #auth-container {
    background: #1a1a1a;
}

/* Spinner Animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

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

/* Circular Spinner - MUST have equal width/height for circle */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Larger spinner variant */
.spinner.large {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* Refresh button spinning animation */
.icon-btn.spinning .material-symbols-outlined {
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   SKELETON LOADING - Improves perceived performance
   ========================================================================== */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            #f0f0f0 25%,
            #e0e0e0 50%,
            #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Skeleton variants */
.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-title {
    height: 20px;
    width: 40%;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 80px;
    margin-bottom: 12px;
}

.skeleton-tree-item {
    height: 8px;
    margin-bottom: 12px;
    border-radius: 4px;
}

/* Skeleton container for tree view */
.skeleton-tree {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ==========================================================================
   MULTI-SELECT FILE HIGHLIGHTING
   ========================================================================== */
.file-item.selected {
    background: rgba(59, 130, 246, 0.15);
    border-radius: 4px;
}

.file-item.selected .file-link {
    color: #2563eb;
    font-weight: 500;
}

.file-item.selected::before {
    content: '✓';
    position: absolute;
    left: -18px;
    color: #2563eb;
    font-weight: bold;
    font-size: 12px;
}

.file-item {
    position: relative;
}

/* Multi-select action bar - white theme like context menus */
.multi-select-bar {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: #333;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
    z-index: 1000;
    gap: 12px;
    align-items: center;
}

.multi-select-bar.active {
    display: flex;
}

.multi-select-bar .count {
    font-weight: 600;
    color: #2563eb;
    padding-right: 8px;
    border-right: 1px solid #e5e7eb;
}

.multi-select-bar button {
    background: #f3f4f6;
    border: none;
    color: #374151;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.multi-select-bar button:hover {
    background: #e5e7eb;
}

.multi-select-bar button.danger {
    color: #dc2626;
}

.multi-select-bar button.danger:hover {
    background: #fef2f2;
}

.multi-select-bar .clear-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    margin-left: 4px;
}

.multi-select-bar .clear-btn:hover {
    color: #6b7280;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* Disable autocomplete styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0px 1000px white inset !important;
    box-shadow: 0 0 0px 1000px white inset !important;
}

/* ==========================================================================
   DASHBOARD CARDS - Account page styling
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.dashboard-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
}

.dashboard-card h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 8px;
}

.dashboard-card p {
    font-size: 28px;
    font-weight: 600;
    color: #111827;
    font-family: var(--font-heading);
}

/* Balance Card - Premium styling */
.balance-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    position: relative;
    overflow: hidden;
}

/* Removed decorative circle and $ sign - redundant with coin icon */

.balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.balance-row p {
    font-size: 32px;
    color: #3b82f6;
}

.balance-row .icon-btn {
    background: #2563eb;
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.balance-row .icon-btn:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

#app-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
    flex-grow: 1;
}

.material-symbols-outlined {
    vertical-align: middle;
    font-size: 20px;
}

/* ==========================================================================
   BLOCK 2: HEADER & NAVIGATION
   ========================================================================== */
#app-header,
#app-header-account {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    height: 80px;
    border-bottom: 1px solid #e0e0e0;
}

/* Logo Centering Logic */
.header-spacer {
    width: 48px;
}

.logo-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

#repo-logo {
    height: 70px;
    width: auto;
}

/* User Menu Button */
.user-menu-container {
    position: relative;
    width: 48px;
    display: flex;
    justify-content: flex-end;
}

#user-menu-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    color: #5f6368;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#user-menu-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Dropdown */
.user-menu {
    position: absolute;
    right: 0;
    top: 120%;
    background-color: white;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 200px;
    z-index: 100;
    padding: 8px;
}

.user-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.user-menu li {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    gap: 12px;
    color: #333;
    border-radius: 8px;
}

.user-menu li:hover {
    background-color: #f3f5f7;
    color: #007bff;
}

/* ==========================================================================
   BLOCK 3: AUTH PAGES (Login/Register)
   ========================================================================== */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 85vh;
}

.form-wrapper {
    background-color: white;
    padding: 3rem 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.form-wrapper input {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    background-color: #f9f9f9;
}

.form-wrapper button {
    width: 100%;
    padding: 14px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
}

.auth-links {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
}

.auth-links a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

/* ==========================================================================
   BLOCK 4: TREE VIEW
   ========================================================================== */
#category-tree-container ul {
    list-style: none;
    padding-left: 24px;
    margin: 0;
    position: relative;
}

/* Tree Lines */
#category-tree-container ul::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: #e0e0e0;
}

.category-item::before,
.file-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 15px;
    width: 20px;
    height: 1px;
    background-color: #e0e0e0;
}

#category-tree-container li:last-child>ul::before {
    display: none;
}

/* Expansion Logic */
.category-item>ul {
    display: none;
}

.category-item.expanded>ul {
    display: block;
}

.arrow {
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 8px;
    border-left: 6px solid #888;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transition: transform 0.2s;
}

.category-item.expanded>.category-name>.arrow {
    transform: rotate(90deg);
}

/* Text Styles */
.category-name {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.category-name:hover {
    background-color: #e3e8f0;
    color: #0056b3;
}


/* --- GOOGLE CHAT FULL SCREEN --- */

#chat-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: white;
    z-index: 5000;
    /* Top of everything */
    display: flex;
    flex-direction: column;
}

/* Global Header */
.chat-global-header {
    height: 64px;
    border-bottom: 1px solid #dadce0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-right {
    display: flex;
    align-items: center;
}

.chat-header-search {
    background: #f1f3f4;
    border-radius: 8px;
    padding: 8px 16px;
    width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #5f6368;
}

.chat-header-search input {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    font-size: 16px;
}

/* Body Layout */
.chat-body {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

/* SIDEBAR & COLLAPSE LOGIC */
.chat-sidebar {
    width: 256px;
    border-right: 1px solid #dadce0;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    /* Hide text when shrinking */
}

/* Collapsed State: Narrow width, hide text */
.chat-sidebar.collapsed {
    width: 72px;
}

.chat-sidebar.collapsed .btn-text,
.chat-sidebar.collapsed .sidebar-section-label,
.chat-sidebar.collapsed .contact-info {
    display: none;
}

.chat-sidebar.collapsed #new-chat-btn {
    justify-content: center;
    padding: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    /* Circle button when collapsed */
}

.chat-sidebar.collapsed .contact-item {
    justify-content: center;
    padding: 10px 0;
    margin-right: 0;
    border-radius: 0;
}

/* Sidebar Components */
#new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    border-radius: 24px;
    color: #3c4043;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    height: 48px;
    margin-bottom: 10px;
}

#new-chat-btn:hover {
    background-color: #f8f9fa;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.sidebar-section-label {
    padding: 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #5f6368;
}

/* Contact List */
#chat-contacts-list {
    flex-grow: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 16px;
    cursor: pointer;
    height: 48px;
    margin-right: 8px;
    border-top-right-radius: 24px;
    border-bottom-right-radius: 24px;
}

.contact-item:hover {
    background-color: #f1f3f4;
}

.contact-item.active {
    background-color: #e8f0fe;
    color: #1967d2;
}

/* Avatar */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

.contact-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.contact-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Area */
.chat-main {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

#chat-empty-state {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#active-chat-header {
    height: 64px;
    border-bottom: 1px solid #dadce0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.125rem;
    color: #202124;
    font-weight: 600;
}

/* Messages & Input */
#dm-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

#dm-form-container {
    padding: 16px 24px;
}

#replying-to-banner {
    background: #f1f3f4;
    padding: 8px 15px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #1967d2;
}

#dm-form {
    background: #f1f3f4;
    border-radius: 24px;
    padding: 4px 8px 4px 20px;
    display: flex;
    align-items: center;
}

#dm-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    padding: 10px;
    font-size: 1rem;
}

#dm-input:focus {
    outline: none;
}

.send-btn {
    background: none;
    border: none;
    color: #1967d2;
    cursor: pointer;
    padding: 8px;
}

.send-btn:hover {
    color: #1557b0;
}

/* Message Rows - With Avatar Support */
.message-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: flex-end;
    /* Align avatar to bottom of bubble */
}

.message-row.self {
    justify-content: flex-end;
}

.message-row.other {
    justify-content: flex-start;
}

/* The Message Box */
.message-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    /* Rounder bubbles */
    font-size: 1rem;
    line-height: 1.5;
    background-color: #f1f3f4;
    /* Grey for others */
    color: #1f1f1f;
    max-width: 60%;
    position: relative;
}

.message-row.self .message-bubble {
    background-color: #e8f0fe;
    /* Blue for me */
    color: #1f1f1f;
    border-bottom-right-radius: 4px;
    /* Subtle visual cue */
}

.message-row.other .message-bubble {
    border-bottom-left-radius: 4px;
}

/* Reply Context */
.reply-preview {
    font-size: 0.8rem;
    color: #5f6368;
    margin-bottom: 4px;
    border-left: 2px solid #1967d2;
    padding-left: 6px;
    cursor: pointer;
}

/* Meta (Time & Ticks) */
.message-meta {
    font-size: 0.7rem;
    color: #5f6368;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tick-icon {
    font-size: 14px !important;
}

.tick-read {
    color: #1967d2;
}

.tick-sent {
    color: #5f6368;
}

/* The "New Messages" Line */
.unread-separator {
    display: flex;
    align-items: center;
    margin: 15px 0;
    color: #d93025;
    font-size: 0.8rem;
    font-weight: 500;
}

.unread-separator::before,
.unread-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #d93025;
}

.unread-separator span {
    padding: 0 10px;
}

/* Context Menu */
.msg-context-menu {
    position: absolute;
    background: white;
    border: 1px solid #dadce0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    z-index: 2000;
    padding: 4px 0;
}

.msg-context-menu div {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.msg-context-menu div:hover {
    background: #f1f3f4;
}


.file-link {
    text-decoration: none;
    color: #007bff;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
}

.file-link:hover {
    background-color: #f0f7ff;
}

.file-link.locked {
    color: #888;
}

.file-link.pending {
    color: #e65100;
    font-style: italic;
}

/* Levels */
.level-0>.category-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 15px;
}

.level-1>.category-name {
    font-size: 1.15rem;
    font-weight: 600;
}

.level-2>.category-name {
    font-size: 1rem;
}

/* ==========================================================================
   BLOCK 5: MODALS (Purchase, Transfer, Reports)
   ========================================================================== */
#purchase-modal-backdrop,
#transfer-modal-backdrop,
#reports-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

#purchase-modal {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#purchase-modal h3 {
    margin-top: 0;
}

#purchase-modal-buttons {
    margin-top: 2rem;
    display: flex;
    gap: 12px;
    justify-content: center;
}

#purchase-modal button {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

#purchase-confirm-button {
    background: #007bff;
    color: white;
}

#purchase-cancel-button {
    background: #f1f3f5;
    color: #333;
}

#transfer-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
}

#transfer-form input:focus {
    border-color: #007bff;
    outline: none;
}

/* ==========================================================================
   BLOCK 6: ACCOUNT DASHBOARD
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 1.5rem;
    text-align: center;
    border-radius: 12px;
}

.stat-card p {
    font-size: 2rem;
    font-weight: 600;
    color: #202124;
    margin: 10px 0 0 0;
}

#transactions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

#transactions-table th {
    text-align: left;
    padding: 16px;
    color: #666;
    background: #f8f9fa;
}

#transactions-table td {
    padding: 16px;
    border-bottom: 1px solid #eee;
}

.positive-amount {
    color: #137333;
    font-weight: 600;
    background: #e6f4ea;
    padding: 4px 8px;
    border-radius: 4px;
}

.negative-amount {
    color: #c5221f;
    font-weight: 600;
}

.icon-btn {
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    color: #444;
}

.icon-btn:hover {
    background-color: #e0e0e0;
}

#open-transfer-modal {
    background-color: #e7f1ff;
    color: #007bff;
}

/* ==========================================================================
   BLOCK 7: PDF VIEWER & CONTEXT MENUS
   ========================================================================== */
/* PDF Viewer */
#pdf-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #333;
    z-index: 3000;
    display: flex;
    flex-direction: column;
}

.pdf-toolbar {
    background: #292a2d;
    color: #fff;
    height: 60px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    /* Pushes items to edges */
    align-items: center;
    padding: 0 16px;
    box-sizing: border-box;
    overflow: hidden;
    /* Prevents layout breaking */
}

.pdf-toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.toolbar-btn {
    background: none;
    border: none;
    color: #e8eaed;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#pdf-canvas-container {
    flex-grow: 1;
    overflow: auto;
    text-align: center;
    padding: 40px 0;
}

.pdf-page-container {
    margin: 0 auto 20px auto;
    position: relative;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.textLayer {
    position: absolute;
    inset: 0;
    opacity: 1;
    background: transparent !important;
    pointer-events: none;
}

.textLayer span {
    color: transparent;
    position: absolute;
    cursor: text;
    pointer-events: auto;
}

.textLayer ::selection {
    background: rgba(194, 231, 255, 0.6);
}

/* Context Menus */
.context-menu {
    position: absolute;
    background: white;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 6px;
    z-index: 2000;
    min-width: 180px;
}

.context-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.context-menu li {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    border-radius: 4px;
}

.context-menu li:hover {
    background-color: #f0f2f5;
    color: #007bff;
}

.admin-only {
    display: none !important;
}

/* When body has is-admin class, show admin-only elements (except multi-select bar) */
body.is-admin .admin-only:not(#multi-select-bar) {
    display: block !important;
}

/* Multi-select bar: ONLY show when admin AND .active class is present */
#multi-select-bar {
    display: none !important;
}

body.is-admin #multi-select-bar.active {
    display: flex !important;
}

.cut-item {
    opacity: 0.5;
}

/* ==========================================================================
   BLOCK 8: GLOBAL LOADER
   ========================================================================== */
.loader-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.loader-backdrop.active {
    display: flex;
}

.loader-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    z-index: 2;
}

.loader-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: #007bff;
    border-right-color: #007bff;
    animation: spin 1s linear infinite;
    z-index: 1;
}

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

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

.spinning span {
    animation: spin 1s linear infinite;
}


/* --- NOTIFICATIONS --- */
.notification-item {
    background: white;
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    position: relative;
    /* For positioning the tick */
    transition: all 0.2s;
}

.notification-item.unread {
    background: #fff;
    border-left: 4px solid #007bff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.notification-item.read {
    opacity: 0.7;
    background: #f9f9f9;
}

.notification-item h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    color: #333;
}

.notification-item p {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

/* preserve line breaks */
.notification-item .meta {
    font-size: 0.75rem;
    color: #999;
    margin-top: 8px;
}

/* Mark Read Tick Button */
.mark-read-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ccc;
    transition: all 0.2s;
}

.mark-read-btn:hover {
    background: #e6f4ea;
    border-color: #28a745;
    color: #28a745;
}

.notification-item.read .mark-read-btn {
    display: none;
    /* Hide tick if already read */
}

/* Update Admin Tool */
#admin-notification-tool {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#admin-notification-tool h3 {
    margin-top: 0;
    color: #d63384;
    /* Distinct Admin Color */
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

#admin-notify-form input,
#admin-notify-form textarea,
#admin-notify-form select {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
}

#admin-notify-form button {
    width: auto;
    padding: 8px 24px;
}

/* Fix Admin Form Overflow */
#admin-notify-form input,
#admin-notify-form textarea,
#admin-notify-form select {
    width: 100%;
    box-sizing: border-box;
    /* Critical: includes padding in width calculation */
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

/* Spinner Animation */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Highlight animation for Go To File */
@keyframes highlight-pulse {
    0% {
        background-color: #fff3cd;
    }

    100% {
        background-color: transparent;
    }
}

.highlight-file {
    animation: highlight-pulse 3s ease-out;
}

/* --- TASK BOARD STYLES --- */

/* Layout */
#tasks-view {
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    background-color: #fff;
}

.tasks-layout {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

/* 1. Sidebar (Filters) */
.tasks-sidebar {
    width: 220px;
    /* Slightly narrower */
    background-color: #fff;
    /* White looks cleaner */
    border-right: 1px solid #e0e0e0;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-group h4 {
    margin: 0 0 10px 10px;
    font-size: 0.85rem;
    color: #5f6368;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tasks-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-item {
    padding: 10px 16px;
    margin-bottom: 4px;
    border-radius: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #3c4043;
    font-size: 0.95rem;
    font-weight: 500;
}

.filter-item:hover {
    background-color: #e8eaed;
}

.filter-item.active {
    background-color: #e8f0fe;
    color: #1967d2;
}

.filter-item .material-symbols-outlined {
    font-size: 20px;
}

/* 2. Main List Area */
.tasks-main {
    flex-grow: 1;
    background-color: #f8f9fa;
    /* Light gray background for contrast */
    padding: 20px;
    /* Reduce padding */
    overflow-y: auto;
}

#task-cards-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1000px;
    /* Wider container */
    width: 100%;
    margin: 0 auto;
}

/* Task Card */
.task-card {
    background: white;
    border: 1px solid transparent;
    /* Remove visible border */
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    /* Softer shadow */
    margin-bottom: 10px;
}

.task-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #dadce0;
}

.task-card-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-title {
    font-weight: 600;
    font-size: 1rem;
    color: #202124;
}

.task-meta {
    font-size: 0.85rem;
    color: #5f6368;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Status Badges */
.status-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: capitalize;
}

.status-open {
    background: #e6f4ea;
    color: #137333;
}

.status-in_progress {
    background: #fff8e1;
    color: #f9a825;
}

.status-submitted {
    background: #e8f0fe;
    color: #1967d2;
}

.status-completed {
    background: #f1f3f4;
    color: #5f6368;
    text-decoration: line-through;
}

.task-bounty {
    font-weight: 700;
    color: #e37400;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 3. Detail Panel (Slide-over) */
#task-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 500px;
    background: white;
    border-left: 1px solid #e0e0e0;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    padding: 24px;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s ease;
    z-index: 100;
    overflow-y: auto;
}

#task-detail-panel.hidden {
    transform: translateX(100%);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.bounty-badge {
    background: #fff8e1;
    color: #e37400;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

#detail-title {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.detail-meta {
    font-size: 0.9rem;
    color: #5f6368;
    margin-bottom: 10px;
}

#detail-description {
    margin: 20px 0;
    line-height: 1.6;
    color: #3c4043;
}

/* Markdown Styles within Description */
.markdown-body h1,
.markdown-body h2 {
    font-size: 1.2rem;
    margin-top: 1rem;
}

.markdown-body ul {
    padding-left: 20px;
}

.markdown-body code {
    background: #f1f3f4;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* Action Buttons Area */
#detail-actions {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Tag Styling */
.task-tag {
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #555;
    margin-left: 4px;
}

/* Task Board Animations */
#task-detail-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

#create-task-modal>div {
    animation: slideDown 0.3s ease-out;
}

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

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

/* Profile Input Polish */
.form-wrapper.profile-edit {
    box-shadow: none;
    border: 1px solid #eee;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

/* --- PROFILE DASHBOARD --- */
.profile-header-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-info-edit {
    flex-grow: 1;
    max-width: 400px;
}

.profile-info-edit label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.input-group button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.dashboard-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-card p {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: #333;
}

.balance-card {
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.icon-btn.small {
    width: 32px;
    height: 32px;
    padding: 0;
}

.table-container {
    background: white;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

/* ==========================================================================
   BLOCK 9: CUSTOM MODAL SYSTEM
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease-out;
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    color: #202124;
    font-weight: 600;
}

.modal-content p {
    color: #5f6368;
    margin: 0 0 1.5rem 0;
    line-height: 1.5;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafafa;
}

.modal-content input:focus,
.modal-content textarea:focus {
    outline: none;
    border-color: var(--color-primary, #1a73e8);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
    background: #fff;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 1.5rem;
}

.modal-buttons button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-buttons button:not(.primary) {
    background: #f1f3f4;
    color: #3c4043;
}

.modal-buttons button:not(.primary):hover {
    background: #e8eaed;
}

.modal-buttons button.primary {
    background: var(--color-primary, #1a73e8);
    color: white;
}

.modal-buttons button.primary:hover {
    background: #1557b0;
    transform: translateY(-1px);
}

.modal-buttons button.danger {
    background: #dc3545;
}

.modal-buttons button.danger:hover {
    background: #c82333;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

/* Task Modal Styling (inside tasks-view) */
.task-modal-backdrop {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.task-modal-backdrop.active {
    display: flex;
}

.task-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    width: 500px;
    max-width: 95%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.task-modal-content h3 {
    margin: 0 0 1.5rem 0;
}

.task-modal-content input,
.task-modal-content textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.task-modal-content input:focus,
.task-modal-content textarea:focus {
    border-color: #007bff;
    outline: none;
}

/* ==========================================================================
   BLOCK 10: PROFILE IMPROVEMENTS
   ========================================================================== */
.profile-display-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-current-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: #202124;
}

.profile-edit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.profile-edit-row input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

/* ==========================================================================
   BLOCK 11: TASKS VIEW FIXES
   ========================================================================== */
#tasks-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #fff;
    z-index: 4000;
    display: flex;
    flex-direction: column;
}

#tasks-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    height: 64px;
    gap: 16px;
}

#tasks-header h2 {
    margin: 0;
    flex-grow: 1;
}

.tasks-layout {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   BLOCK 12: EMOJI PICKER & REACTIONS
   ========================================================================== */
.emoji-picker {
    position: absolute;
    background: white;
    border: 1px solid #dadce0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-radius: 24px;
    padding: 8px 12px;
    z-index: 2001;
    display: flex;
    gap: 8px;
}

.emoji-picker span {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: transform 0.15s, background 0.15s;
}

.emoji-picker span:hover {
    background: #f1f3f4;
    transform: scale(1.2);
}

.message-reactions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #f1f3f4;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.reaction-badge:hover {
    background: #e8f0fe;
}

.reaction-badge.reacted {
    background: #e8f0fe;
    border: 1px solid #1967d2;
}

.reaction-badge .count {
    font-size: 12px;
    color: #5f6368;
}

/* ==========================================================================
   BLOCK 13: ORGANIC ANIMATIONS - Making UI Feel Alive
   ========================================================================== */

/* Subtle hover lift for cards */
.dashboard-card,
.task-card,
.notification-item,
.contact-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

/* Buttons with subtle feedback */
button,
.icon-btn {
    transition: all 0.15s ease;
}

button:active,
.icon-btn:active {
    transform: scale(0.97);
}

/* Ripple effect for clicks */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.ripple:active::after {
    width: 200px;
    height: 200px;
}

/* Smooth fade for view transitions */
#main-app-view,
#account-view,
#notifications-view {
    animation: fadeInView 0.3s ease-out;
}

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

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

/* Category tree expansion animation */
.category-item>ul {
    animation: expandTree 0.25s ease-out;
    transform-origin: top;
}

@keyframes expandTree {
    from {
        opacity: 0;
        transform: scaleY(0.9);
    }

    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

/* Message bubble entrance */
.message-row {
    animation: messageSlide 0.25s ease-out;
}

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

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

/* Pulsing notification dot */
#notification-dot {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* Loading spinner enhanced */
.loader-spinner {
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Gradient shimmer for loading states */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

/* Floating effect for important buttons */
#create-task-btn {
    transition: transform 0.2s, box-shadow 0.2s;
}

#create-task-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* Chat sidebar smooth collapse */
.chat-sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Task detail panel slide */
#task-detail-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Menu dropdown animation */
.user-menu {
    animation: dropIn 0.2s ease-out;
    transform-origin: top right;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Form input focus glow */
input:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Tooltip-like hover effect */
[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #333;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
}

/* Status badge colors with subtle gradients */
.status-open {
    background: linear-gradient(135deg, #e6f4ea, #d4edda);
}

.status-in_progress {
    background: linear-gradient(135deg, #fff8e1, #ffeeba);
}

.status-submitted {
    background: linear-gradient(135deg, #e8f0fe, #d1e3ff);
}

/* Avatar hover effect */
.avatar,
.profile-avatar-large {
    transition: transform 0.2s, box-shadow 0.2s;
}

.profile-avatar-large:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Balance card special styling */
.balance-card {
    background: linear-gradient(135deg, #f8f9ff, #f0f4ff);
    border-color: #d1ddff;
}

/* Bounty badge glow */
.bounty-badge {
    box-shadow: 0 2px 8px rgba(227, 116, 0, 0.2);
}

/* Tree item hover effect */
.category-name:hover,
.file-link:hover {
    background: linear-gradient(90deg, #e3e8f0, transparent);
}

/* ==========================================================================
   BLOCK 14: ADDITIONAL COMPONENT STYLES
   ========================================================================== */

/* Profile Edit Buttons - Consistent with rest of app */
.profile-edit-row button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.2s;
}

#save-profile-btn {
    background: var(--color-primary);
    color: white;
}

#save-profile-btn:hover {
    background: #1557b0;
}

#cancel-profile-edit {
    background: #f1f3f4;
    color: #3c4043;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cancel-profile-edit:hover {
    background: #e8eaed;
}

/* Edit Profile button styling */
#edit-profile-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

#edit-profile-btn:hover {
    background: #f1f3f4;
    color: var(--color-text);
}

/* Mark All Read Button - Consistent styling */
#mark-all-read-btn {
    width: 100%;
    padding: 12px 20px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 20px;
}

#mark-all-read-btn:hover {
    background: #f1f3f4;
    border-color: #c1c7cd;
    color: var(--color-text);
}

/* Chat Date Dividers */
.chat-date-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: #5f6368;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-date-divider::before,
.chat-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #dadce0;
}

.chat-date-divider::before {
    margin-right: 16px;
}

.chat-date-divider::after {
    margin-left: 16px;
}

/* Consistent Input Styling */
input,
textarea,
select {
    font-family: var(--font-body);
}

/* Consistent Button Font */
button {
    font-family: var(--font-body);
}

/* Transaction amount styling */
.positive-amount {
    color: var(--color-success);
    font-weight: 600;
}

.negative-amount {
    color: var(--color-danger);
    font-weight: 600;
}

/* Loading state for tree */
#category-tree-container.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* Improved notification item styling */
.notification-item {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.notification-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.notification-item.unread {
    border-left: 4px solid var(--color-primary);
    background: #f8f9ff;
}

/* Boost info in task detail */
.boost-info {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    padding: 12px;
    margin-top: 16px;
    font-size: 14px;
}

.boost-info h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #856404;
}

.boost-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.boost-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    color: #5f6368;
}

/* ==========================================================================
   BLOCK 15: MESSAGE CONTEXT MENU
   ========================================================================== */
.msg-context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 5000;
    min-width: 150px;
    overflow: hidden;
    animation: dropIn 0.15s ease-out;
}

.msg-context-menu div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text);
    transition: background 0.15s;
}

.msg-context-menu div:hover {
    background: #f1f3f4;
}

.msg-context-menu div .material-symbols-outlined {
    font-size: 18px;
}

/* Reply preview in message bubble */
.reply-preview {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--color-primary);
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 0 4px 4px 0;
    font-size: 12px;
    color: var(--color-text-secondary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Global Loader */
#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
}

#global-loader .loader-icon {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#global-loader span {
    color: var(--color-text-secondary);
    font-size: 14px;
}

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

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

/* ==========================================================================
   BLOCK 16: UI POLISH & REFINEMENTS
   ========================================================================== */

/* Borderless buttons until hover - general principle */
.icon-btn {
    background: transparent;
    border: none !important;
    border-radius: 50%;
    transition: background 0.15s, transform 0.1s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Edit profile button - no border */
#edit-profile-btn {
    background: transparent;
    border: none !important;
}

#edit-profile-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Emoji picker - better positioning */
.emoji-picker {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    padding: 8px 12px;
    z-index: 6000;
    display: flex;
    gap: 4px;
    transform: translateX(-50%);
}

.emoji-picker span {
    font-size: 24px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: transform 0.15s, background 0.15s;
}

.emoji-picker span:hover {
    background: #f1f3f4;
    transform: scale(1.25);
}

/* Chrome-style PDF Viewer */
#pdf-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #525659;
    z-index: 5000;
    display: none;
    flex-direction: column;
}

.pdf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #323639;
    color: white;
    height: 48px;
}

.pdf-toolbar .pdf-title {
    font-size: 14px;
    font-weight: 500;
    color: white;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-toolbar .pdf-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-toolbar button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.pdf-toolbar button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.pdf-toolbar .zoom-display {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    min-width: 50px;
    text-align: center;
}

#pdf-canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    gap: 16px;
    background: #525659;
}

.pdf-page-container {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    background: white;
}

/* Improved Purchase Modal */
#purchase-modal-backdrop,
#transfer-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 5000;
    display: none;
    justify-content: center;
    align-items: center;
}

#purchase-modal-backdrop .modal-content,
#transfer-modal-backdrop .modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    text-align: center;
}

#purchase-modal-backdrop h3,
#transfer-modal-backdrop h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 500;
}

#purchase-modal-backdrop .modal-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #e8f0fe, #d2e3fc);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

#purchase-modal-backdrop .modal-icon .material-symbols-outlined {
    font-size: 32px;
    color: var(--color-primary);
}

#purchase-modal-backdrop p {
    color: var(--color-text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}

.modal-buttons-centered {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-buttons-centered button {
    padding: 12px 32px;
    border-radius: 24px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-buttons-centered .btn-cancel {
    background: #f1f3f4;
    border: none;
    color: var(--color-text);
}

.modal-buttons-centered .btn-cancel:hover {
    background: #e8eaed;
}

.modal-buttons-centered .btn-primary {
    background: var(--color-primary);
    border: none;
    color: white;
}

.modal-buttons-centered .btn-primary:hover {
    background: #1557b0;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

/* Transfer Modal Form */
#transfer-modal-backdrop .form-group {
    margin-bottom: 16px;
    text-align: left;
}

#transfer-modal-backdrop label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

#transfer-modal-backdrop input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#transfer-modal-backdrop input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* Tags with # prefix */
.task-tag::before {
    content: '#';
}

.task-tag {
    background: #e8f0fe;
    color: var(--color-primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Reply preview improvement */
.reply-preview {
    background: rgba(26, 115, 232, 0.08);
    border-left: 3px solid var(--color-primary);
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: var(--color-text-secondary);
    font-style: italic;
}

/* Spinner in favicon area */
.favicon-loader {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 24px;
    height: 24px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 9999;
    display: none;
}

/* ==========================================================================
   MOBILE RESPONSIVE STYLES - Vercel Cost Optimization
   Optimized for reduced horizontal space on mobile devices
   ========================================================================== */

@media screen and (max-width: 768px) {

    /* --- TREE VIEW MOBILE OPTIMIZATION --- */
    /* Reduce indentation from 24px to 8px for phone screens */
    #category-tree-container ul {
        padding-left: 8px;
    }

    /* Reduce the horizontal connector lines */
    .category-item::before,
    .file-item::before {
        left: -8px;
        width: 6px;
    }

    /* Slightly smaller font for deep nesting */
    .category-name {
        font-size: 0.9rem;
        padding: 5px 6px;
    }

    .file-link {
        font-size: 0.85rem;
        padding: 5px 8px;
    }

    /* Reduce level-0 root item size on mobile */
    .level-0>.category-name {
        font-size: 1.1rem;
    }

    .level-1>.category-name {
        font-size: 1rem;
    }

    /* --- ACCOUNT/DASHBOARD GRIDS --- */
    /* Stack stats cards vertically instead of 3-column */
    .stats-grid,
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Make stat cards more compact */
    .stat-card,
    .dashboard-card {
        padding: 1rem;
    }

    .stat-card p,
    .dashboard-card p {
        font-size: 1.5rem;
    }

    /* --- TASK BOARD MOBILE --- */
    /* Stack task layout vertically */
    .tasks-layout {
        flex-direction: column !important;
    }

    /* Collapsible task sidebar */
    .tasks-sidebar {
        width: 100% !important;
        min-width: unset !important;
        max-height: 200px;
        overflow-y: auto;
        border-right: none !important;
        border-bottom: 1px solid #e0e0e0;
        padding: 10px !important;
    }

    /* Hide filter labels on mobile, show icons only */
    .tasks-sidebar .filter-group h4 {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }

    .tasks-sidebar ul {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .tasks-sidebar .filter-item {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Create task button compact */
    #create-task-btn {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        margin-bottom: 10px !important;
    }

    /* Task main area */
    .tasks-main {
        padding: 10px !important;
    }

    /* Task detail panel - slide over from right */
    #task-detail-panel {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* --- CHAT VIEW MOBILE --- */
    /* Sidebar collapsed on mobile */
    .chat-sidebar {
        width: 60px !important;
        min-width: 60px !important;
    }

    /* Hide text elements in collapsed sidebar */
    .chat-sidebar .btn-text,
    .chat-sidebar .sidebar-section-label,
    .chat-sidebar .contact-info,
    .chat-sidebar .contact-name {
        display: none !important;
    }

    /* Center align "New Chat" button when collapsed */
    .chat-sidebar>div:first-child {
        padding: 8px !important;
        display: flex;
        justify-content: center;
    }

    .chat-sidebar #new-chat-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 auto !important;
    }

    /* Center align contact items in collapsed sidebar */
    #chat-contacts-list {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .chat-sidebar .contact-item {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        margin: 4px 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
    }

    .chat-sidebar .contact-item .avatar {
        margin: 0 !important;
    }

    /* Hide sidebar toggle on mobile - always collapsed */
    #sidebar-toggle-btn {
        display: none;
    }

    /* Message bubbles take more width on mobile */
    .message-bubble {
        max-width: 85%;
    }

    /* Chat header search - hide or shrink */
    .chat-header-search {
        display: none;
    }

    /* --- HEADER MOBILE --- */
    #repo-logo {
        height: 50px;
    }

    #app-header,
    #app-header-account {
        padding: 0.5rem 0;
        margin-bottom: 1rem;
        height: auto;
    }

    /* --- MODALS MOBILE --- */
    #purchase-modal,
    .modal-content {
        width: 90%;
        max-width: 320px;
        padding: 1.5rem;
    }

    /* Form wrapper for auth pages */
    .form-wrapper {
        padding: 2rem 1.5rem;
        margin: 0 10px;
    }

    /* --- TRANSACTIONS TABLE MOBILE --- */
    #transactions-table {
        font-size: 0.85rem;
    }

    #transactions-table th,
    #transactions-table td {
        padding: 10px 6px;
    }

    /* --- PDF VIEWER MOBILE --- */
    .pdf-toolbar {
        height: 50px;
        padding: 0 8px;
    }

    .pdf-toolbar-group {
        gap: 4px;
    }

    #pdf-title {
        font-size: 0.85rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* --- NOTIFICATIONS MOBILE --- */
    .notification-item {
        padding: 12px;
    }

    .mark-read-btn {
        top: 10px;
        right: 10px;
        width: 28px;
        height: 28px;
    }
}

/* Extra small devices (phones in portrait) */
@media screen and (max-width: 480px) {
    #category-tree-container ul {
        padding-left: 6px;
    }

    .category-item::before,
    .file-item::before {
        left: -6px;
        width: 4px;
    }

    .category-name {
        font-size: 0.85rem;
        padding: 4px 5px;
    }

    .file-link {
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    /* Make icons smaller */
    .material-symbols-outlined {
        font-size: 18px;
    }

    /* Hide transaction description on very small screens */
    #transactions-table td:nth-child(2),
    #transactions-table th:nth-child(2) {
        display: none;
    }

    /* Task sidebar even more compact */
    .tasks-sidebar {
        max-height: 150px;
    }
}

/* ==========================================================================
   CHAT SIDEBAR ALIGNMENT FIX (All screen sizes when collapsed)
   ========================================================================== */

/* Collapsed state alignment */
.chat-sidebar.collapsed {
    width: 60px !important;
}

.chat-sidebar.collapsed>div:first-child {
    padding: 8px;
    display: flex;
    justify-content: center;
}

.chat-sidebar.collapsed #new-chat-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.chat-sidebar.collapsed .btn-text,
.chat-sidebar.collapsed .sidebar-section-label,
.chat-sidebar.collapsed .contact-info,
.chat-sidebar.collapsed .contact-name {
    display: none;
}

.chat-sidebar.collapsed #chat-contacts-list {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-sidebar.collapsed .contact-item {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.chat-sidebar.collapsed .contact-item .avatar {
    margin: 0;
}

/* ==========================================================================
   MOBILE RESPONSIVE STYLES
   ========================================================================== */
@media (max-width: 768px) {

    /* Chat View - Mobile: Show contacts list first, then chat */
    #chat-view .chat-body {
        flex-direction: column;
    }

    #chat-view .chat-sidebar {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid #dadce0;
        max-height: 100%;
        flex-shrink: 0;
    }

    /* When a chat is active, hide sidebar and show main */
    #chat-view.chat-active .chat-sidebar {
        display: none;
    }

    #chat-view.chat-active .chat-main {
        display: flex;
        flex-direction: column;
    }

    /* When no chat is active, hide main and show sidebar */
    #chat-view:not(.chat-active) .chat-main {
        display: none;
    }

    #chat-view:not(.chat-active) .chat-sidebar {
        display: flex;
        height: 100%;
    }

    /* Make chat contacts list scrollable */
    #chat-view .chat-sidebar #chat-contacts-list {
        overflow-y: auto;
        flex-grow: 1;
    }

    /* Mobile chat header - add back button */
    #chat-view.chat-active #active-chat-header {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    /* Collapse sidebar toggle not needed on mobile */
    #chat-view #sidebar-toggle {
        display: none;
    }

    /* Tasks view mobile improvements */
    #task-lists-panel {
        padding: 12px 8px;
    }

    .task-card {
        padding: 14px;
    }

    .task-card .task-title {
        font-size: 15px;
    }

    .task-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Multi-select bar - make buttons smaller on mobile */
    .multi-select-bar {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: wrap;
        max-width: 95%;
    }

    .multi-select-bar button {
        padding: 6px 10px;
        font-size: 12px;
    }

    .multi-select-bar button .material-symbols-outlined {
        font-size: 16px;
    }

    /* Dashboard grid - 2 columns on mobile */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .balance-card {
        grid-column: span 2;
    }

    /* ==========================================================================
       MOBILE CHAT - Google Chat style with names visible
       ========================================================================== */

    /* Chat body - full vertical layout */
    #chat-view .chat-body {
        flex-direction: column;
    }

    /* Sidebar takes full width on mobile, shows as contact list */
    #chat-view .chat-sidebar {
        width: 100% !important;
        border-right: none;
        flex-shrink: 0;
    }

    /* NEVER collapse sidebar on mobile - always show full names */
    #chat-view .chat-sidebar.collapsed {
        width: 100% !important;
    }

    #chat-view .chat-sidebar.collapsed .btn-text,
    #chat-view .chat-sidebar.collapsed .sidebar-section-label,
    #chat-view .chat-sidebar.collapsed .contact-info {
        display: block !important;
    }

    #chat-view .chat-sidebar.collapsed #new-chat-btn {
        width: auto !important;
        height: auto !important;
        border-radius: 24px !important;
        padding: 0 24px 0 16px !important;
        justify-content: flex-start !important;
    }

    #chat-view .chat-sidebar.collapsed .contact-item {
        width: 100% !important;
        height: auto !important;
        border-radius: 0 !important;
        padding: 12px 16px !important;
        justify-content: flex-start !important;
    }

    #chat-view .chat-sidebar.collapsed .contact-item .avatar {
        margin-right: 12px;
    }

    /* Contact list styling for mobile */
    #chat-view #chat-contacts-list {
        flex-grow: 1;
        overflow-y: auto;
    }

    #chat-view .contact-item {
        padding: 12px 16px;
        border-bottom: 1px solid #f0f0f0;
    }

    /* Hide sidebar toggle on mobile */
    #chat-view #sidebar-toggle {
        display: none !important;
    }

    /* When a chat is active, hide contacts and show chat */
    #chat-view.chat-active .chat-sidebar {
        display: none !important;
    }

    #chat-view.chat-active .chat-main {
        display: flex !important;
        flex-direction: column;
    }

    /* When no chat active, show contacts, hide chat */
    #chat-view:not(.chat-active) .chat-main {
        display: none !important;
    }

    #chat-view:not(.chat-active) .chat-sidebar {
        display: flex !important;
        height: 100%;
    }

    /* ==========================================================================
       MOBILE PROFILE PAGE FIXES
       ========================================================================== */

    /* Profile header - prevent edit button from breaking layout */
    .profile-header {
        flex-wrap: wrap !important;
        gap: 12px;
    }

    .profile-display-row,
    .profile-edit-row {
        flex-wrap: wrap !important;
        gap: 8px;
    }

    /* Edit button - position properly on mobile */
    #edit-profile-btn {
        position: absolute !important;
        top: 16px;
        right: 16px;
    }

    /* Balance card - prevent overflow */
    .balance-display {
        font-size: 24px !important;
        word-break: break-word;
    }

    .profile-section {
        padding: 16px !important;
        overflow: hidden;
    }

    /* Stats grid - make responsive */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* Transactions table - horizontal scroll */
    .transactions-table-wrapper {
        overflow-x: auto !important;
    }

    /* Input field - full width on mobile */
    #profile-username {
        min-width: 150px !important;
        flex: 1 !important;
    }
}

/* ==========================================================================
   HIDE REFRESH BUTTONS GLOBALLY
   (No longer needed since we're off Vercel - logic remains for future use)
   ========================================================================== */
#refresh-tree-btn,
#refresh-profile-btn,
#chat-refresh-btn,
#refresh-tasks-btn,
#refresh-notifications-btn {
    display: none !important;
}

/* ==========================================================================
   PROFILE PAGE - FIX EDIT BUTTON POSITIONING
   ========================================================================== */
#app-header-account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

#app-header-account h2 {
    flex: 1;
    text-align: center;
    margin: 0;
}

/* Profile header card - proper layout */
.profile-header-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    position: relative;
}

.profile-info-edit {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-display-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Edit button - don't overlap with header */
#edit-profile-btn {
    flex-shrink: 0;
}

/* ==========================================================================
   PROFILE EDIT - BETTER LAYOUT
   ========================================================================== */
.profile-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.profile-edit-row #profile-username {
    flex: 1;
    min-width: 0;
    max-width: 200px;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

.edit-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.edit-actions #cancel-profile-edit {
    order: 1;
}

.edit-actions #save-profile-btn {
    order: 2;
}

/* ==========================================================================
   NEW CHAT BUTTON - ROUNDED PILL STYLE
   ========================================================================== */
.new-chat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.new-chat-pill:hover {
    background: #1557b0;
}

.new-chat-pill .material-symbols-outlined {
    font-size: 20px;
}

/* ==========================================================================
   CHAT HEADER STYLES (WhatsApp-like)
   ========================================================================== */
#active-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

#chat-back-btn {
    display: none;
    /* Hidden on desktop */
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
}

#chat-user-name {
    font-weight: 500;
    font-size: 16px;
    color: #333;
}

/* ==========================================================================
   MOBILE CHAT - WHATSAPP STYLE 
   ========================================================================== */
@media (max-width: 768px) {

    /* Hide global chat header on mobile when in a chat */
    #chat-view.chat-active .chat-global-header {
        display: none !important;
    }

    /* Chat container - full height */
    #chat-view {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
    }

    /* Chat body - fill remaining space */
    #chat-view .chat-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    /* Sidebar (contact list) - full width on mobile */
    #chat-view .chat-sidebar {
        width: 100% !important;
        height: 100%;
        display: flex;
        flex-direction: column;
        border-right: none;
    }

    /* Never collapse on mobile */
    #chat-view .chat-sidebar.collapsed {
        width: 100% !important;
    }

    #chat-view .chat-sidebar.collapsed .btn-text,
    #chat-view .chat-sidebar.collapsed .sidebar-section-label,
    #chat-view .chat-sidebar.collapsed .contact-info {
        display: block !important;
    }

    /* Sidebar header */
    #chat-view .sidebar-header {
        padding: 16px;
    }

    /* NEW CHAT BUTTON - ROUNDED RECTANGLE */
    #chat-view .new-chat-pill {
        width: 100%;
        justify-content: center;
    }

    /* Hide sidebar toggle on mobile */
    #chat-view #sidebar-toggle,
    #sidebar-toggle-btn {
        display: none !important;
    }

    /* Contact list - scrollable */
    #chat-view #chat-contacts-list {
        flex: 1;
        overflow-y: auto;
        padding: 0;
    }

    /* CONTACT ITEMS - RECTANGLES WITH AVATAR + NAME + PREVIEW */
    #chat-view .contact-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        padding: 12px 16px;
        border-bottom: 1px solid #f0f0f0;
        gap: 12px;
        width: 100% !important;
        height: auto !important;
        border-radius: 0 !important;
        background: white;
        cursor: pointer;
        transition: background 0.2s;
    }

    #chat-view .contact-item:hover,
    #chat-view .contact-item:active {
        background: #f5f5f5;
    }

    #chat-view .contact-item .avatar {
        width: 48px !important;
        height: 48px !important;
        flex-shrink: 0;
        border-radius: 50%;
    }

    #chat-view .contact-item .contact-info {
        flex: 1;
        min-width: 0;
        display: flex !important;
        flex-direction: column;
        gap: 4px;
    }

    #chat-view .contact-item .contact-name {
        font-weight: 500;
        font-size: 15px;
        color: #333;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block !important;
    }

    #chat-view .contact-item .contact-preview {
        font-size: 13px;
        color: #666;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* When chat is active - show chat, hide everything else */
    #chat-view.chat-active .chat-sidebar {
        display: none !important;
    }

    #chat-view.chat-active .chat-main {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    /* When no chat - show contacts, hide chat main */
    #chat-view:not(.chat-active) .chat-main {
        display: none !important;
    }

    #chat-view:not(.chat-active) .chat-sidebar {
        display: flex !important;
    }

    /* Chat main - proper layout */
    #chat-view .chat-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    /* ACTIVE CHAT HEADER - WHATSAPP STYLE */
    #chat-view #active-chat-header {
        padding: 10px 12px;
        display: flex;
        align-items: center;
        gap: 12px;
        border-bottom: 1px solid #e0e0e0;
        flex-shrink: 0;
        background: #f8f9fa;
    }

    /* Show back button on mobile */
    #chat-back-btn {
        display: flex !important;
        padding: 8px;
    }

    #chat-view .chat-avatar {
        width: 40px;
        height: 40px;
    }

    /* Message container - scrollable, fills space */
    #chat-view #dm-messages {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
        min-height: 0;
    }

    /* Message input - FIXED AT BOTTOM */
    #chat-view #dm-form-container {
        flex-shrink: 0;
        padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid #e0e0e0;
        background: #fff;
    }

    #chat-view #dm-form {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    #chat-view #dm-input {
        flex: 1;
        padding: 10px 16px;
        border-radius: 24px;
        border: 1px solid #e0e0e0;
        font-size: 15px;
        min-height: 40px;
    }

    #chat-view #dm-send-btn {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: #1a73e8;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
    }

    /* Empty state centered */
    #chat-view #chat-empty-state {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    /* ==========================================================================
       PROFILE EDIT PEN - proper positioning on mobile
       ========================================================================== */
    .profile-header-card {
        position: relative;
    }

    .profile-display-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .profile-current-name {
        font-size: 18px;
        font-weight: 500;
        word-break: break-word;
    }

    /* Pen stays after name when it fits */
    #edit-profile-btn {
        flex-shrink: 0;
    }

    /* ==========================================================================
       NEW CHAT BUTTON - FULL WIDTH ROUNDED RECTANGLE on mobile
       ========================================================================== */
    #chat-view .new-chat-pill {
        display: flex !important;
        width: 100% !important;
        padding: 12px 20px !important;
        border-radius: 24px !important;
        justify-content: center !important;
        gap: 8px !important;
    }

    #chat-view .new-chat-pill .material-symbols-outlined {
        font-size: 20px;
    }

    #chat-view .new-chat-pill .btn-text {
        display: inline !important;
    }

    /* Chat avatar - smaller on mobile */
    #chat-view .contact-item .avatar {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }
}

/* ==========================================================================
   POLISHED AUTH FORMS
   ========================================================================== */
#auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.auth-form h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    text-align: center;
}

.auth-subtitle {
    color: #666;
    font-size: 14px;
    text-align: center;
    margin: 0 0 20px 0;
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.input-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.input-group input::placeholder {
    color: #999;
}

/* Password visibility toggle */
.password-group {
    position: relative;
}

.password-group input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    padding: 4px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.toggle-password:hover {
    opacity: 1;
    color: #333;
}

.toggle-password:focus,
.toggle-password:focus-visible,
.toggle-password:active,
.toggle-password:focus-within {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

.toggle-password .material-symbols-outlined {
    font-size: 18px;
    color: #666;
}

.auth-btn {
    width: 100%;
    padding: 14px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.auth-btn:hover {
    background: #1557b0;
}

.auth-btn:active {
    transform: scale(0.98);
}

.auth-links {
    margin-top: 20px;
    text-align: center;
}

.auth-links p {
    margin: 8px 0;
    color: #666;
    font-size: 14px;
}

.auth-links a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

#message-area {
    margin-top: 16px;
    text-align: center;
    color: var(--color-danger);
    font-size: 14px;
}

/* ==========================================================================
   CIRCULAR ELEMENTS - PRESERVE ASPECT RATIO (No Ovals!)
   ========================================================================== */
.spinner,
.avatar,
.loader-icon,
.profile-avatar-large,
.chat-avatar,
.contact-item .avatar {
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important;
    min-width: unset;
    min-height: unset;
}

/* Ensure spinners stay circular */
.spinner {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
}

.spinner.large {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
}

/* Loader icon in global loader */
.loader-icon {
    width: 40px !important;
    height: 40px !important;
}

/* Profile avatar - fixed size */
.profile-avatar-large {
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
}

/* ==========================================================================
   TREE SKELETON - Many thin lines layout
   ========================================================================== */
.skeleton-tree {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.skeleton-tree-item {
    height: 10px;
    margin-bottom: 14px;
    border-radius: 4px;
}

/* ==========================================================================
   MOBILE AUTH RESPONSIVE
   ========================================================================== */
@media (max-width: 480px) {
    .auth-card {
        padding: 30px 24px;
        border-radius: 12px;
    }

    .auth-logo-img {
        width: 60px;
        height: 60px;
    }

    .auth-form h2 {
        font-size: 20px;
    }

    .input-group input {
        padding: 12px 14px;
        font-size: 14px;
    }

    .auth-btn {
        padding: 12px;
        font-size: 15px;
    }
}

/* ==========================================================================
   SETTINGS PAGE
   ========================================================================== */
#settings-view {
    min-height: 100vh;
    background: var(--color-bg);
}

#settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.settings-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.settings-section {
    background: var(--color-surface);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--color-border);
}

.settings-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-section h3 .material-symbols-outlined {
    font-size: 18px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

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

.settings-item-info {
    flex: 1;
}

.settings-item-label {
    display: block;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 2px;
}

.settings-item-desc {
    display: block;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.settings-btn {
    padding: 8px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.settings-btn:hover {
    opacity: 0.9;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(22px);
}