:root {
    --bg-main: #0f111a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --accent: #7289da;
    --accent-glow: rgba(114, 137, 218, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --status-online: #43b581;
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

button {
    display: flex;
    align-items: center;
    justify-content: center;
}

body {
    background: radial-gradient(circle at top right, #1a1c2c, #0f111a);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-shell {
    width: 100vw;
    height: 100vh;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: 0;
    display: flex;
    box-shadow: none;
    overflow: hidden;
}

/* Sidebar Slim */
.nav-rail {
    width: 80px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    border-right: 1px solid var(--glass-border);
}

.nav-item {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: var(--bg-card);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary);
}

.nav-item:hover, .nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-2px);
}

.unread-rail-item {
    background: none !important;
    box-shadow: none !important;
    animation: bounceIn 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1c2c;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 32px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: modalIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modalIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Secondary Sidebar (Conversations) */
.conv-sidebar {
    width: 300px;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
}

.sidebar-header {
    padding: 24px;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.input-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.input-container button {
    padding: 0;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: color 0.2s;
}

.input-container button:hover {
    color: white !important;
}

.conv-item {
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.conv-item:hover {
    background: var(--bg-card-hover);
}

.conv-item.active {
    background: rgba(255, 255, 255, 0.1);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    object-fit: cover;
    border: 2px solid transparent;
}

.conv-info {
    flex: 1;
}

.conv-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.conv-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Chat Main */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.05);
}

/* Right profile panel */
.profile-panel {
    width: 320px;
    flex-shrink: 0;
    background: #1a1c2c;
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    animation: slideInRight 0.25s ease;
}

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

.banner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.2s;
}

#profile-banner-zone:hover .banner-overlay {
    opacity: 1;
}

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
}

.avatar-upload-overlay:hover {
    opacity: 1;
}


.chat-header {
    height: 80px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
}

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

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
}

/* Message group (avatar + pseudo + messages) */
.msg-group {
    display: flex;
    gap: 14px;
    padding: 1px 16px;
    transition: background 0.15s;
}

/* Hover on individual message lines */
.msg-text {
    font-size: 0.93rem;
    line-height: 1.4;
    color: #dcddde;
    word-break: break-word;
    margin: 0;
    padding: 1px 4px;
    border-radius: 4px;
    cursor: default;
    transition: background 0.1s;
}

.msg-text:hover {
    background: rgba(255,255,255,0.04);
}

.msg-group-avatar {
    flex-shrink: 0;
    width: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 2px;
}

.msg-group-avatar img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

/* Placeholder for grouped messages (no avatar repeat) */
.msg-group-avatar .avatar-placeholder {
    width: 44px;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
    opacity: 0;
}

.msg-group-avatar .avatar-placeholder .msg-time-hover {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.msg-group:hover .avatar-placeholder {
    opacity: 1;
}

.msg-body {
    flex: 1;
    min-width: 0;
}

.msg-group-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}



.msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.msg-author {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.msg-timestamp {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.msg-content {
    font-size: 0.93rem;
    line-height: 1.4;
    color: #dcddde;
    word-break: break-word;
    position: relative;
}

.msg-content:hover::after {
    content: attr(data-edited);
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 6px;
}

.msg-edited-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.msg-group-first {
    margin-top: 14px;
}

/* Compact Mode */
.messages-area.compact-mode .msg-group {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
}
.messages-area.compact-mode .msg-group-first {
    margin-top: 8px;
}
.messages-area.compact-mode .msg-group-avatar img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}
.messages-area.compact-mode .msg-group-avatar {
    width: 28px;
}
.messages-area.compact-mode .msg-header {
    font-size: 0.85rem;
}
.messages-area.compact-mode .msg-text {
    font-size: 0.9rem;
}
.chat-input-wrapper {
    padding: 24px 32px;
}

.input-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.input-container input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    padding: 8px 0;
}

/* Modals / Add Friend */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1c2c;
    padding: 32px;
    border-radius: 24px;
    width: 400px;
    border: 1px solid var(--glass-border);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-discord {
    background: #5865F2;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-discord:hover {
    background: #4752C4;
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(88, 101, 242, 0.3);
}

/* Auth Styles */
.auth-container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(30px);
    padding: 48px;
    border-radius: 32px;
    width: 450px;
    border: 1px solid var(--glass-border);
}

.form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 14px;
    border-radius: 12px;
    color: white;
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Compact Mode */
.messages-area.compact-mode .message-wrapper {
    margin-bottom: 2px !important;
    padding: 2px 32px !important;
}
.messages-area.compact-mode .message-avatar {
    display: none;
}
.messages-area.compact-mode .message-content {
    margin-left: 0 !important;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.messages-area.compact-mode .message-header {
    margin-bottom: 0 !important;
    min-width: fit-content;
}

/* Markdown Styling */
.msg-text b, .msg-text strong { font-weight: 700; color: white; }
.msg-text i, .msg-text em { font-style: italic; }
.msg-text u { text-decoration: underline; }
.msg-text s, .msg-text strike { text-decoration: line-through; opacity: 0.6; }
.msg-text code { 
    background: rgba(0,0,0,0.3); 
    padding: 2px 6px; 
    border-radius: 4px; 
    font-family: monospace; 
    font-size: 0.9em; 
}
.msg-text pre {
    background: #2b2d31;
    border: 1px solid rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: 8px;
    margin: 8px 0;
    overflow-x: auto;
}
.msg-text blockquote {
    border-left: 4px solid #4e5058;
    padding-left: 12px;
    margin: 4px 0;
    color: var(--text-secondary);
}

/* GIF Picker */
.gif-picker {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 340px;
    height: 400px;
    background: #232428;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: none;
    flex-direction: column;
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    overflow: hidden;
}
.gif-search {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}
.gif-results {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
}
.gif-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.1s;
}
.gif-item:hover {
    transform: scale(1.05);
    outline: 2px solid var(--accent);
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(114, 137, 218, 0.4); } 70% { box-shadow: 0 0 0 15px rgba(114, 137, 218, 0); } 100% { box-shadow: 0 0 0 0 rgba(114, 137, 218, 0); } }

/* Badge tooltip */
.badge-icon {
    position: relative;
    font-size: 1.2rem;
    cursor: default;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    transition: background 0.2s, transform 0.15s;
}

.badge-icon:hover {
    background: rgba(255,255,255,0.12);
    transform: scale(1.15);
}

.badge-icon::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1c2c;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    border: 1px solid var(--glass-border);
    z-index: 100;
}

.badge-icon:hover::after {
    opacity: 1;
}

/* Admin broadcast notification animation */
/* Unread Badge */
.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f23f43;
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 12px;
    border: 2px solid #1a1c2c;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}