/* Image Cropper - Modern Styles */
/* Matching GIF Loop Changer / Watermark Maker design system */

:root {
    /* Primary colors - Green theme for cropping */
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: #D1FAE5;
    
    /* Secondary colors */
    --secondary: #6366F1;
    --secondary-light: #E0E7FF;
    
    /* Status colors */
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    
    /* Neutral colors */
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* Tool Container */
.tool-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 2rem;
}

.hero-icon-wrapper {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg);
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 1rem;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Tool Main */
.tool-main {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Upload Section */
.upload-section {
    padding: 3rem 2rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary-light) 0%, #ecfdf5 100%);
    transform: translateY(-2px);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.upload-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.5rem;
}

.upload-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 1rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-full);
}

/* File Info Bar */
.file-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.file-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-info-item svg {
    color: var(--primary);
}

.file-info-item span {
    font-weight: 500;
    color: var(--text);
}

/* Preview Row */
.preview-row {
    padding: 2rem;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
}

.preview-panel {
    padding: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.panel-header h3 svg {
    color: var(--primary);
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-elevated);
    padding: 0.375rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: repeating-conic-gradient(#e5e7eb 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    transform-origin: center center;
    transition: transform 0.1s ease;
}

#editorCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    border: 2px solid var(--primary);
    background: rgba(16, 185, 129, 0.1);
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.crop-dimensions {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--bg-elevated);
    border: 2px solid var(--primary);
    border-radius: 50%;
}

.handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.handle-n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.handle-e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.handle-s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.handle-w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }

/* Move Hint */
.move-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.8;
}

.move-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: inherit;
}

/* Controls Row */
.controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.controls-panel {
    padding: 2rem;
    border-right: 1px solid var(--border);
}

.controls-panel:last-child {
    border-right: none;
}

/* Settings Groups */
.settings-group {
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

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

.settings-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-title svg {
    color: var(--primary);
}

/* Dimensions Row */
.dimensions-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.dimensions-row .control-group {
    flex: 1;
}

.aspect-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    margin-bottom: 0;
}

.aspect-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.aspect-link.locked {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.aspect-link.locked .link-icon { display: block; }
.aspect-link.locked .unlink-icon { display: none; }
.aspect-link:not(.locked) .link-icon { display: none; }
.aspect-link:not(.locked) .unlink-icon { display: block; }

/* Input with Unit */
.input-with-unit {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
}

.number-input {
    flex: 1;
    border: none;
    padding: 0.625rem 0.75rem;
    font-size: 0.9rem;
    width: 100%;
    min-width: 0;
}

.number-input:focus {
    outline: none;
}

.input-with-unit:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.unit {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    border-left: 1px solid var(--border);
}

/* Shape Buttons */
.shape-buttons {
    display: flex;
    gap: 0.5rem;
}

.shape-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.shape-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: white;
}

.shape-btn span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Position Buttons */
.position-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Preset Settings */
.presets-settings {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border-color: var(--secondary);
}

.preset-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.25rem;
    border-radius: var(--radius-full);
}

.preset-tab {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-tab:hover {
    color: var(--secondary);
}

.preset-tab.active {
    background: var(--secondary);
    color: white;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.625rem 0.75rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

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

.preset-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
}

.preset-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Output Settings */
.output-settings {
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
    border-color: var(--success);
}

/* Control Elements */
.control-group {
    margin-bottom: 1rem;
}

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

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.control-value {
    font-weight: 600;
    color: var(--primary);
}

.control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Select Input */
.select-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Range Input */
.range-input {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.range-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.range-short {
    max-width: 150px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* Output Section */
.output-section {
    padding: 2rem;
    border-top: 1px solid var(--border);
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.output-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--success);
    margin: 0;
}

.output-dimensions {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
}

.output-preview {
    display: flex;
    justify-content: center;
    padding: 2rem;
    background: repeating-conic-gradient(#e5e7eb 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-md);
}

#outputCanvas {
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow-lg);
}

/* Related Tools */
.related-tools {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 2rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.related-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.related-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.related-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Info Sections */
.info-sections {
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.info-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1.25rem;
}

.info-title svg {
    color: var(--primary);
}

/* Steps List */
.steps-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.step-content strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.step-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Shortcuts Grid */
.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.shortcut-item kbd {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
}

.shortcut-item span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* FAQ */
.faq-card {
    grid-column: 1 / -1;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.faq-question:hover {
    background: var(--bg);
}

.faq-arrow {
    color: var(--text-muted);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.faq-item.active .faq-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 200px;
}

.faq-answer p {
    padding: 0 1.25rem 1rem;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Image Move Mode */
.canvas-container.move-mode {
    cursor: move;
}

.canvas-container.move-mode .crop-overlay {
    pointer-events: none;
}

/* Responsive */
@media (max-width: 900px) {
    .controls-row {
        grid-template-columns: 1fr;
    }
    
    .controls-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .controls-panel:last-child {
        border-bottom: none;
    }
    
    .file-info-bar {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .upload-section {
        padding: 2rem 1.5rem;
    }
    
    .preview-row {
        padding: 1.5rem;
    }
    
    .controls-panel {
        padding: 1.5rem;
    }
    
    .shape-buttons {
        flex-wrap: wrap;
    }
    
    .shape-btn {
        min-width: calc(50% - 0.25rem);
    }
    
    .control-row {
        grid-template-columns: 1fr;
    }
    
    .dimensions-row {
        flex-direction: column;
    }
    
    .aspect-link {
        align-self: center;
    }
    
    .action-bar {
        flex-direction: column;
        padding: 1.5rem;
    }
    
    .btn {
        width: 100%;
    }
    
    .related-tools {
        flex-direction: column;
        text-align: center;
    }
    
    .related-links {
        justify-content: center;
    }
    
    .info-sections {
        grid-template-columns: 1fr;
    }
    
    .shortcuts-grid {
        grid-template-columns: 1fr;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .preset-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .shape-btn {
        min-width: 100%;
    }
}

/* Print */
@media print {
    .tool-container {
        max-width: 100%;
    }
    
    .upload-section,
    .action-bar,
    .related-tools {
        display: none;
    }
}
