:root {
    --primary: #2E4467;
    --dark: #0D0D0D;
    --secondary: #1D2C40;
    --accent: #4A6FA5;
    --bg-color: #f9f9f9;
    --text-color: #0D0D0D;
    --card-bg: #ffffff;
    --card-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    --section-alt-bg: #f2f2f2;
    --text-secondary: #666;
    --nav-height: 80px;
    --border-color: #e0e0e0;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #f0f0f0;
    --card-bg: #1e1e1e;
    --card-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    --section-alt-bg: #181818;
    --text-secondary: #b0b0b0;
    --border-color: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    background-color: var(--bg-color);
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Theme Toggle */
.theme-toggle-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
}

#theme-toggle:hover {
    background-color: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 111, 165, 0.3);
}

#theme-toggle svg {
    width: 24px;
    height: 24px;
}

#theme-toggle .sun {
    display: none;
}

[data-theme="dark"] #theme-toggle .moon {
    display: none;
}

[data-theme="dark"] #theme-toggle .sun {
    display: block;
}

/* Main Layout */
.main-content {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.chat-container {
    width: 100%;
    max-width: 1000px;
    height: 90vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

/* Username Section */
.username-section {
    background-color: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.username-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 1;
}

.username-section h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 24px;
}

/* Chat Stats in Username Section */
.chat-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-item i {
    color: var(--accent);
    font-size: 16px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

/* Button Styles */
.btn {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.btn:hover {
    background-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 68, 103, 0.3);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

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

/* Chat Interface */
.chat-interface {
    display: none;
    flex: 1;
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-interface::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 1;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: var(--section-alt-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success-color);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background-color: var(--section-alt-bg);
    border-left: 4px solid var(--accent);
    transition: all 0.2s ease;
    position: relative;
}

.message:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: var(--card-bg);
}

/* User-specific message colors */
.message.user-1 {
    border-left-color: #4A6FA5;
}

.message.user-2 {
    border-left-color: #28a745;
}

.message.user-3 {
    border-left-color: #ffc107;
}

.message.user-4 {
    border-left-color: #dc3545;
}

.message.user-5 {
    border-left-color: #6f42c1;
}

.message.user-6 {
    border-left-color: #fd7e14;
}

.message.user-7 {
    border-left-color: #20c997;
}

.message.user-8 {
    border-left-color: #e83e8c;
}

.message.system {
    border-left-color: var(--accent);
    background-color: rgba(74, 111, 165, 0.1);
}

.message.user {
    border-left-color: var(--primary);
}

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

.username {
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* User badges */
.user-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--accent);
    color: white;
}

/* Special badges - stand out prominently */
.user-badge.Admin {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
    animation: adminGlow 3s ease-in-out infinite alternate;
}

.user-badge.System {
    background: linear-gradient(135deg, #4A6FA5, #3a5a8a);
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 4px rgba(74, 111, 165, 0.3);
    animation: systemPulse 2s ease-in-out infinite;
}

.user-badge.Mod {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #000;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

/* Regular badges - subtle styling */
.user-badge.admin {
    background-color: #dc3545;
    color: white;
}

.user-badge.moderator {
    background-color: #ffc107;
    color: #000;
}

.user-badge.member {
    background-color: var(--accent);
    color: white;
}

.user-badge.online {
    background-color: #28a745;
    color: white;
}

.user-badge.away {
    background-color: #ffc107;
    color: #000;
}

.user-badge.busy {
    background-color: #dc3545;
    color: white;
}

.user-badge.system {
    background-color: #4A6FA5;
    color: white;
}

.user-badge.You {
    background-color: #2E4467;
    color: white;
    font-weight: 600;
}

.user-badge.Error {
    background-color: #dc3545;
    color: white;
    font-weight: 600;
}

.user-badge.VIP {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.user-badge.New {
    background-color: #28a745;
    color: white;
    font-weight: 600;
}

.user-badge.Bot {
    background-color: #6c757d;
    color: white;
    font-weight: 600;
}

/* Animations for special badges */
@keyframes adminGlow {
    0% {
        box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
    }

    100% {
        box-shadow: 0 4px 8px rgba(220, 53, 69, 0.6);
    }
}

@keyframes systemPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

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

.message-content {
    color: var(--text-color);
    word-wrap: break-word;
}

/* Scroll to Bottom Button */
.scroll-to-bottom {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(46, 68, 103, 0.3);
    transition: all 0.3s ease;
    z-index: 10;
    opacity: 0;
    transform: translateY(20px);
}

.scroll-to-bottom:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

.scroll-to-bottom:hover {
    background-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 68, 103, 0.4);
}

.scroll-to-bottom:active {
    transform: translateY(0);
}

.unread-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border: 2px solid var(--card-bg);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Chat Input */
.chat-input {
    padding: 20px;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

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

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
    transform: scale(1.02);
}

.input-group input:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(74, 111, 165, 0.1);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {

    /* Improve touch targets */
    .btn,
    .btn-icon,
    input[type="text"],
    input[type="submit"] {
        min-height: 44px;
        touch-action: manipulation;
    }

    /* Prevent text selection on buttons */
    .btn,
    .btn-icon {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Improve scrolling on mobile */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Better focus states for mobile */
    .form-group input:focus,
    .input-group input:focus {
        transform: scale(1.02);
        transition: transform 0.2s ease;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 10px;
        align-items: flex-start;
        padding-top: 60px;
    }

    .chat-container {
        height: calc(100vh - 80px);
        max-height: none;
        gap: 15px;
    }

    .theme-toggle-container {
        top: 15px;
        right: 15px;
    }

    #theme-toggle {
        width: 45px;
        height: 45px;
    }

    .username-section {
        padding: 30px 20px;
    }

    .username-section h2 {
        font-size: 20px;
    }

    .chat-stats {
        gap: 20px;
        margin-top: 15px;
        padding-top: 15px;
    }

    .stat-item {
        font-size: 13px;
    }

    .input-group {
        flex-wrap: nowrap;
    }

    .btn-icon {
        flex: 0 0 48px;
        min-width: 48px;
    }

    .status-bar {
        padding: 8px 15px;
        font-size: 13px;
    }

    .chat-messages {
        padding: 15px;
    }

    .message {
        padding: 10px 12px;
        margin-bottom: 12px;
    }

    .chat-input {
        padding: 15px;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 5px;
        padding-top: 50px;
    }

    .chat-container {
        height: calc(100vh - 60px);
        gap: 10px;
    }

    .username-section {
        padding: 20px 15px;
    }

    .username-section h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .chat-stats {
        gap: 15px;
        margin-top: 12px;
        padding-top: 12px;
    }

    .stat-item {
        font-size: 12px;
    }

    .form-group input {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 14px 16px;
    }

    .status-bar {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 10px 15px;
    }

    .status-item {
        font-size: 12px;
    }

    .chat-messages {
        padding: 10px;
        max-height: calc(100vh - 200px);
    }

    .message {
        padding: 8px 10px;
        margin-bottom: 10px;
    }

    .message-header {
        margin-bottom: 6px;
    }

    .username {
        font-size: 14px;
    }

    .timestamp {
        font-size: 11px;
    }

    .message-content {
        font-size: 14px;
    }

    .chat-input {
        padding: 10px;
    }

    .input-group input {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 14px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
        padding: 10px;
    }

    .scroll-to-bottom {
        bottom: 70px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 16px;
    }

    .unread-count {
        min-width: 18px;
        height: 18px;
        font-size: 10px;
        top: -6px;
        right: -6px;
    }
}

@media (max-width: 400px) {
    .main-content {
        padding: 2px;
        padding-top: 45px;
    }

    .chat-container {
        height: calc(100vh - 50px);
    }

    .username-section {
        padding: 15px 10px;
    }

    .username-section h2 {
        font-size: 16px;
    }

    .status-bar {
        padding: 8px 10px;
    }

    .chat-messages {
        padding: 8px;
    }

    .chat-input {
        padding: 8px;
    }

    .scroll-to-bottom {
        bottom: 60px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .unread-count {
        min-width: 16px;
        height: 16px;
        font-size: 9px;
        top: -5px;
        right: -5px;
    }
}