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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0c5f74 0%, #002c37 100%);
    min-height: 100vh;
    color: #333;
    display: flex;
    overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: 400px;
    background: white;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar.collapsed {
    transform: translateX(-400px);
}

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    flex: 1;
}

.new-conversation-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.new-conversation-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.new-conversation-btn svg {
    width: 20px;
    height: 20px;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.loading-conversations {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.conversation-item {
    padding: 15px;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.conversation-item:hover {
    background: #e9ecef;
    border-color: #2193b0;
    transform: translateX(5px);
}

.conversation-item.active {
    background: #d9f2ff;
    border-color: #2193b0;
}

.conversation-date {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 5px;
}

.conversation-preview {
    font-size: 0.9rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.conversation-meta {
    font-size: 0.75rem;
    color: #666;
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
}

.conversation-cost {
    font-weight: 600;
    color: #2193b0;
}

.total-cost {
    padding: 15px;
    margin: 10px 15px 15px 15px;
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(33, 147, 176, 0.2);
}

.total-cost-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
}

.total-cost-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.toggle-sidebar-btn {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 2px solid #2193b0;
    color: #2193b0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.toggle-sidebar-btn:hover {
    background: #2193b0;
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.toggle-sidebar-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .toggle-sidebar-btn svg {
    transform: rotate(180deg);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 400px;
    transition: margin-left 0.3s ease;
    padding: 0;
    padding-left: 5px;
    width: calc(100% - 400px);
}

.sidebar.collapsed ~ .main-content {
    margin-left: 0;
    width: 100%;
}

.container {
    margin: 0 auto;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
}

.header-text {
    flex: 1;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    padding: 40px;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #2193b0;
    border-radius: 15px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f0faff;
}

.upload-area:hover {
    border-color: #1a7a8f;
    background: #e6f7ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #1a7a8f;
    background: #d9f2ff;
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: #2193b0;
}

.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    color: #666;
    margin-bottom: 5px;
}

.file-info {
    font-size: 0.9rem;
    color: #999;
}

/* Image Display */
.image-display {
    margin-bottom: 30px;
}

.top-comparison {
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.top-comparison h3 {
    margin-bottom: 20px;
    color: #2193b0;
    font-size: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.top-download-btn {
    margin-top: 15px;
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.top-download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.image-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-container h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3rem;
}

.image-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    display: block;
}

.change-image-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.change-image-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Chat Section */
.chat-section {
    margin-bottom: 30px;
}

.chat-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3rem;
}

.chat-box {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 150px;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 2px solid #2193b0;
    width: 100%;
}

.side-by-side-images {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.image-comparison-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 300px;
    max-width: 45%;
}

.image-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2193b0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.image-comparison-item img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

.result-image-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.result-image-container .download-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.result-image-container .download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.message {
    padding: 12px 16px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
}

.message.user {
    background: #2193b0;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message.assistant {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    align-self: flex-start;
}

.message.error {
    background: #ff4444;
    color: white;
    align-self: center;
    text-align: center;
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#promptInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#promptInput:focus {
    outline: none;
    border-color: #2193b0;
}

.submit-btn {
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 147, 176, 0.4);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Section */
.results-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.results-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3rem;
    text-align: center;
}

.result-container {
    text-align: center;
}

.result-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.download-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Footer */
footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

/* Progress Bar in Chat */
.message.progress {
    background: linear-gradient(135deg, #f0f9ff 0%, #e6f7ff 100%);
    border: 2px solid #2193b0;
    padding: 16px;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    animation: fadeIn 0.3s ease;
}

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

.progress-label {
    font-weight: 600;
    color: #2193b0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.progress-label::before {
    content: "⚙️";
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.progress-bar-bg {
    width: 100%;
    height: 24px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2193b0 0%, #6dd5ed 50%, #2193b0 100%);
    background-size: 200% 100%;
    border-radius: 12px;
    width: 0%;
    transition: width 0.3s ease;
    animation: shimmer 2s infinite;
    position: relative;
    box-shadow: 0 2px 8px rgba(33, 147, 176, 0.4);
}

@keyframes shimmer {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 200% 0%;
    }
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: slide 1.5s infinite;
}

@keyframes slide {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-percentage {
    text-align: center;
    margin-top: 8px;
    font-weight: 700;
    font-size: 1rem;
    color: #2193b0;
}

/* Upload Progress Overlay - No longer used, kept for backwards compatibility */

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }

    .sidebar.collapsed {
        transform: translateX(-280px);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar:not(.collapsed) ~ .main-content {
        margin-left: 280px;
        width: calc(100% - 280px);
    }

    header h1 {
        font-size: 2rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    main {
        padding: 20px;
    }
    
    .upload-area {
        padding: 40px 20px;
    }
    
    .message {
        max-width: 90%;
    }

    .conversation-item {
        padding: 12px;
    }

    .sidebar-header h2 {
        font-size: 1rem;
    }

    /* Stack images vertically on mobile */
    .side-by-side-images {
        flex-direction: column;
        align-items: center;
    }

    .image-comparison-item {
        max-width: 100%;
        width: 100%;
    }

    .image-comparison-item img {
        max-height: 300px;
    }

}

