/* CSS Variables for Theme Switching */
:root {
    --primary-color: #4285f4;
    --primary-dark: #3367d6;
    --secondary-color: #34a853;
    --accent-color: #ea4335;
    --warning-color: #fbbc05;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f5f5f5;
    --card-bg: #fff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 5px 15px rgba(0, 0, 0, 0.15);
    --sidebar-width: 320px;
    --header-height: 80px;
}

/* Dark Theme */
[data-theme="dark"] {
    --text-color: #e0e0e0;
    --text-light: #a0a0a0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --border-color: #333;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 5px 15px rgba(0, 0, 0, 0.4);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    color: var(--text-color);
}

.theme-btn:hover {
    transform: rotate(15deg);
    box-shadow: var(--shadow-hover);
}

/* Tool Container */
.tool-container {
    max-width: 1600px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-top: 20px;
    margin-bottom: 20px;
}

.tool-header {
    padding: 20px 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    text-align: center;
}

.tool-header h1 {
    font-size: 2.2rem;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tool-header p {
    opacity: 0.9;
    font-size: 1rem;
}

/* Tool Body */
.tool-body {
    display: flex;
    min-height: 80vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.drop-area {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.3s;
    background: var(--bg-color);
    position: relative;
    overflow: hidden;
}

.drop-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.drop-area:hover::before {
    left: 100%;
}

.drop-area:hover, .drop-area.active {
    border-color: var(--primary-color);
    background: var(--card-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.drop-content {
    text-align: center;
    z-index: 2;
}

.drop-content i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    transition: transform 0.3s;
}

.drop-area:hover .drop-content i {
    transform: scale(1.1);
}

.drop-content p {
    margin-bottom: 5px;
    font-weight: 500;
}

.drop-content span {
    display: block;
    margin: 5px 0;
    color: var(--text-light);
}

/* AI Suggestions */
.ai-suggestions {
    margin-bottom: 30px;
}

.ai-suggestions h3 {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
}

.ai-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ai-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.9rem;
}

.ai-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Control Groups */
.control-group {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.control-group:last-child {
    border-bottom: none;
}

.control-group h3 {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
}

/* Sliders */
.slider-container {
    margin-bottom: 15px;
}

.slider-container label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-wrapper input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
}

.value {
    width: 50px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Preset Grid */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.preset-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.preset-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.preset-preview {
    width: 100%;
    height: 40px;
    border-radius: 4px;
}

.preset-preview.vintage {
    background: linear-gradient(45deg, #8B6B4C, #C19A6B, #8B6B4C);
}

.preset-preview.bw {
    background: linear-gradient(45deg, #333, #999, #333);
}

.preset-preview.cool {
    background: linear-gradient(45deg, #4A90E2, #7ED0F2, #4A90E2);
}

.preset-preview.warm {
    background: linear-gradient(45deg, #FF9A3D, #FFC371, #FF9A3D);
}

.preset-preview.dramatic {
    background: linear-gradient(45deg, #2C3E50, #6C7A89, #2C3E50);
}

.preset-preview.cinematic {
    background: linear-gradient(45deg, #1A1A2E, #16213E, #1A1A2E);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Preview Section */
.preview-section {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.preview-controls {
    display: flex;
    gap: 10px;
}

.preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    min-height: 400px;
}

#imagePreview, #imageCanvas {
    max-width: 100%;
    max-height: 100%;
    display: none;
    box-shadow: var(--shadow);
}

.zoom-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Tool Buttons */
.tool-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Download Section */
.download-section {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 10px;
    margin-top: auto;
}

.format-options h4 {
    margin-bottom: 10px;
    color: var(--text-light);
}

.format-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.format-option {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.format-option:hover {
    background: rgba(66, 133, 244, 0.1);
}

.format-option input {
    margin: 0;
}

/* History Section */
.history-section {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
}

.history-section h3 {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
}

.history-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.history-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

.history-empty i {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Buttons */
.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-weight: 500;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.upload-btn {
    background: var(--secondary-color);
}

.upload-btn:hover {
    background: #2d9246;
}

.reset-btn {
    background: var(--accent-color);
}

.reset-btn:hover {
    background: #d33426;
}

.save-preset-btn {
    background: var(--warning-color);
    color: #333;
}

.save-preset-btn:hover {
    background: #e6a700;
}

.download-btn {
    background: var(--secondary-color);
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.download-btn:hover {
    background: #2d9246;
}

.preview-control-btn, .tool-btn {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.preview-control-btn:hover, .tool-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Crop Controls */
.crop-controls {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: none;
}

.crop-controls h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.crop-buttons {
    display: flex;
    gap: 10px;
}

.apply-crop-btn {
    background: var(--secondary-color);
}

.cancel-crop-btn {
    background: var(--accent-color);
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: var(--shadow-hover);
}

.spinner {
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--secondary-color);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    display: none;
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* File Input */
.file-input {
    display: none;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .tool-body {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .preset-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 1.8rem;
    }
    
    .preset-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .ai-buttons {
        grid-template-columns: 1fr;
    }
    
    .preview-controls {
        flex-wrap: wrap;
    }
    
    .tool-buttons {
        justify-content: center;
    }
    
    .action-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .tool-container {
        margin: 10px;
        border-radius: 8px;
    }
    
    .tool-header {
        padding: 15px 20px;
    }
    
    .tool-header h1 {
        font-size: 1.5rem;
    }
    
    .sidebar, .preview-section, .history-section {
        padding: 15px;
    }
    
    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .format-buttons {
        flex-direction: column;
        gap: 10px;
    }
}