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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #F5EDD6 0%, #C8D9BD 50%, #A3CDC3 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Sidebar Menu */
.sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid #e5e5e5;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #8BADC4 0%, #A3CDC3 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 500;
}

.close-sidebar-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.close-sidebar-btn:hover {
    opacity: 0.8;
}

.new-chat-btn {
    margin: 16px;
    padding: 10px 14px;
    background: white;
    color: #2d333a;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: #f7f7f8;
}
}

.chat-sessions {
    flex: 1;
    padding: 0 16px 16px;
    overflow-y: auto;
}

.chat-session-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.2s;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-session-item:hover {
    background: #e8f0fe;
}

.chat-session-item.active {
    background: #f5f5f5;
    border-left-color: #909090;
}

.chat-session-content {
    flex: 1;
    cursor: pointer;
}

.chat-session-title {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 4px;
}

.chat-session-date {
    font-size: 12px;
    color: #5f6368;
}

.delete-session-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.delete-session-btn:hover {
    background: rgba(197, 34, 31, 0.1);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.show {
    display: block;
}

.menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
    margin-right: 12px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.container {
    width: 100%;
    max-width: 1200px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 90vh;
    border: 1px solid #e5e5e5;
}

header {
    background: linear-gradient(135deg, #8BADC4 0%, #A3CDC3 100%);
    padding: 16px 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
    z-index: 10;
    position: relative;
    font-size: 14px;
    font-weight: 500;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 500;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.conversation {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #5f6368;
}

.welcome-message h2 {
    font-size: 28px;
    font-weight: 400;
    color: #202124;
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 16px;
    line-height: 1.5;
}

.message {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.5;
}

.message.user .message-content {
    background: #8BADC4;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #f1f3f4;
    color: #202124;
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0 0 8px 0;
}

.image-result {
    margin-top: 16px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    background: #f1f3f4;
}

.image-result img {
    width: 100%;
    display: block;
    max-width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-result img.loaded {
    opacity: 1;
}

/* PHASE 2: Image Button Container */
.image-buttons {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    animation: fadeInBtn 0.3s ease forwards 0.5s;
}

@keyframes fadeInBtn {
    to {
        opacity: 1;
    }
}

/* PHASE 2: Edit Button */
.edit-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.edit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: white;
}

.edit-btn svg {
    stroke: #F57C00;
}

.download-btn {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: white;
}

.download-btn svg {
    stroke: #8BADC4;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: #5f6368;
    padding: 20px;
}

.loading span {
    font-size: 15px;
    font-weight: 500;
}

.loading-circle {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-circle svg {
    animation: rotate 1.5s linear infinite;
}

.loading-circle circle {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.input-container {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #e8eaed;
}

/* PHASE 2: Image Upload Styles */
.upload-section {
    margin-bottom: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.upload-preview {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #dadce0;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-upload-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.remove-upload-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.upload-label {
    font-size: 14px;
    color: #5f6368;
    font-weight: 500;
}

.upload-btn {
    background: transparent;
    border: none;
    color: #5f6368;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}

.upload-btn:hover {
    background: #f1f3f4;
}

.upload-btn svg {
    stroke: #8BADC4;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: white;
    border-radius: 24px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 12px;
}

#promptInput {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 16px;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
}

.generate-btn {
    background: #8BADC4;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.generate-btn:hover {
    background: #7599b0;
}
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.generate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
}

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

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.bottom-controls {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
}

.right-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toggle-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    color: #202124;
    padding: 8px 16px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(255, 165, 0, 0.3);
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 165, 0, 0.4);
}

.toggle-btn.alt {
    background: linear-gradient(135deg, #707070 0%, #606060 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(112, 112, 112, 0.3);
}

.toggle-btn.alt:hover {
    box-shadow: 0 4px 8px rgba(112, 112, 112, 0.4);
}

.action-btn {
    background: linear-gradient(135deg, rgba(139, 173, 196, 0.08) 0%, rgba(163, 205, 195, 0.08) 100%);
    border: 1.5px solid rgba(139, 173, 196, 0.4);
    color: #8BADC4;
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(139, 173, 196, 0.1);
}

.action-btn:hover {
    background: linear-gradient(135deg, #8BADC4 0%, #A3CDC3 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 173, 196, 0.25);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1.5px solid rgba(220, 53, 69, 0.3);
    color: #dc3545;
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.1);
}

.clear-btn:hover {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25);
    border-color: #dc3545;
}

.clear-btn:active {
    transform: translateY(0);
}

.clear-btn svg {
    width: 18px;
    height: 18px;
}

.error {
    background: #fce8e6 !important;
    color: #c5221f !important;
    border-left: 4px solid #c5221f;
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #bdc1c6;
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        margin: 0 10px;
    }
    
    .chat-container {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    header {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    
    .logo {
        gap: 8px;
    }

    .logo h1 {
        font-size: 18px;
    }
    
    .logo svg {
        width: 24px;
        height: 24px;
    }
    
    .back-btn {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .back-btn span {
        display: none;
    }
    
    .menu-btn {
        padding: 6px;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .welcome-message {
        padding: 30px 16px;
    }
    
    .welcome-message h2 {
        font-size: 22px;
    }
    
    .welcome-message p {
        font-size: 14px;
    }

    .message-content {
        max-width: 95%;
        font-size: 14px;
    }
    
    .message {
        gap: 12px;
    }
    
    .input-container {
        padding: 12px 16px;
    }
    
    .input-wrapper {
        gap: 8px;
    }
    
    textarea {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .generate-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    
    .upload-btn {
        padding: 8px;
    }
    
    .upload-section {
        padding: 8px 16px;
    }
    
    .bottom-controls {
        flex-direction: column;
        gap: 8px;
        padding: 8px 16px;
    }
    
    .right-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .action-btn,
    .clear-btn {
        flex: 1;
        min-width: 0;
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .action-btn span,
    .clear-btn span {
        display: none;
    }
    
    .sidebar {
        width: 280px;
        left: -280px;
    }
    
    .image-display img {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 16px;
    }
    
    .welcome-message h2 {
        font-size: 20px;
    }
    
    .chat-container {
        padding: 12px;
    }
    
    .message-content {
        font-size: 13px;
    }
    
    textarea {
        font-size: 13px;
    }
    
    .generate-btn {
        width: 36px;
        height: 36px;
    }
    
    .action-btn,
    .clear-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

