:root {
    --bg-dark: #0f1115;
    --bg-sidebar: #171a1f;
    --bg-topbar: #1c2026;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --border: #2d343f;
    --btn-secondary: #2d343f;
    --btn-secondary-hover: #374151;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Typography */
h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

/* Layout Components */
.top-bar {
    height: 60px;
    background-color: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

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

.logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.mode-switcher {
    display: flex;
    background: var(--bg-dark);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.mode-btn {
    padding: 6px 16px;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn.active {
    background: var(--accent);
    color: white;
}

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

.history-controls {
    display: flex;
    gap: 4px;
}

.divider {
    width: 1px;
    height: 24px;
    background-color: var(--border);
    margin: 0 8px;
}

.editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 0;
}

.tool-groups {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
}

.tool-group {
    margin-bottom: 8px;
    border-radius: var(--radius);
    overflow: hidden;
}

.tool-toggle {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.tool-toggle svg {
    color: var(--text-secondary);
    transition: var(--transition);
}

.tool-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.tool-group.active .tool-toggle {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent);
}

.tool-group.active .tool-toggle svg {
    color: var(--accent);
}

.tool-panel {
    display: none;
    padding: 8px 12px 16px 44px;
    flex-direction: column;
    gap: 16px;
}

.tool-group.active .tool-panel {
    display: flex;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: auto;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.canvas-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    background-image: 
        linear-gradient(45deg, #1e1e1e 25%, transparent 25%), 
        linear-gradient(-45deg, #1e1e1e 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #1e1e1e 75%), 
        linear-gradient(-45deg, transparent 75%, #1e1e1e 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    transform-origin: center;
    transition: transform 0.15s ease-out;
}

.zoom-indicator {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: white;
    backdrop-filter: blur(4px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.canvas-wrapper:hover .zoom-indicator {
    opacity: 1;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 140px);
    object-fit: contain;
}

/* Forms & Controls */
.control-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-field label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-field.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.control-field.checkbox label {
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.9rem;
    cursor: pointer;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -6px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

input[type="number"], input[type="text"] {
    background: var(--btn-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 100%;
}

.input-row {
    display: flex;
    gap: 12px;
}

.input-row .control-field {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

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

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

.btn-secondary {
    background-color: var(--btn-secondary);
    color: var(--text-primary);
}

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

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

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-icon:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-check {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-check:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-check.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.ratio-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-title {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: -8px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    border: 2px solid white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--accent);
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

.crop-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.grid-v-1, .grid-v-2, .grid-h-1, .grid-h-2 {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
}

.grid-v-1 { left: 33.33%; top: 0; height: 100%; width: 1px; }
.grid-v-2 { left: 66.66%; top: 0; height: 100%; width: 1px; }
.grid-h-1 { top: 33.33%; left: 0; width: 100%; height: 1px; }
.grid-h-2 { top: 66.66%; left: 0; width: 100%; height: 1px; }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-sidebar);
    width: 400px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-primary);
    cursor: pointer;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Bulk View */
.bulk-view {
    width: 100%;
    max-width: 1000px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.bulk-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.bulk-list {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding-right: 8px;
}

.bulk-item {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

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

.bulk-item-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bulk-item-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.bulk-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bulk-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bulk-item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.bulk-item-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.bulk-item:hover .bulk-item-remove {
    opacity: 1;
}

.bulk-item-remove:hover {
    background: #ef4444;
}

.bulk-actions-bar {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.bulk-options {
    display: flex;
    gap: 20px;
    flex: 1;
}

.bulk-options .control-field {
    flex: 1;
}

select {
    background: var(--btn-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 100%;
    cursor: pointer;
}
