/* General mobile-first styles */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background-color: #ffffff;
    color: #000000;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar (mobile-first: hidden off-screen) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100%;
    background-color: #ffffff;
    border-right: 1px solid #000000;
    padding: 10px;
    box-sizing: border-box;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

#new-chat-btn, #submit-btn, .tab, button {
    background-color: #ffffff;
    border: 1px solid #000000;
    color: #000000;
    padding: 10px;
    cursor: pointer;
    border-radius: 0; /* Right angles */
    margin-bottom: 10px;
}

#new-chat-btn:hover, #submit-btn:hover, .tab:hover, button:hover {
    background-color: #f0f0f0;
}

.conversation-list {
    flex-grow: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #000000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item.active {
    background-color: #e0e0e0;
}

.conversation-item-actions {
    display: none;
}

.conversation-item:hover .conversation-item-actions {
    display: flex;
}

.conversation-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 5px;
}

.rename-btn,
.delete-btn {
    font-weight: bold;
    font-size: 1.2em;
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
}

.rename-btn {
    background-color: #4CAF50; /* Green */
    color: white;
}

.delete-btn {
    background-color: #f44336; /* Red */
    color: white;
}

/* Main content area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    box-sizing: border-box;
    background-color: #ffffff;
}

#sidebar-toggle-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1500;
    background: #ffffff;
    border: 1px solid #000000;
    border-radius: 0; /* Right angles */
    width: 40px;
    height: 40px;
    cursor: pointer;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

h1 {
    text-align: center;
    margin: 0 0 10px 0;
    font-size: 1.5em;
    flex-shrink: 0;
    padding-top: 45px;
}

.tab-container {
    display: flex;
    flex-shrink: 0;
    overflow-x: auto;
    border-bottom: 1px solid #000000;
}

.tab.active {
    border-bottom: 2px solid #000000;
}

.tab-content {
    display: none;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

.image-result {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
    border: 1px solid #000000;
    overscroll-behavior: contain;
}

.image-preview-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(100%, 720px);
    margin: 0 auto;
}

.image-result img {
    display: block;
    width: 100%;
    max-height: 65vh;
    object-fit: contain;
    background: #f0f0f0;
    cursor: zoom-in;
}

.image-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-preview-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    box-sizing: border-box;
    margin: 0;
    padding: 56px 12px 12px;
    border: 0;
    background: #111111;
    align-items: center;
    justify-content: center;
}

.image-preview-dialog[open] {
    display: flex;
}

.image-preview-dialog::backdrop {
    background: #111111;
}

.image-preview-dialog img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: pinch-zoom;
}

.close-image-preview-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
    color: #ffffff;
    background: #333333;
    border-color: #777777;
}

/* Chat specific layout */
.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #000000;
    background-color: #ffffff;
    margin-bottom: 10px;
}

#chat-form {
    display: flex;
    flex-shrink: 0;
    align-items: center;
}

#prompt, textarea, select {
    flex-grow: 1;
    resize: none;
    padding: 10px;
    border: 1px solid #000000;
    border-radius: 0; /* Right angles */
    margin-right: 10px;
    background-color: #ffffff;
}

.message {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0; /* Right angles */
    max-width: 85%;
    word-wrap: break-word;
    border: 1px solid #000000;
}

.user-message {
    background-color: #f0f0f0;
    color: #000000;
    margin-left: auto;
}

.assistant-message {
    background-color: #ffffff;
    color: #000000;
    margin-right: auto;
}

.assistant-status {
    color: #555555;
    font-size: 0.9em;
}

.assistant-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background-color: #138a72;
    animation: status-pulse 1.1s ease-in-out infinite;
}

@keyframes status-pulse {
    50% {
        opacity: 0.35;
        transform: scale(0.8);
    }
}

/* Controls and settings */
.controls, .advanced-settings {
    flex-shrink: 0;
    margin-bottom: 10px;
    border: 1px solid #000000;
    padding: 10px;
}

.advanced-settings {
    display: none;
}

.advanced-settings.active {
    display: block;
}

/* Desktop and larger screens */
@media (min-width: 769px) {
    .sidebar {
        position: relative;
        transform: translateX(0);
        width: 280px;
    }

    .main-content {
        width: calc(100% - 280px);
    }

    #sidebar-toggle-btn {
        display: none;
    }

    .container {
        max-width: 900px;
        margin: 0 auto;
        padding: 20px;
    }

    h1 {
        padding-top: 0;
        margin-top: 10px;
    }
}