:root {
    /* @tweakable primary brand color */
    --primary-color: #10a37f;
    --primary-hover: #0d8c6d;
    
    /* @tweakable secondary colors for accents and UI */
    --secondary-color: #f9f9f9;
    --border-color: #e5e5e5;
    --text-color: #333;
    --light-text: #666;
    
    /* @tweakable notification colors */
    --error-color: #e64542;
    --success-color: #28a745;
    --info-color: #3291ff;
    --warning-color: #f0ad4e;
    
    /* @tweakable typography settings */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    --font-size-base: 15px;
    --line-height: 1.5;
    
    /* @tweakable UI effects */
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    
    /* @tweakable animation settings */
    --transition-speed: 0.3s;
    --analysis-pulse-speed: 1.5s;
    
    /* @tweakable layout dimensions */
    --sidebar-width: 300px;
    --layout-gap: 1.25rem;
    --section-padding: 1rem;
    
    /* @tweakable dark mode colors */
    --dark-bg: #1a1a1a;
    --dark-surface: #2a2a2a;
    --dark-border: #444;
    --dark-text: #e0e0e0;
    --dark-text-light: #aaa;
    
    /* @tweakable sidebar colors */
    --sidebar-bg: var(--secondary-color);
    --dark-sidebar-bg: #232323;
    
    /* @tweakable hover animation duration */
    --hover-animation-duration: 0.2s;
    
    /* @tweakable button interaction colors */
    --button-hover-brightness: 1.05;
    --button-active-brightness: 0.95;
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-color);
    background-color: #fff;
    line-height: var(--line-height);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 1.75rem;
}

header p {
    color: var(--light-text);
    font-size: 1rem;
}

/* Two column layout */
.two-column-layout {
    display: flex;
    gap: var(--layout-gap);
    flex: 1;
}

/* Sidebar styles */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    border-radius: var(--radius);
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-section {
    padding: var(--section-padding);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.upload-container {
    width: 100%;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    background-color: rgba(255, 255, 255, 0.7);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(16, 163, 127, 0.05);
    transform: scale(1.01);
}

.upload-area svg {
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.upload-area p {
    color: var(--light-text);
    font-size: 0.9rem;
}

.image-preview {
    display: none;
    position: relative;
    margin-top: 0.75rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.image-preview img {
    width: 100%;
    display: block;
}

.image-preview button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--hover-animation-duration) ease;
}

.image-preview button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.primary-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--hover-animation-duration) ease;
    font-weight: 500;
    width: 100%;
    margin-top: 0.75rem;
}

.primary-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.primary-button:active {
    transform: translateY(0);
    filter: brightness(var(--button-active-brightness));
}

.primary-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.result-section {
    display: none;
    background-color: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    flex: 1;
    position: relative;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-color);
    overflow-x: auto; 
    scrollbar-width: none; 
}

.tabs::-webkit-scrollbar {
    display: none; 
}

.tab-button {
    padding: 0.8rem 1.25rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border-bottom: 3px solid transparent;
    color: var(--light-text);
    white-space: nowrap; 
}

.tab-button:hover {
    background-color: rgba(0, 0, 0, 0.03);
    color: var(--text-color);
}

.tab-button.active {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    position: relative;
    flex: 1;
    min-height: 350px;
    height: 100%;
}

.tab-pane {
    display: none;
    height: 100%;
    overflow: auto;
}

.tab-pane.active {
    display: block;
    height: 100%;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    min-height: 400px;
}

.code-actions {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: #f5f5f5;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.action-button {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--hover-animation-duration) ease;
}

.action-button:hover {
    background-color: var(--secondary-color);
    border-color: #ccc;
}

.action-button:active {
    transform: translateY(1px);
}

pre {
    margin: 0;
    padding: 1rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f8f8f8;
    height: 100%;
    overflow: auto;
}

code {
    background: none;
    padding: 0;
}

.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 100;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(16, 163, 127, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 0.75rem;
}

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

.analysis-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.option-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

.analysis-preview {
    display: none;
    padding: 0.9rem;
    background-color: rgba(16, 163, 127, 0.05);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
    max-height: 180px;
    overflow-y: auto;
}

.analysis-status {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.analysis-details {
    padding-left: 0.75rem;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.pulse {
    animation: pulse var(--analysis-pulse-speed) infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--light-text);
    font-size: 0.85rem;
}

.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background-color: #333;
    color: white;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--transition-speed) ease;
    font-weight: 500;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background-color: var(--success-color);
}

.toast.error {
    background-color: var(--error-color);
}

.toast.info {
    background-color: var(--info-color);
}

.toast.warning {
    background-color: var(--warning-color);
}

.export-zip-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--hover-animation-duration) ease;
    z-index: 10;
}

.export-zip-button:hover {
    background-color: #f0f0f0;
    border-color: #ccc;
}

.export-zip-button:active {
    transform: translateY(1px);
}

.export-zip-button svg {
    color: var(--primary-color);
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--light-text);
}

body.dark-mode {
    background-color: var(--dark-bg);
    color: var(--dark-text);
}

body.dark-mode .app-container {
    background-color: var(--dark-bg);
}

body.dark-mode header h1 {
    color: var(--primary-color);
}

body.dark-mode header p,
body.dark-mode footer {
    color: var(--dark-text-light);
}

body.dark-mode .sidebar {
    background-color: var(--dark-sidebar-bg);
    border-color: var(--dark-border);
}

body.dark-mode .sidebar-section {
    border-color: var(--dark-border);
}

body.dark-mode .upload-area {
    background-color: var(--dark-surface);
    border-color: var(--dark-border);
}

body.dark-mode .upload-area p {
    color: var(--dark-text-light);
}

body.dark-mode .result-section {
    background-color: var(--dark-surface);
    border-color: var(--dark-border);
}

body.dark-mode .tabs {
    background-color: var(--dark-surface);
    border-color: var(--dark-border);
}

body.dark-mode .tab-button {
    color: var(--dark-text-light);
}

body.dark-mode .tab-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .tab-button.active {
    color: var(--primary-color);
}

body.dark-mode pre {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

body.dark-mode .code-actions {
    background-color: #333;
    border-color: var(--dark-border);
}

body.dark-mode .action-button {
    background-color: var(--dark-surface);
    border-color: var(--dark-border);
    color: var(--dark-text);
}

body.dark-mode .loading-indicator {
    background-color: rgba(26, 26, 26, 0.9);
    color: var(--dark-text);
}

body.dark-mode .analysis-preview {
    background-color: rgba(16, 163, 127, 0.1);
    border-color: var(--primary-color);
}

body.dark-mode .export-zip-button {
    background-color: var(--dark-surface);
    border-color: var(--dark-border);
    color: var(--dark-text);
}

/* Responsive styles */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .app-container {
        padding: 1.25rem;
    }
}

@media (max-width: 768px) {
    .two-column-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    .sidebar-section {
        padding: 0.85rem;
    }
    
    .analysis-preview {
        max-height: 140px;
    }
    
    #previewFrame {
        min-height: 350px;
    }
}

@media (max-width: 480px) {
    :root {
        --font-size-base: 14px;
    }
    
    .app-container {
        padding: 0.85rem;
    }
    
    header {
        margin-bottom: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .tab-button {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }
    
    .export-zip-button {
        font-size: 0.8rem;
        padding: 0.35rem 0.7rem;
    }
    
    .theme-toggle {
        top: 0.75rem;
        right: 0.75rem;
        font-size: 0.8rem;
    }
}

/* Animation classes for generated content */
.hover-scale {
    transition: transform var(--hover-animation-duration) ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-lift {
    transition: transform var(--hover-animation-duration) ease, box-shadow var(--hover-animation-duration) ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.hover-bright {
    transition: filter var(--hover-animation-duration) ease;
}

.hover-bright:hover {
    filter: brightness(1.1);
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.swing-in {
    animation: swingIn 0.5s ease-out;
    transform-origin: top center;
}

@keyframes swingIn {
    0% { transform: rotateX(-90deg); opacity: 0; }
    70% { transform: rotateX(20deg); }
    100% { transform: rotateX(0deg); opacity: 1; }
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

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