:root {
    --bg-dark: #0a0a0a;
    --bg-panel: #141414;
    --bg-glass: rgba(30, 30, 30, 0.7);
    --border-color: rgba(255, 0, 51, 0.2);
    --brand-red: #ff0033;
    --brand-red-glow: rgba(255, 0, 51, 0.5);
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --message-bot: rgba(255, 0, 51, 0.1);
    --message-user: rgba(40, 40, 40, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3 {
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 1px;
}

/* Base Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.sidebar-header {
    padding: 30px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--brand-red);
    text-shadow: 0 0 10px var(--brand-red-glow);
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
}

.nav-links {
    list-style: none;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.nav-item i {
    font-size: 1.5rem;
}

.nav-item:hover {
    background-color: rgba(255, 0, 51, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--message-bot);
    border-color: var(--border-color);
    color: var(--brand-red);
    box-shadow: 0 0 15px rgba(255, 0, 51, 0.1) inset;
}

/* Chat Main Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(rgba(10, 10, 10, 0.85), rgba(10, 10, 10, 0.95)), url('https://files.nexhub.fun/api/file/view/crv9dKzv5kr0vJhgAHbiIR_xUaXo-zjx2OenpdwVDtUdXds0-XjnHt7-GVVSVL5t') no-repeat center center;
    background-size: cover;
    position: relative;
}

/* Mobile header logic */
.mobile-header {
    display: none; /* hidden on desktop */
    padding: 15px 20px;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-panel);
}

.mobile-logo {
    color: var(--brand-red);
    font-size: 1.5rem;
}

/* Chat Header */
.chat-header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 0, 51, 0.1);
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-header-icon {
    font-size: 2rem;
    color: var(--brand-red);
}

.chat-title-group h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.status-indicator {
    font-size: 0.8rem;
    color: #4CAF50;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Scrollbar customization */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--brand-red);
}

.message {
    max-width: 80%;
    animation: fadeIn 0.4s ease forwards;
    line-height: 1.5;
    word-wrap: break-word;
}

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

.message-user {
    align-self: flex-end;
    background-color: var(--message-user);
    padding: 15px 20px;
    border-radius: 15px 15px 0 15px;
    border: 1px solid #333;
}

.message-bot {
    align-self: flex-start;
    background-color: var(--message-bot);
    padding: 15px 20px;
    border-radius: 15px 15px 15px 0;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(255, 0, 51, 0.05);
}

.message pre {
    white-space: pre-wrap;
    font-family: inherit;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 15px 20px;
    align-self: flex-start;
    background-color: var(--message-bot);
    border-radius: 15px 15px 15px 0;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--brand-red);
    border-radius: 50%;
    animation: bounce 1.5s infinite ease-in-out;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* Input Area */
.chat-input-area {
    padding: 20px 30px;
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid #222;
}

.chat-form {
    display: flex;
    gap: 15px;
    position: relative;
}

#chat-input {
    flex: 1;
    background-color: var(--bg-dark);
    border: 1px solid #333;
    padding: 15px 25px;
    border-radius: 30px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

#chat-input:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 10px rgba(255, 0, 51, 0.2);
}

.send-btn {
    background-color: var(--brand-red);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--brand-red-glow);
}

.send-btn:active {
    transform: scale(0.95);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .chat-header {
        display: none;
    }

    .message {
        max-width: 90%;
    }
}

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

.view-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #111 0%, var(--bg-dark) 100%);
}

#login-view {
    background: linear-gradient(rgba(10, 10, 10, 0.7), rgba(10, 10, 10, 0.8)), url('https://files.nexhub.fun/api/file/view/A1kOqNjpMFhXvc1_AAdqfgqzUSy-FidZ_lN5o8qIAr95HttY2Ko2RRmVvY5h_aS6') no-repeat center center;
    background-size: cover;
}

.login-card {
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(15px);
    padding: 40px;
    border-radius: 15px;
    border: 1px solid var(--brand-red);
    box-shadow: 0 10px 40px rgba(255,0,51,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.85) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.login-logo {
    font-size: 4rem;
    margin-bottom: -10px;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#login-form input, .input-light {
    background-color: var(--bg-dark);
    border: 1px solid #333;
    padding: 15px;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}

#login-form input:focus, .input-light:focus {
    border-color: var(--brand-red);
}

.primary-btn {
    background-color: var(--brand-red);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 600;
}

.primary-btn:hover {
    background-color: #d4002a;
    box-shadow: 0 0 15px var(--brand-red-glow);
}

.error-msg {
    color: var(--brand-red);
    font-size: 0.9rem;
}

.admin-msg {
    color: #4CAF50;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Sidebar updates */
.user-info {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 0, 51, 0.1);
}

#logged-user-name {
    font-weight: bold;
    color: var(--brand-red);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.3s;
}

.logout-btn:hover {
    color: var(--brand-red);
}

.nav-divider {
    height: 1px;
    background: rgba(255, 0, 51, 0.1);
    margin: 10px 15px;
}

.nav-action {
    color: var(--text-secondary);
}
.nav-action.active {
    background-color: var(--message-bot);
    color: var(--brand-red);
}

/* View Sections */
.view-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.history-container {
    background: linear-gradient(rgba(10, 10, 10, 0.85), rgba(10, 10, 10, 0.95)), url('https://files.nexhub.fun/api/file/view/crv9dKzv5kr0vJhgAHbiIR_xUaXo-zjx2OenpdwVDtUdXds0-XjnHt7-GVVSVL5t') no-repeat center center;
    background-size: cover;
    overflow-y: auto;
}

.section-header {
    padding: 30px;
    border-bottom: 1px solid rgba(255, 0, 51, 0.1);
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-list {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-card {
    background: var(--bg-panel);
    border: 1px solid #333;
    padding: 20px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-card:hover {
    border-color: var(--brand-red);
}

.history-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.history-query {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--brand-red);
}

.history-response {
    background: var(--message-bot);
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    white-space: pre-wrap;
    border-left: 3px solid var(--brand-red);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 70vh;
    overflow-y: auto;
}

#create-user-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.users-list-ui {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.users-list-ui li {
    background: var(--bg-dark);
    padding: 10px 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    border: 1px solid #333;
}

/* Telegram Inline Keyboard Styles */
.inline-keyboard {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
}

.tg-inline-btn {
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid rgba(255, 0, 51, 0.5);
    color: var(--text-primary);
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
    flex: 1 1 calc(50% - 10px);
    text-align: center;
}

.tg-inline-btn:hover {
    background: rgba(255, 0, 51, 0.2);
    box-shadow: 0 0 10px rgba(255, 0, 51, 0.3);
}

.tg-inline-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
}
