* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    color: #000000;
    height: 100vh;
    overflow: hidden;
}

/* Auth Container */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #ffffff;
}

.auth-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border: 2px solid #000000;
}

.auth-box h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.subtitle {
    color: #666666;
    margin-bottom: 32px;
}

.auth-card h2 {
    margin-bottom: 24px;
    font-size: 24px;
}

.auth-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-size: 14px;
}

.auth-card input:focus {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

/* Password Checkbox Label */
.password-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    margin-top: 8px;
}

.password-checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    accent-color: #000000;
    flex-shrink: 0;
    vertical-align: middle;
}

.password-checkbox-label input[type="checkbox"]:focus {
    outline: none;
}

.password-checkbox-label input[type="checkbox"]:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

.auth-card button {
    width: 100%;
    padding: 12px;
    background: #000000;
    color: #ffffff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.auth-card button:hover {
    background: #333333;
}

.auth-switch {
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
}

.auth-switch a {
    color: #000000;
    text-decoration: underline;
}

/* App Container */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 2px solid #000000;
    background: #ffffff;
}

.header h1 {
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info span {
    font-weight: 500;
}

#logoutButton {
    padding: 8px 16px;
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    cursor: pointer;
    font-size: 14px;
}

#logoutButton:hover {
    background: #000000;
    color: #ffffff;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 66px);
}

/* Sidebar */
.sidebar {
    border-right: 2px solid #000000;
    padding: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #000000 #ffffff;
}

/* Chat Sessions Section - Top, takes more space */
.sidebar-section.sessions-section {
    flex: 1 1 auto;
    min-height: 0;
}

/* Documents Section - Bottom, controlled height */
.sidebar-section.documents-section {
    flex: 0 1 auto;
    min-height: 300px;
    max-height: 400px;
    border-top: 1px solid #000000;
}

.sidebar-divider {
    display: none;
}

.sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sessions-header h2 {
    font-size: 18px;
    margin: 0;
}

.new-chat-btn {
    padding: 6px 12px;
    background: #000000;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.new-chat-btn:hover {
    background: #333333;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.session-item {
    padding: 12px;
    border: 1px solid #000000;
    cursor: pointer;
    font-size: 13px;
    background: #ffffff;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.session-item:hover {
    background: #f5f5f5;
}

.session-item.active {
    background: #000000;
    color: #ffffff;
    font-weight: 600;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-delete-btn {
    padding: 4px 8px;
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.2s;
}

.session-delete-btn:hover {
    background: #000000;
    color: #ffffff;
}

.session-item.active .session-delete-btn {
    background: #ffffff;
    color: #000000;
    border: 1px solid #ffffff;
}

.session-item.active .session-delete-btn:hover {
    background: #cccccc;
    border-color: #cccccc;
}

.session-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.session-date {
    font-size: 11px;
    color: #666666;
}

.session-item.active .session-date {
    color: #cccccc;
}

.no-sessions {
    text-align: center;
    color: #999999;
    padding: 24px 12px;
    font-size: 12px;
}

/* Documents Panel */
.documents-panel {
    border-right: 2px solid #000000;
    padding: 24px;
    overflow-y: auto;
    background: #ffffff;
}

.documents-panel h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.upload-area {
    border: 2px dashed #000000;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 24px;
}

.upload-area:hover {
    background: #f5f5f5;
}

.upload-area p {
    font-size: 14px;
}

.upload-progress {
    margin-bottom: 24px;
}

.progress-bar {
    height: 4px;
    background: #e0e0e0;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #000000;
    transition: width 0.3s;
}

.progress-text {
    font-size: 12px;
    color: #666666;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    padding: 12px;
    border: 1px solid #000000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
}

.file-size {
    font-size: 12px;
    color: #666666;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.file-actions button {
    padding: 4px 8px;
    background: #000000;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 12px;
}

.file-actions button:hover {
    background: #333333;
}

.no-files {
    text-align: center;
    color: #999999;
    padding: 24px;
    font-size: 14px;
}

/* Chat Panel */
.chat-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    height: 100%;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: scroll;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    min-height: 0;
    scrollbar-width: auto;
    scrollbar-color: #000000 #f0f0f0;
}

.message {
    padding: 12px 16px;
    max-width: 70%;
    border: 1px solid #000000;
}

.user-message {
    align-self: flex-end;
    background: #000000;
    color: #ffffff;
}

.bot-message {
    align-self: flex-start;
    background: #ffffff;
    color: #000000;
}

.message p {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-input-area {
    border-top: 2px solid #000000;
    padding: 16px 24px;
    display: flex;
    gap: 12px;
}

#chatInput {
    flex: 1;
    padding: 12px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-size: 14px;
    font-family: inherit;
    resize: none;
}

#chatInput:focus {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

#sendButton {
    padding: 12px 24px;
    background: #000000;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

#sendButton:hover {
    background: #333333;
}

#sendButton:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* Scrollbar - WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #ffffff;
}

::-webkit-scrollbar-thumb {
    background: #000000;
    border: 2px solid #ffffff;
}

::-webkit-scrollbar-thumb:hover {
    background: #333333;
}

/* Responsive Design */

/* Tablets (768px to 1024px) */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 280px 1fr;
    }

    .sidebar-section {
        padding: 16px;
    }

    .header h1 {
        font-size: 20px;
    }

    .message {
        max-width: 85%;
    }
}

/* Small tablets and large phones (600px to 768px) */
@media (max-width: 768px) {
    .main-content {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        border-right: none;
        border-bottom: 2px solid #000000;
        max-height: 35vh;
        flex-shrink: 0;
    }

    .sidebar-section {
        padding: 12px;
        font-size: 12px;
    }

    .sidebar-section.sessions-section {
        flex: 1 1 auto;
        min-height: 0;
    }

    .sidebar-section.documents-section {
        flex: 0 1 auto;
        min-height: auto;
        max-height: none;
    }

    .sessions-header h2 {
        font-size: 16px;
    }

    .new-chat-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .session-item {
        padding: 8px;
        font-size: 12px;
    }

    .session-title {
        font-size: 12px;
    }

    .session-date {
        font-size: 10px;
    }

    .session-delete-btn {
        padding: 2px 6px;
        font-size: 9px;
    }

    .file-item {
        padding: 8px;
    }

    .file-name {
        font-size: 13px;
    }

    .file-size {
        font-size: 11px;
    }

    .file-actions button {
        padding: 3px 6px;
        font-size: 10px;
    }

    .upload-area {
        padding: 16px 8px;
    }

    .upload-area p {
        font-size: 12px;
    }

    .chat-panel {
        flex: 1;
    }

    .chat-messages {
        padding: 12px;
        gap: 12px;
    }

    .message {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 12px;
    }

    .message p {
        font-size: 13px;
    }

    .chat-input-area {
        padding: 12px;
        gap: 8px;
    }

    #chatInput {
        padding: 8px;
        font-size: 13px;
    }

    #sendButton {
        padding: 8px 16px;
        font-size: 12px;
    }

    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 18px;
    }

    .user-info {
        gap: 8px;
    }

    .user-info span {
        font-size: 12px;
    }

    #logoutButton {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Mobile phones (max 600px) */
@media (max-width: 600px) {
    .main-content {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        border-right: none;
        border-bottom: 2px solid #000000;
        max-height: 30vh;
        flex-shrink: 0;
    }

    .sidebar-section {
        padding: 10px;
    }

    .header {
        padding: 10px 12px;
        gap: 8px;
    }

    .header h1 {
        font-size: 16px;
    }

    .user-info {
        gap: 6px;
        flex-direction: column;
        align-items: flex-end;
    }

    .user-info span {
        font-size: 11px;
    }

    #logoutButton {
        padding: 4px 8px;
        font-size: 10px;
    }

    .auth-box {
        padding: 24px;
        width: 95%;
    }

    .auth-box h1 {
        font-size: 24px;
    }

    .auth-card h2 {
        font-size: 18px;
    }

    .auth-card input {
        padding: 10px;
        font-size: 13px;
    }

    .auth-card button {
        padding: 10px;
        font-size: 12px;
    }

    .sessions-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sessions-header h2 {
        font-size: 14px;
    }

    .new-chat-btn {
        padding: 4px 8px;
        font-size: 9px;
        align-self: flex-end;
    }

    .session-item {
        padding: 6px;
        font-size: 11px;
    }

    .session-title {
        font-size: 11px;
    }

    .session-date {
        font-size: 9px;
    }

    .session-delete-btn {
        padding: 2px 4px;
        font-size: 8px;
    }

    .upload-area {
        padding: 12px 8px;
        margin-bottom: 12px;
    }

    .upload-area p {
        font-size: 11px;
    }

    .file-item {
        padding: 6px;
    }

    .file-name {
        font-size: 12px;
    }

    .file-size {
        font-size: 10px;
    }

    .file-actions button {
        padding: 2px 4px;
        font-size: 9px;
    }

    .chat-messages {
        padding: 8px;
        gap: 8px;
    }

    .message {
        max-width: 95%;
        padding: 6px 10px;
    }

    .message p {
        font-size: 12px;
    }

    .chat-input-area {
        padding: 8px;
        gap: 6px;
        flex-direction: column;
    }

    #chatInput {
        padding: 8px;
        font-size: 13px;
        min-height: 36px;
    }

    #sendButton {
        padding: 8px 12px;
        font-size: 12px;
        width: 100%;
    }
}

/* Extra small phones (max 480px) */
@media (max-width: 480px) {
    .main-content {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        max-height: 25vh;
    }

    .sidebar-section {
        padding: 8px;
    }

    .header h1 {
        font-size: 14px;
    }

    .header {
        padding: 8px 10px;
    }

    .auth-box {
        padding: 16px;
        width: 90%;
    }

    .auth-box h1 {
        font-size: 20px;
    }

    .subtitle {
        font-size: 12px;
    }

    .session-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .session-info {
        width: 100%;
        margin-bottom: 4px;
    }

    .session-delete-btn {
        align-self: flex-end;
    }

    .message {
        max-width: 98%;
        padding: 4px 8px;
    }

    .message p {
        font-size: 11px;
    }
}
