/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5865F2;
    --primary-hover: #4752C4;
    --secondary: #7289DA;
    --accent: #fdda6c;
    --accent-hover: #ffcc66;
    --success: #57F287;
    --warning: #FEE75C;
    --error: #ED4245;
    --bg-primary: #1E2A38;
    --bg-secondary: #2C3E50;
    --bg-tertiary: #34495E;
    --surface: #2F3640;
    --surface-hover: #3B4B5A;
    --text-primary: #ffffff;
    --text-secondary: #b0b3b8;
    --text-muted: #8e9297;
    --border: #40444b;
    --border-light: #4f545c;
    --user-bg: #3b82f6;
    --bot-bg: #9b59b6;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --border-radius-small: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5A6A7B;
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(145deg, var(--bg-primary), var(--bg-secondary));
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* Login Modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.login-modal.show {
    opacity: 1;
    visibility: visible;
}

.login-content {
    background: var(--surface);
    padding: 3rem 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    transition: var(--transition);
}

.login-modal.show .login-content {
    transform: translateY(0);
}

.login-header {
    margin-bottom: 2rem;
}

.login-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-light);
}

.login-header h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.discord-login-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius-small);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    transition: var(--transition);
    margin-bottom: 1rem;
}

.discord-login-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.discord-login-btn i {
    font-size: 1.2rem;
}

.login-note {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Navigation */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.nav-links {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 1rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-small);
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.premium-btn {
    color: var(--accent) !important;
    font-weight: 600 !important;
    position: relative;
}

.premium-btn::before {
    content: '✨';
    margin-right: 0.25rem;
}

.premium-btn:hover {
    color: var(--accent-hover) !important;
    background: rgba(253, 218, 108, 0.1) !important;
}

.invite-btn {
    background: var(--accent) !important;
    color: var(--bg-primary) !important;
    font-weight: 600 !important;
}

.invite-btn:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

/* User Info */
.user-info {
    position: relative;
}

.user-dropdown {
    position: relative;
}

.user-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: var(--transition);
}

.user-btn:hover {
    background: var(--surface-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: var(--transition);
}

.user-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-small);
    box-shadow: var(--shadow);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 1000;
}

.user-dropdown.active .user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.user-menu a:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.user-menu a:first-child {
    border-radius: var(--border-radius-small) var(--border-radius-small) 0 0;
}

.user-menu a:last-child {
    border-radius: 0 0 var(--border-radius-small) var(--border-radius-small);
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
    padding: 8px;
    border-radius: var(--border-radius-small);
    transition: var(--transition);
    z-index: 1001;
}

.hamburger:hover {
    background: var(--surface-hover);
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
}

.chat-container {
    max-width: 800px;
    width: 100%;
    height: 70vh;
    background: var(--surface);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

/* Chat Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-bot-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.status i {
    font-size: 0.6rem;
}

.clear-chat-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: var(--transition);
}

.clear-chat-btn:hover {
    color: var(--error);
    background: rgba(237, 66, 69, 0.1);
}

/* Welcome Message */
.welcome-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
    pointer-events: none;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.welcome-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    box-shadow: var(--shadow-light);
}

.welcome-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-content p {
    color: var(--text-secondary);
    max-width: 300px;
    line-height: 1.5;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: messageSlideIn 0.3s ease-out;
}

.message-row.user {
    flex-direction: row-reverse;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message {
    max-width: 70%;
    padding: 0.875rem 1.125rem;
    border-radius: 1rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
}

.message.user {
    background: var(--user-bg);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.ai {
    background: var(--bot-bg);
    color: white;
    border-bottom-left-radius: 0.25rem;
}

.typing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-style: italic;
    color: var(--text-muted);
    padding: 0.875rem 1.125rem;
    background: var(--bg-tertiary);
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
}

.typing::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDot 1.4s infinite ease-in-out;
}

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

/* Chat Form */
.chat-form {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    border: 2px solid transparent;
    transition: var(--transition);
}

.input-container:focus-within {
    border-color: var(--primary);
}

#chatInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
}

#chatInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--surface-hover);
    cursor: not-allowed;
    opacity: 0.5;
}

.send-btn i {
    color: white;
    font-size: 0.9rem;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.char-count {
    font-weight: 500;
}

.input-hint {
    font-style: italic;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 2rem 0 1rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
}

.footer-section h4,
.footer-section h5 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-brand .footer-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.footer-brand p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.social-links {
    display: flex;
    gap: 0.75rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 50%;
    text-decoration: none;
    transition: var(--transition);
}

.social-links a:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-section ul li a:hover {
    color: var(--text-primary);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    padding-top: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-bottom a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-bottom a:hover {
    color: var(--text-primary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--surface);
        flex-direction: column;
        padding: 5rem 2rem 2rem;
        border-left: 1px solid var(--border);
        box-shadow: var(--shadow);
        transition: var(--transition);
        z-index: 999;
        overflow-y: auto;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .nav-links a {
        display: block;
        width: 100%;
        padding: 1rem;
        text-align: left;
        border-radius: var(--border-radius-small);
        font-size: 1rem;
    }

    .hamburger {
        display: flex;
        position: relative;
        z-index: 1001;
    }

    .main-content {
        padding: 1rem 0.5rem;
    }

    .chat-container {
        height: 80vh;
        border-radius: var(--border-radius-small);
    }

    .chat-header {
        padding: 1rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: 85%;
        font-size: 0.9rem;
    }

    .chat-form {
        padding: 1rem;
    }

    .input-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .footer-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }

    .footer-brand {
        align-items: center;
    }

    .social-links {
        justify-content: center;
    }

    .user-menu {
        right: auto;
        left: 0;
    }

    /* Mobile menu overlay */
    .nav-links.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

@media (max-width: 480px) {
    .navbar-container {
        padding: 0 0.5rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .chat-container {
        height: 85vh;
        border-radius: 0;
    }

    .welcome-content h2 {
        font-size: 1.25rem;
    }

    .welcome-content p {
        font-size: 0.9rem;
    }

    .message {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }

    .nav-links {
        width: 100%;
        right: -100%;
    }

    .nav-links.active {
        right: 0;
    }
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
button:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #ffffff;
        --text-secondary: #ffffff;
        --text-muted: #cccccc;
    }
}