body {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #1e293b;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-y: auto;
    line-height: 1.6;
}

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.app-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.app-icon i {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 320px;
    height: 100vh;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
}

.side-menu.open {
    left: 0;
}

.side-menu-header {
    padding: 24px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.side-menu-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.025em;
}

.side-menu-content {
    flex: 1;
    padding: 24px 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
}

.menu-section {
    margin-bottom: 32px;
}

.menu-section label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    letter-spacing: -0.01em;
}

.menu-section h4 {
    margin: 0 0 16px 0;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    tracking: 0.05em;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.menu-btn:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.shifted {
    margin-left: 320px;
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    transition: transform 0.2s ease-out, background 0.2s ease-out;
    border-radius: 999px;
}

.hamburger-btn:hover {
    background: rgba(15, 23, 42, 0.06);
}

.hamburger-btn span {
    display: block;
    height: 4px;
    width: 22px;
    background: #111827;
    border-radius: 999px;
    transition: transform 0.25s ease-out, opacity 0.25s ease-out, background 0.25s ease-out;
    transform-origin: center;
}

.hamburger-btn span + span {
    margin-top: 4px;
}

.hamburger-btn.open span {
    background: #111827;
}

.hamburger-btn.open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger-btn.open span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}


header {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 16px;
    font-weight: 600;
    color: #1f2933;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
    position: relative;
}

.header-title {
    margin-left: 8px;
    font-size: 18px;
    letter-spacing: 0.02em;
}

#chatArea {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    background: transparent;
    border: none;
    padding-bottom: 140px; /* Space for fixed input */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.message:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.message.user {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    margin-left: auto;
    margin-right: 0;
    text-align: left;
    border-bottom-right-radius: 4px;
}

.message.ai {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #1e293b;
    margin-left: 0;
    margin-right: auto;
    text-align: left;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid #e2e8f0;
    padding: 16px 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-group .form-control {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    padding: 16px 20px;
    font-size: 15px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #1e293b;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.input-group .form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group .form-control::placeholder {
    color: #94a3b8;
}

.input-group .btn {
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.input-group .btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.form-select {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    color: #334155;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select option {
    background: #ffffff;
    color: #334155;
    padding: 8px;
}

@media (max-width: 768px) {
    .message {
        max-width: 95%;
        padding: 12px 16px;
        font-size: 14px;
    }
    #chatArea {
        padding: 20px 15px;
        max-width: none;
        padding-bottom: 80px;      /* extra space so last messages clear the input */
        overflow-y: visible;       /* let the whole page handle scrolling on mobile */
    }
    .input-container {
        position: static;          /* was fixed: avoid mobile viewport bugs */
        padding: 12px 15px;
        max-width: none;
        box-shadow: none;
    }
    .input-group .form-control {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    .input-group .btn {
        width: 44px;
        height: 44px;
    }
    header {
        padding: 12px 16px;
        font-size: 14px;
    }
    .hamburger-btn {
        margin-right: 16px;
    }
    .side-menu {
        width: 280px;
    }
    .main-content.shifted {
        margin-left: 280px;
    }
    .side-menu-content {
        padding: 20px 16px;
    }
    .menu-section {
        margin-bottom: 24px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #1e293b;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f1f5f9;
}

.modal-body {
    padding: 24px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.users-list {
    display: grid;
    gap: 16px;
}

.user-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info h4 {
    margin: 0 0 4px 0;
    color: #1e293b;
}

.user-info p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.user-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-btn:hover {
    background: #f3f4f6;
}

.user-btn.danger {
    border-color: #ef4444;
    color: #ef4444;
}

.user-btn.danger:hover {
    background: #fef2f2;
}

.add-user-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.add-user-form {
    margin-top: 15px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.add-user-form .form-control {
    margin-bottom: 10px;
}

.add-user-form .menu-btn {
    margin-right: 10px;
}
.attachment-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
}

.upload-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.image-preview-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-chip {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.image-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    line-height: 16px;
    font-size: 12px;
}

.message-attachments {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.message-attachments a {
    display: inline-block;
    position: relative;
}

.message-attachments img {
    max-width: 160px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
