/* Main Styles */
:root {
    --primary-color: #cc785c;
    --primary-hover: #b66848;
    --secondary-color: #5a5a5a;
    --background: #f5f5f5;
    --surface: #ffffff;
    --border: #e5e5e5;
    --text-primary: #2d2d2d;
    --text-secondary: #6a6a6a;
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
}

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

.fade-in {
    animation: fadeIn 0.3s;
}

.fade-out {
    animation: fadeOut 0.3s;
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* Desktop Layout */
.desktop-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    user-select: none;
}

.nav-item:hover {
    background: var(--background);
}

.nav-item.active {
    background: rgba(204, 120, 92, 0.1);
    color: var(--primary-color);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.nav-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.nav-badge {
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--background);
}

#content-container {
    min-height: 100%;
    transition: opacity 0.15s ease;
}

/* Home View */
.home-view {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.home-header {
    text-align: center;
    margin-bottom: 40px;
}

.home-header h1 {
    font-size: 36px;
    margin-bottom: 8px;
}

.home-header p {
    color: var(--text-secondary);
    font-size: 18px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.category-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.category-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.category-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.category-formats {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Category View */
.category-view, .image-converter-view {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.view-header, .converter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.view-header h2, .converter-header h2 {
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-actions, .converter-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.converter-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mode-switcher {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    background: var(--background);
    border-radius: 8px;
}

.mode-switcher label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
}

/* Upload Area */
.upload-area, .upload-zone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    transition: var(--transition);
    margin-bottom: 32px;
}

.upload-area.dragover, .upload-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(204, 120, 92, 0.05);
}

.upload-content, .upload-inner {
    max-width: 400px;
    margin: 0 auto;
}

.upload-icon {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-area h3, .upload-zone h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.upload-area p, .upload-zone p {
    color: var(--text-secondary);
    margin: 12px 0;
}

/* Buttons */
button {
    border: none;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 8px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary, .btn-upload {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover, .btn-upload:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
}

.btn-icon:hover {
    background: white;
}

/* File Preview */
.files-preview, .image-grid {
    margin-top: 24px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.preview-item, .file-item {
    background: var(--surface);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.preview-item:hover, .file-item:hover {
    box-shadow: var(--shadow-md);
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.image-item {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.image-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.image-preview {
    position: relative;
    width: 100%;
    height: 200px;
    background: var(--background);
    overflow: hidden;
}

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

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-item:hover .image-overlay {
    opacity: 1;
}

.image-info {
    padding: 12px;
}

.image-name {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.image-convert {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.image-convert label {
    color: var(--text-secondary);
}

/* Format Select */
.format-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.format-select:hover:not(:disabled) {
    border-color: var(--primary-color);
}

.format-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Modals */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-success {
    border-left: 4px solid var(--success);
}

.notification-error {
    border-left: 4px solid var(--error);
}

.notification-warning {
    border-left: 4px solid var(--warning);
}

.notification-info {
    border-left: 4px solid var(--info);
}

.notification-close {
    width: 24px;
    height: 24px;
    background: transparent;
    padding: 0;
    font-size: 20px;
    color: var(--text-secondary);
}

/* Sortable */
.sortable-ghost {
    opacity: 0.4;
}

/* Loading States */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Container */
.error-container {
    text-align: center;
    padding: 40px;
}

.error-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.error-message {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.btn-retry {
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}