:root {
    /* Default (Dark Mode) - Deep Black */
    --bg-color: #050505;
    --surface-color: #0f0f0f;
    --surface-hover: #171717;
    --border-color: #222222;
    --text-primary: #f0f0f0;
    --text-secondary: #888888;
    --accent-color: #ffffff;
    --danger-color: #ff3333;

    /* Spacing & Layout */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 40px;
    --border-radius: 12px;
    --max-width: 95%;

    /* Transitions */
    --transition-speed: 0.3s;
}

/* Light Mode Override */
[data-theme="light"] {
    --bg-color: #ffffff;
    --surface-color: #f7f7f7;
    --surface-hover: #eaeaea;
    --border-color: #e0e0e0;
    --text-primary: #171717;
    --text-secondary: #666666;
    --accent-color: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Hide scrollbar globally for IE, Edge and Firefox */
* {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar globally for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease-in-out;
}

.splash-logo {
    font-size: 5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    opacity: 0;
    animation: fadeInOut 2.5s ease-in-out forwards;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    20% {
        opacity: 1;
        transform: scale(1);
    }

    80% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

/* Utilities */
.hidden {
    display: none !important;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    width: 100%;
}

/* Components */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition-speed) ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.btn-primary:hover {
    background-color: #e0e0e0;
    transform: translateY(-1px);
}

/* Dropdown Utilities */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-radius: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background-color: var(--surface-hover);
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(.active) {
    background-color: var(--surface-hover);
    border-color: #333;
}

.btn-secondary.active {
    border-color: var(--text-primary);
    background-color: var(--surface-hover);
}

.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    transition: border-color var(--transition-speed) ease;
}

.card:hover {
    border-color: #333;
}

input,
textarea {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    width: 100%;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus {
    border-color: var(--text-secondary);
}

/* Layout Specifics */
#app {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
}

header {
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-xl);
    background: rgba(5, 5, 5, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Light mode header override */
[data-theme="light"] header {
    background: rgba(255, 255, 255, 0.8);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.nav-links {
    display: flex;
    gap: 32px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

/* Login Page */
#login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-title {
    margin-bottom: var(--spacing-sm);
    font-size: 1.8rem;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    font-size: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.task-item:last-child {
    border-bottom: none;
}

.status-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--surface-hover);
    color: var(--text-secondary);
}

/* Overview Masonry */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--spacing-lg);
}

.project-card {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4/3;
    border-radius: var(--border-radius);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.project-content {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: flex-end;
}

.project-title {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.project-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* RESTORED CHAT HEADER STYLES */
.chat-header {
    padding: 10px 16px;
    background: #202c33;
    border-left: 1px solid #2f3b43;
    display: flex;
    flex-direction: row;
    /* FORCE ROW */
    align-items: center;
    justify-content: flex-start;
    height: 60px;
    gap: 12px;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.chat-header p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}



.chat-header p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Message Bubbles - WhatsApp Style */
/* Message Bubbles - WhatsApp Style */
.message {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    font-size: 0.95rem;
    line-height: 19px;
    position: relative;
    word-break: break-word;
    margin-bottom: 4px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

/* Sent - Green with Tail */
.message.sent {
    align-self: flex-end;
    background: #005c4b;
    /* WhatsApp Dark Sent Green */
    color: #e9edef;
    border-bottom-right-radius: 0;
    margin-right: 10px;
    border-radius: 7.5px;
    /* Reset */
    border-bottom-right-radius: 0;
}

.message.sent::after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    bottom: 0;
    right: -10px;
    border: 10px solid transparent;
    border-bottom: 10px solid #005c4b;
    border-left: 0;
    transform: rotate(0deg);
    clip-path: polygon(0 0, 0% 100%, 100% 100%);
}

/* Received - Dark Grey with Tail */
.message.received {
    align-self: flex-start;
    background: #202c33;
    /* WhatsApp Dark Received */
    color: #e9edef;
    border: none;
    border-bottom-left-radius: 0;
    margin-left: 10px;
    border-radius: 7.5px;
    /* Reset */
    border-bottom-left-radius: 0;
}

.message.received::after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    bottom: 0;
    left: -10px;
    border: 10px solid transparent;
    border-bottom: 10px solid #202c33;
    border-right: 0;
    transform: scaleX(-1);
    clip-path: polygon(0 0, 0% 100%, 100% 100%);
}

/* Light Mode Overrides for WhatsApp Bubbles */
[data-theme="light"] .message.sent {
    background: #d9fdd3;
    /* WhatsApp Light Sent Green */
    color: #111b21;
}

[data-theme="light"] .message.sent::after {
    border-bottom-color: #d9fdd3;
}

[data-theme="light"] .message.received {
    background: #ffffff;
    /* WhatsApp Light Received White */
    color: #111b21;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

[data-theme="light"] .message.received::after {
    border-bottom-color: #ffffff;
}

[data-theme="light"] .chat-main {
    background-color: #efeae2;
    /* WhatsApp Light BG */
    background-blend-mode: normal;
}

[data-theme="light"] .chat-header,
[data-theme="light"] .chat-inputs-area {
    background: #f0f2f5;
    border-left: 1px solid #d1d7db;
}

[data-theme="light"] .chat-sidebar {
    background: #ffffff;
    border-right: 1px solid #d1d7db;
}

[data-theme="light"] .user-item:hover,
[data-theme="light"] .user-item.active {
    background: #f0f2f5;
}

[data-theme="light"] .user-item {
    border-bottom: 1px solid #e9edef;
}

[data-theme="light"] .input-wrapper {
    background: #ffffff;
}

[data-theme="light"] #chat-input {
    color: #111b21;
}

/* Layout Overrides */
.chat-layout {
    position: fixed;
    top: 58px;
    /* Matched to header height */
    left: 0;
    width: 100vw;
    height: calc(100vh - 58px);
    z-index: 50;
    border: none;
    border-radius: 0;
    background: var(--bg-color);
    /* Ensure background is set */
}

.chat-sidebar {
    background: #111b21;
    border-right: 1px solid #2f3b43;
}

.user-item {
    border-bottom: 1px solid #202c33;
    padding: 12px;
}

.user-item:hover {
    background: #202c33;
}

.user-item.active {
    background: #2a3942;
}

/* Input Pill */
.input-wrapper {
    background: #2a3942;
    border-radius: 8px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
}

#chat-input {
    background: transparent;
    border: none;
    color: #d1d7db;
    padding: 9px 12px;
}

#chat-input:focus {
    border: none;
    outline: none;
}

/* Profile Photo */
.profile-photo-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--surface-hover);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    border: 1px solid var(--border-color);
}

#profile-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Chat Layout */
/* Chat Layout - already defined in override above, removing duplicate/conflicting block or ensuring it doesn't conflict */
.chat-layout {
    display: flex;
    /* height is set in the override above */
    gap: 0;
    /* Remove gap for full width feel */
    background: var(--surface-color);
    border: none;
    /* override border */
    overflow: hidden;
}

.chat-sidebar {
    width: 250px;
    background: var(--surface-hover);
    padding: var(--spacing-md);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-hover);
}

.chat-messages {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-input-area {
    padding: var(--spacing-md);
    background: var(--surface-hover);
    border-top: 1px solid var(--border-color);
}

/* User List */
.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-item:hover,
.user-item.active {
    background: var(--bg-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-color);
    color: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.user-status {
    font-size: 0.75rem;
}

.user-status.online {
    color: #4ade80;
}

.user-status.offline {
    color: var(--text-secondary);
}

/* Messages */
.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.message.sent {
    align-self: flex-end;
    background: var(--accent-color);
    color: var(--bg-color);
    border-bottom-right-radius: 2px;
}

.message.received {
    align-self: flex-start;
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.message-meta {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

.system-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 10px 0;
}

/* Input Area */
.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    background: var(--bg-color);
}

.btn-icon {
    font-size: 1.2rem;
    padding: 8px;
    color: var(--text-secondary);
    border-radius: 50%;
}

.btn-icon:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #25D366;
    /* WhatsApp Green, or use var(--accent-color) if preferred */
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
    background-color: #20bd5a;
}

.btn-send svg {
    margin-left: 2px;
    /* Visual alignment for the paper plane */
}

/* File Attachment */
.file-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
}

.file-attachment:hover {
    background: rgba(0, 0, 0, 0.2);
}

.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-color);
    margin-bottom: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}