* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #eee;
    height: 100vh;
    overflow: hidden;
}

/* =================== LOGIN =================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-box {
    background: #16213e;
    padding: 48px 40px;
    border-radius: 20px;
    width: 420px;
    max-width: 92%;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    text-align: center;
    border: 1px solid #1e3a5f;
}

.login-box h1 {
    font-size: 2.2em;
    margin-bottom: 8px;
    color: #fff;
}

.login-subtitle {
    color: #7a8ba0;
    margin-bottom: 28px;
    font-size: 0.95em;
}

.login-error {
    color: #ff4757;
    margin-bottom: 14px;
    min-height: 22px;
    font-size: 0.9em;
}

.input-group {
    text-align: left;
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    color: #8a9bb5;
    font-size: 0.88em;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid #2a3f5f;
    border-radius: 10px;
    background: #0f3460;
    color: #eee;
    font-size: 1em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.input-group input::placeholder {
    color: #4a6080;
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #e94560, #c73a52);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: transform 0.15s, box-shadow 0.2s;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.35);
}

.login-btn:active {
    transform: translateY(0);
}

/* =================== APP LAYOUT =================== */
.app {
    display: flex;
    height: 100vh;
    position: relative;
}

/* =================== SIDEBAR =================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #16213e;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e3a5f;
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar-header {
    padding: 18px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #1e3a5f;
}

.sidebar-header h2 {
    font-size: 1.1em;
    font-weight: 600;
    color: #cdd6e0;
}

.new-chat-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #e94560, #c73a52);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.2s;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px;
}

.conversations-list::-webkit-scrollbar {
    width: 4px;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: #2a3f5f;
    border-radius: 4px;
}

.conv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 4px;
    font-size: 0.9em;
    transition: background 0.15s;
    color: #b0bec5;
}

.conv-item:hover {
    background: #0f3460;
    color: #eee;
}

.conv-item.active {
    background: #0f3460;
    color: #fff;
    border-left: 3px solid #e94560;
}

.conv-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.delete-conv {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    opacity: 0;
    padding: 4px 6px;
    border-radius: 6px;
    transition: opacity 0.15s, background 0.15s;
}

.conv-item:hover .delete-conv {
    opacity: 0.6;
}

.delete-conv:hover {
    opacity: 1 !important;
    background: rgba(255, 71, 87, 0.2);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid #1e3a5f;
}

.user-info {
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #8a9bb5;
    font-weight: 500;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.admin-btn,
.logout-btn {
    flex: 1;
    padding: 9px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.83em;
    font-weight: 500;
    transition: background 0.15s;
}

.admin-btn {
    background: #0f3460;
    color: #cdd6e0;
}

.admin-btn:hover {
    background: #1a4a8a;
}

.logout-btn {
    background: #2a2a3e;
    color: #b0bec5;
}

.logout-btn:hover {
    background: #3a3a50;
}

/* =================== NOTIFICATION BANNER =================== */
.notif-banner {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    background: linear-gradient(135deg, #e94560, #c73a52);
    color: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    font-size: 0.93em;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.3);
}

.notif-banner button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.1em;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.notif-banner button:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* =================== CHAT MAIN =================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #1a1a2e;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #1e3a5f;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #16213e;
}

.chat-header h3 {
    font-size: 1.05em;
    font-weight: 600;
    color: #cdd6e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: #cdd6e0;
    font-size: 1.5em;
    cursor: pointer;
    padding: 4px;
}

/* =================== MESSAGES =================== */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-thumb {
    background: #2a3f5f;
    border-radius: 6px;
}

.message {
    margin-bottom: 18px;
    padding: 16px 20px;
    border-radius: 16px;
    max-width: 78%;
    line-height: 1.65;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.95em;
}

.message.user {
    background: linear-gradient(135deg, #0f3460, #1a4a8a);
    margin-left: auto;
    border-bottom-right-radius: 6px;
    color: #dde6f0;
}

.message.assistant {
    background: #16213e;
    border: 1px solid #1e3a5f;
    border-bottom-left-radius: 6px;
    color: #d0d8e4;
}

.message.loading {
    opacity: 0.6;
    font-style: italic;
    color: #7a8ba0;
}

.message p {
    margin-bottom: 10px;
}

.message p:last-child {
    margin-bottom: 0;
}

.message ul,
.message ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message li {
    margin-bottom: 4px;
}

.message pre {
    background: #0d1117;
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid #21262d;
}

.message code {
    font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
    font-size: 0.88em;
}

.message p code {
    background: #0d1117;
    padding: 3px 7px;
    border-radius: 5px;
    font-size: 0.87em;
    border: 1px solid #21262d;
}

.message a {
    color: #e94560;
    text-decoration: none;
}

.message a:hover {
    text-decoration: underline;
}

.message strong {
    color: #fff;
}

.msg-image {
    max-width: 220px;
    border-radius: 10px;
    margin-top: 10px;
    display: block;
    border: 1px solid #1e3a5f;
}

/* =================== INPUT AREA =================== */
.input-area {
    padding: 16px 20px;
    border-top: 1px solid #1e3a5f;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #16213e;
}

.upload-btn {
    font-size: 1.4em;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: background 0.15s;
    line-height: 1;
}

.upload-btn:hover {
    background: #0f3460;
}

.image-preview {
    position: relative;
    display: flex;
    align-items: center;
}

.image-preview img {
    height: 44px;
    border-radius: 8px;
    border: 1px solid #2a3f5f;
}

.image-preview button {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 0.7em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.image-preview button:hover {
    background: #c73a52;
}

#messageInput {
    flex: 1;
    padding: 13px 16px;
    border: 1px solid #2a3f5f;
    border-radius: 14px;
    background: #0f3460;
    color: #eee;
    font-size: 0.98em;
    resize: none;
    outline: none;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#messageInput:focus {
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

#messageInput::placeholder {
    color: #4a6080;
}

#sendBtn {
    padding: 13px 18px;
    background: linear-gradient(135deg, #e94560, #c73a52);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    line-height: 1;
}

#sendBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.35);
}

#sendBtn:active {
    transform: translateY(0);
}

/* =================== ADMIN =================== */
.admin-container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 36px 24px;
    height: 100vh;
    overflow-y: auto;
}

.admin-container::-webkit-scrollbar {
    width: 6px;
}

.admin-container::-webkit-scrollbar-thumb {
    background: #2a3f5f;
    border-radius: 6px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 1.8em;
    color: #fff;
}

.back-btn {
    padding: 10px 22px;
    background: #0f3460;
    color: #cdd6e0;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.92em;
    font-weight: 500;
    transition: background 0.15s;
}

.back-btn:hover {
    background: #1a4a8a;
}

.admin-section {
    background: #16213e;
    padding: 28px;
    border-radius: 16px;
    margin-bottom: 24px;
    border: 1px solid #1e3a5f;
}

.admin-section h2 {
    margin-bottom: 20px;
    font-size: 1.15em;
    color: #cdd6e0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.stat-card {
    background: #0f3460;
    padding: 24px 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #1a4a8a;
}

.stat-label {
    display: block;
    color: #7a8ba0;
    font-size: 0.83em;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 2em;
    font-weight: 700;
    color: #e94560;
}

.add-user-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.add-user-form input,
.add-user-form select {
    padding: 11px 14px;
    border: 1px solid #2a3f5f;
    border-radius: 10px;
    background: #0f3460;
    color: #eee;
    font-size: 0.93em;
    outline: none;
    flex: 1;
    min-width: 150px;
    transition: border-color 0.2s;
}

.add-user-form input:focus,
.add-user-form select:focus {
    border-color: #e94560;
}

.add-user-form input::placeholder {
    color: #4a6080;
}

.add-user-form select option {
    background: #0f3460;
    color: #eee;
}

.add-user-form button {
    padding: 11px 28px;
    background: linear-gradient(135deg, #e94560, #c73a52);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.93em;
    transition: transform 0.15s, box-shadow 0.2s;
}

.add-user-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.3);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid #1e3a5f;
    font-size: 0.9em;
}

.users-table th {
    color: #7a8ba0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.5px;
}

.users-table tr:hover {
    background: rgba(15, 52, 96, 0.3);
}

.role-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    display: inline-block;
}

.role-badge.admin {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
    border: 1px solid rgba(233, 69, 96, 0.3);
}

.role-badge.user {
    background: rgba(15, 52, 96, 0.5);
    color: #7a8ba0;
    border: 1px solid #2a3f5f;
}

.delete-user-btn {
    padding: 7px 14px;
    background: rgba(255, 71, 87, 0.15);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.83em;
    font-weight: 500;
    transition: background 0.15s;
}

.delete-user-btn:hover {
    background: rgba(255, 71, 87, 0.3);
}

.notif-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.notif-form select,
.notif-form textarea {
    padding: 12px 14px;
    border: 1px solid #2a3f5f;
    border-radius: 10px;
    background: #0f3460;
    color: #eee;
    font-size: 0.93em;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.notif-form select:focus,
.notif-form textarea:focus {
    border-color: #e94560;
}

.notif-form select option {
    background: #0f3460;
    color: #eee;
}

.notif-form textarea::placeholder {
    color: #4a6080;
}

.notif-form button {
    padding: 12px 28px;
    background: linear-gradient(135deg, #e94560, #c73a52);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.93em;
    align-self: flex-start;
    transition: transform 0.15s, box-shadow 0.2s;
}

.notif-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(233, 69, 96, 0.3);
}

/* =================== SCROLLBAR GLOBAL =================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #2a3f5f;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a5580;
}

/* =================== MOBILE =================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .menu-btn {
        display: block;
    }

    .notif-banner {
        left: 0;
    }

    .message {
        max-width: 92%;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .messages {
        padding: 16px 12px;
    }

    .input-area {
        padding: 12px;
    }

    .admin-container {
        padding: 20px 12px;
    }

    .add-user-form {
        flex-direction: column;
    }

    .add-user-form input,
    .add-user-form select {
        min-width: 100%;
    }

    .users-table {
        font-size: 0.82em;
    }

    .users-table th,
    .users-table td {
        padding: 10px 6px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-box {
        padding: 32px 24px;
    }

    .login-box h1 {
        font-size: 1.7em;
    }
}
.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #1e3a5f;
    transition: background 0.15s;
}

.conv-item:hover {
    background: #1e3a5f;
}

.conv-item.active {
    background: #0f3460;
    border-left: 3px solid #e94560;
}

.conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.93em;
}

.conv-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.conv-item:hover .conv-actions {
    opacity: 1;
}

.rename-conv, .delete-conv {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.rename-conv {
    color: #7ab8ff;
}

.rename-conv:hover {
    background: rgba(122, 184, 255, 0.15);
}

.delete-conv {
    color: #ff4757;
    font-weight: bold;
    font-size: 1em;
}

.delete-conv:hover {
    background: rgba(255, 71, 87, 0.15);
}
