/* CSS Variables */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-color: #ffffff;
    --surface-color: #f9fafb;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #60a5fa;
        --primary-hover: #3b82f6;
        --bg-color: #111827;
        --surface-color: #1f2937;
        --border-color: #374151;
        --text-color: #f9fafb;
        --text-secondary: #d1d5db;
        --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout components */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.main {
    min-height: calc(100vh - 80px);
    padding: 2rem 0;
}

.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 2rem;
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tool-title-section h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.tool-title-section p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.tool-lang-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-selector {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.lang-selector:hover {
    border-color: var(--primary-color);
}

.lang-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* 图片编辑器特定样式 */
.editor-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* 使用指南移动端适配 */
    .guide-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    .guide-header {
        padding: 1rem;
    }
    
    .guide-header h3 {
        font-size: 1.25rem;
    }
    
    .guide-section {
        padding: 1rem;
    }
}

.controls-panel {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    height: fit-content;
}

.control-group {
    margin-bottom: 2rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.upload-section {
    text-align: center;
    margin-bottom: 2rem;
}

.size-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.size-input {
    width: 80px;
}

.rotate-controls,
.filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.action-controls {
    margin-top: 2rem;
    text-align: center;
}

.preview-area {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    position: relative;
    overflow: auto;
}

.image-canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0.25rem;
    box-shadow: var(--shadow);
}

.no-image-placeholder {
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.no-image-placeholder span {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.image-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: var(--bg-color);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.help-section {
    margin-top: 1rem;
}

.help-section details {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
}

.help-section summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
}

.help-section ul {
    margin-top: 1rem;
    padding-left: 1.5rem;
}

.help-section li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* 使用指南样式 */
.usage-guide {
    margin-top: 3rem;
    background: var(--surface-color);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.guide-header {
    background: var(--surface-color);
    color: var(--text-color);
    padding: 1.5rem 2rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.guide-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-color);
}

.guide-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: normal;
}

.guide-content {
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.guide-section {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: border-color 0.2s ease;
}

.guide-section:hover {
    border-color: var(--primary-color);
}

.guide-section h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.guide-list li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.9rem;
}

.guide-list li:before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.guide-list li:last-child {
    margin-bottom: 0;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.5rem;
}

.btn:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
}

.btn:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

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

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

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

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

/* Form Styles */
.form-input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.form-input:hover {
    border-color: var(--primary-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Crop functionality styles */
.canvas-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
}

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

.crop-selection {
    position: absolute;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.1);
    pointer-events: all;
    cursor: move;
    min-width: 10px;
    min-height: 10px;
}

.crop-selection::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px dashed rgba(59, 130, 246, 0.5);
}

.crop-selection .resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.crop-selection .resize-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.crop-selection .resize-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.crop-selection .resize-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.crop-selection .resize-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }
.crop-selection .resize-handle.n { top: -4px; left: 50%; margin-left: -4px; cursor: n-resize; }
.crop-selection .resize-handle.s { bottom: -4px; left: 50%; margin-left: -4px; cursor: s-resize; }
.crop-selection .resize-handle.w { top: 50%; left: -4px; margin-top: -4px; cursor: w-resize; }
.crop-selection .resize-handle.e { top: 50%; right: -4px; margin-top: -4px; cursor: e-resize; }

/* Adjustment controls styles */
.adjustment-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.slider-control label {
    font-size: 0.8rem;
    color: var(--text-color);
    min-width: 70px;
    font-weight: 500;
}

.slider {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-control span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 30px;
    text-align: right;
    font-weight: 500;
}
