/* ==========================================================================
   CollabSpace - Modern CSS Stylesheet
   ========================================================================== */

/* --- Theme Variables & Design Tokens --- */
.light-theme {
    --bg-app: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-on-sidebar: #f8fafc;
    --text-on-sidebar-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-light-text: #1e40af;
    
    --success: #16a34a;
    --success-light: #f0fdf4;
    --success-light-text: #166534;
    
    --warning: #ca8a04;
    --warning-light: #fef9c3;
    --warning-light-text: #854d0e;
    
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --danger-light-text: #991b1b;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --scroll-track: #f1f5f9;
    --scroll-thumb: #cbd5e1;
    --scroll-thumb-hover: #94a3b8;
}

.dark-theme {
    --bg-app: #0b0f19;
    --bg-surface: #151f32;
    --bg-surface-hover: #1e2d4a;
    --bg-sidebar: #0b0f19;
    --bg-sidebar-hover: #151f32;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-on-sidebar: #f8fafc;
    --text-on-sidebar-muted: #64748b;
    --border-color: #23334c;
    --border-focus: #3b82f6;
    
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: rgba(59, 130, 246, 0.1);
    --primary-light-text: #93c5fd;
    
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.1);
    --success-light-text: #86efac;
    
    --warning: #eab308;
    --warning-light: rgba(234, 179, 8, 0.1);
    --warning-light-text: #fde047;
    
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --danger-light-text: #fca5a5;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);

    --scroll-track: #151f32;
    --scroll-thumb: #23334c;
    --scroll-thumb-hover: #3b82f6;
}

/* --- Base Resets & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-app);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
}

/* --- Utilities --- */
.hidden {
    display: none !important;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.bold { font-weight: 600; }
.text-muted { color: var(--text-muted); }

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scroll-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-thumb-hover);
}

/* --- Application Layout Shell --- */
#app-root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.shell-wrapper {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-on-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-on-sidebar);
}

.logo-icon {
    width: 26px;
    height: 26px;
    color: var(--primary);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 24px 16px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-on-sidebar-muted);
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s;
}

.nav-link:hover, .nav-link.active {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-on-sidebar);
}

.nav-link.active {
    border-left: 3px solid var(--primary);
}

.nav-icon {
    color: inherit;
}

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-danger {
    background-color: var(--danger);
    color: #ffffff;
    margin-left: auto;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(0, 0, 0, 0.15);
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.user-profile-summary .info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-profile-summary .name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-on-sidebar);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-summary .role {
    font-size: 11px;
    color: var(--text-on-sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-sidebar-muted);
    background-color: rgba(255, 255, 255, 0.03);
    transition: background-color 0.2s, color 0.2s;
}

.control-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-on-sidebar);
}

.text-danger-btn:hover {
    color: var(--danger) !important;
    background-color: rgba(220, 38, 38, 0.1);
}

/* Work Area & Layout */
.work-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100vh;
    overflow: hidden;
}

/* Top Navbar Styling */
.top-navbar {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 90;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-search {
    position: relative;
    width: 260px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.navbar-search input {
    width: 100%;
    height: 38px;
    padding: 0 16px 0 38px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s, background-color 0.2s;
}

.navbar-search input:focus {
    border-color: var(--border-focus);
    background-color: var(--bg-surface);
}

.nav-action-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.nav-action-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--danger);
    color: white;
    font-size: 10px;
    height: 16px;
    min-width: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-surface);
}

/* Notification Dropdown */
.notification-center {
    position: relative;
}

.notifications-dropdown {
    position: absolute;
    right: 0;
    top: 48px;
    width: 360px;
    max-height: 480px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.text-btn {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
}

.text-btn:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.dropdown-body {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.notification-item:hover {
    background-color: var(--bg-surface-hover);
}

.notification-item.unread {
    background-color: var(--primary-light);
}

.notification-item .icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-item .content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notification-item .title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.notification-item .desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.notification-item .time {
    font-size: 10px;
    color: var(--text-muted);
}

.dropdown-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
}

/* Avatar Utilities */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
    background-color: var(--primary);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    font-size: 24px;
}

.avatar-group {
    display: flex;
    align-items: center;
    margin-left: 6px;
}

.avatar-group .avatar {
    margin-left: -6px;
    border: 2px solid var(--bg-surface);
}

/* Content Container */
.content-container {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
    background-color: var(--bg-app);
}

/* --- DASHBOARD VIEW --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1-indexed); /* We can write 1fr 1fr 1fr 1fr */
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-info .value {
    font-size: 28px;
    font-weight: 700;
    margin: 4px 0;
}

.stat-info .label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-row {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

.dashboard-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

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

.panel-title {
    font-size: 16px;
    font-weight: 700;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.activity-content {
    flex-grow: 1;
}

.activity-text {
    font-size: 13px;
    color: var(--text-primary);
}

.activity-text strong {
    font-weight: 600;
}

.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Quick project widgets */
.widget-projects-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.widget-project-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.widget-project-card:hover {
    background-color: var(--bg-surface-hover);
}

.widget-project-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.widget-project-title {
    font-weight: 600;
    font-size: 13px;
}

.widget-project-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Status Badge Styles */
.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-active {
    background-color: var(--primary-light);
    color: var(--primary-light-text);
}

.status-completed {
    background-color: var(--success-light);
    color: var(--success-light-text);
}

.status-hold {
    background-color: var(--warning-light);
    color: var(--warning-light-text);
}

/* Priority Badge Styles */
.priority-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.priority-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.priority-high::before { background-color: var(--danger); }
.priority-medium::before { background-color: var(--warning); }
.priority-low::before { background-color: var(--success); }


/* --- PROJECTS VIEW --- */
.view-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.search-filters-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    height: 38px;
    padding: 0 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

.filter-select:focus {
    border-color: var(--border-focus);
}

/* Project Buttons */
.btn {
    height: 38px;
    padding: 0 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s, transform 0.1s;
}

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

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.btn-danger {
    background-color: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.1);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

/* Grid & Cards layout */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.project-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 250px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.project-card-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.project-card-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    flex-grow: 1;
}

.project-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: auto;
}

.owner-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.project-stats {
    display: flex;
    gap: 12px;
    color: var(--text-muted);
}

.project-stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

/* Empty State Styling */
.empty-state {
    padding: 64px 32px;
    text-align: center;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    max-width: 500px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}


/* --- PROJECT DETAIL VIEW --- */
.detail-header {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.detail-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.detail-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.detail-title {
    font-size: 26px;
    font-weight: 700;
}

.detail-description {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 900px;
    line-height: 1.6;
}

.detail-stats-bar {
    display: flex;
    gap: 32px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.detail-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-stat .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.detail-stat .value {
    font-size: 14px;
    font-weight: 600;
}

/* Tabs Navigation */
.tabs-navigation {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    gap: 8px;
}

.tab-btn {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    min-height: 300px;
}

/* Files tab items */
.files-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.file-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.file-card:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--primary);
}

.file-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-card-info {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-card-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.file-action-btn {
    color: var(--text-muted);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-action-btn:hover {
    color: var(--danger);
    background-color: var(--danger-light);
}

/* History list */
.history-timeline {
    position: relative;
    padding-left: 24px;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background-color: var(--border-color);
}

.history-timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.history-timeline-item:last-child {
    margin-bottom: 0;
}

.history-marker {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--bg-surface);
    background-color: var(--primary);
}

.history-item-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-title {
    font-size: 13px;
}

.history-item-title strong {
    font-weight: 600;
}

.history-item-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* Comments Section */
.comments-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-card {
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.comment-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.comment-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comment-author-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-author-name {
    font-weight: 600;
}

.comment-author-role {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.comment-time {
    font-size: 11px;
    color: var(--text-muted);
}

.comment-content {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.comment-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 8px;
    font-size: 12px;
    width: max-content;
    max-width: 100%;
}

.comment-attachment:hover {
    border-color: var(--primary);
}

.comment-actions {
    margin-top: 4px;
}

.comment-action-link {
    font-size: 11px;
    color: var(--danger);
    font-weight: 500;
}

.comment-action-link:hover {
    text-decoration: underline;
}

/* Comment Box */
.comment-input-area {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    position: relative;
}

.comment-box-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-textarea-container {
    position: relative;
    width: 100%;
}

.comment-textarea-container textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    resize: vertical;
    background-color: var(--bg-app);
    transition: border-color 0.2s, background-color 0.2s;
}

.comment-textarea-container textarea:focus {
    border-color: var(--border-focus);
    background-color: var(--bg-surface);
}

.comment-box-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comment-attachment-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

.comment-attachment-trigger:hover {
    color: var(--primary);
}

.comment-attached-preview {
    font-size: 12px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-attached-preview button {
    color: var(--danger);
    font-weight: bold;
}

/* Autocomplete styling for @mentions */
.mention-suggestions {
    position: absolute;
    bottom: calc(100% - 10px);
    left: 0;
    width: 220px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 150;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.suggestion-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 13px;
}

.suggestion-item:hover, .suggestion-item.selected {
    background-color: var(--bg-surface-hover);
}

.suggestion-item .name {
    font-weight: 500;
}

.suggestion-item .handle {
    color: var(--text-muted);
    font-size: 11px;
}


/* --- MESSAGING VIEW --- */
.messaging-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 134px); /* Fills main content perfectly */
    overflow: hidden;
}

/* Chats Sidebar */
.chats-sidebar {
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: var(--bg-surface);
}

.chats-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.chats-search {
    position: relative;
}

.chats-search input {
    width: 100%;
    height: 36px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 12px 0 32px;
    font-size: 13px;
}

.chats-search .search-icon {
    left: 10px;
}

.chats-list-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-category-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 16px 6px;
    font-weight: 600;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: var(--bg-surface-hover);
}

.chat-item.active {
    background-color: var(--primary-light);
}

.chat-item-avatar-wrapper {
    position: relative;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-muted);
    border: 2px solid var(--bg-surface);
}

.status-dot.online {
    background-color: var(--success);
}

.chat-item-body {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.chat-item-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-item-preview-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-item-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.active .chat-item-preview {
    color: var(--primary-light-text);
}

.chat-badge {
    background-color: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 600;
    height: 16px;
    min-width: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    flex-shrink: 0;
}

/* Chat Main Area */
.chat-main-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-app);
}

.chat-header {
    height: 60px;
    padding: 0 24px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-name {
    font-weight: 700;
    font-size: 15px;
}

.chat-header-sub {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Messages List Panel */
.chat-messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    gap: 4px;
}

.message-bubble-wrapper.received {
    align-self: flex-start;
}

.message-bubble-wrapper.sent {
    align-self: flex-end;
}

.message-sender-name {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 4px;
}

.message-bubble {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.received .message-bubble {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}

.sent .message-bubble {
    background-color: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.message-meta {
    font-size: 10px;
    color: var(--text-muted);
    align-self: flex-end;
    margin-top: 2px;
}

.sent .message-meta {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.typing-indicator-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    background-color: transparent;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: typingPulse 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingPulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Input Bar */
.chat-input-bar {
    padding: 16px 24px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-input-field {
    flex-grow: 1;
    height: 40px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 16px;
    font-size: 13px;
    transition: border-color 0.2s, background-color 0.2s;
}

.chat-input-field:focus {
    border-color: var(--border-focus);
    background-color: var(--bg-surface);
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s, color 0.2s;
}

.chat-action-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

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

.send-btn:hover {
    background-color: var(--primary-hover);
    color: white;
}

.chat-attached-file-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    background-color: var(--primary-light);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
}

.chat-attached-file-name {
    font-weight: 600;
    color: var(--primary-light-text);
}


/* --- USER PROFILE VIEW --- */
.profile-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
}

.profile-card-left {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.profile-avatar-wrapper {
    margin-bottom: 20px;
    position: relative;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-role-badge {
    margin-bottom: 16px;
}

.profile-bio {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.profile-meta-list {
    width: 100%;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.profile-meta-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.profile-meta-icon {
    color: var(--text-muted);
}

/* Profile details right side */
.profile-details-right {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.profile-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}


/* --- MODALS GENERAL STYLING --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-xl);
    animation: modalEntrance 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.close-modal-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background-color 0.2s, color 0.2s;
}

.close-modal-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.modal-form {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.form-group {
    padding: 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-app);
    transition: border-color 0.2s, background-color 0.2s;
    width: 100%;
}

.form-group textarea {
    height: auto;
    padding: 12px 14px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--border-focus);
    background-color: var(--bg-surface);
}

.form-row {
    display: flex;
    padding: 0 12px;
}

.form-row .form-group {
    flex-grow: 1;
}

.col-6 {
    width: 50%;
}

/* Drag and Drop Zone */
.drag-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    background-color: var(--bg-app);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: border-color 0.2s, background-color 0.2s;
    position: relative;
}

.drag-drop-zone:hover, .drag-drop-zone.dragover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.drag-drop-zone.dragover .upload-icon {
    color: var(--primary);
}

.drop-text {
    font-size: 13px;
    margin-bottom: 4px;
}

.browse-link {
    color: var(--primary);
    font-weight: 600;
}

.file-limits-text {
    font-size: 11px;
    color: var(--text-muted);
}

.hidden-file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.uploaded-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
}

.uploaded-file-item .file-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}


/* --- AUTHENTICATION PAGES --- */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background-color: var(--bg-app);
}

.auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    padding: 40px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 16px;
}

.auth-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form .form-group {
    padding: 0;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

.alert-box {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-danger {
    background-color: var(--danger-light);
    color: var(--danger-light-text);
    border: 1px solid rgba(220, 38, 38, 0.1);
}

.avatar-selector {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.avatar-color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid var(--bg-surface);
    box-shadow: 0 0 0 1px var(--border-color);
    transition: transform 0.2s;
}

.avatar-color-option:hover {
    transform: scale(1.15);
}

.avatar-color-option.selected {
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.1);
}


/* --- RESPONSIVE MEDIA QUERIES --- */
.mobile-only-btn {
    display: none;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    .shell-wrapper {
        flex-direction: column;
    }
    
    /* Responsive Navigation drawer for Sidebar */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-only-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 8px;
        color: var(--text-secondary);
        background-color: var(--bg-app);
        border: 1px solid var(--border-color);
    }
    
    #close-sidebar-btn {
        color: var(--text-on-sidebar-muted);
        background-color: transparent;
        border: none;
    }

    .top-navbar {
        padding: 0 16px;
    }
    
    .navbar-search {
        display: none; /* Hide default input on mobile, show on view-action */
    }
    
    .content-container {
        padding: 16px;
    }
    
    .detail-header {
        padding: 20px;
    }
    
    .detail-title {
        font-size: 20px;
    }
    
    .profile-layout {
        grid-template-columns: 1fr;
    }
    
    .profile-form-grid {
        grid-template-columns: 1fr;
    }
    
    .messaging-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 70px); /* Fill screen without top menu */
    }
    
    .messaging-container.chat-active .chats-sidebar {
        display: none;
    }
    
    .messaging-container:not(.chat-active) .chat-main-area {
        display: none;
    }
    
    .chat-back-btn {
        display: flex !important;
        margin-right: 8px;
    }
    
    .form-row {
        flex-direction: column;
        padding: 0;
    }
    
    .col-6 {
        width: 100%;
    }
    
    .modal-card {
        max-height: 95vh;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-stats-bar {
        gap: 16px;
    }
    
    .tab-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .auth-card {
        padding: 24px 16px;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .view-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-filters-group {
        flex-direction: column;
        align-items: stretch;
    }
}
