/**
 * Image Cropper Tool Styles
 * Modern, clean, and mobile-friendly design
 */

/* Tool Container - Full Page Layout */
.image-cropper-tool {
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 0;
    margin: 0;
}

.tool-container {
    max-width: 100%;
    margin: 0;
    padding: 2rem;
    background: transparent;
}

/* Tool Header */
.tool-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.tool-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: black;
    margin-bottom: 1rem;
    
}

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

/* Upload Section */
.upload-section {
    max-width: 800px;
    margin: 0 auto 3rem;
    padding: 2rem;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    padding: 4rem 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-light);
    position: relative;
    overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(50, 146, 109, 0.05);
    transform: translateY(-2px);
}

.upload-content {
    position: relative;
    z-index: 2;
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: block;
}

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

.upload-area p {
    color: var(--text-light);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.upload-btn {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(50, 146, 109, 0.3);
}

.upload-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(50, 146, 109, 0.4);
}

.upload-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(50, 146, 109, 0.05);
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
}

.info-item i {
    color: var(--primary-color);
    font-size: 1.25rem;
    flex-shrink: 0;
}

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

/* Cropping Section */
.cropping-section {
    max-width: 100%;
    margin: 0 auto;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Cropping Layout - Sidebar Design */
.cropping-layout {
    display: flex;
    min-height: 80vh;
    gap: 0;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
}

.canvas-header {
    background: var(--white);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.canvas-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.canvas-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tool-btn {
    background: var(--white);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

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

.zoom-level {
    background: var(--bg-light);
    color: var(--text-color);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    min-width: 50px;
    text-align: center;
    border: 1px solid var(--border-color);
}

/* Controls Sidebar */
.controls-sidebar {
    width: 320px;
    background: var(--white);
    border-left: 1px solid var(--border-color);
    padding: 2rem;
    overflow-y: auto;
    flex-shrink: 0;
}

.control-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1rem 0;
}

/* Aspect Ratio Grid */
.aspect-ratio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.aspect-btn {
    background: var(--bg-light);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

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

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

/* Custom Ratio Section */
.custom-ratio-section {
    margin-top: 1rem;
}

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

.custom-ratio-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-ratio-inputs input {
    width: 60px;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    font-size: 0.875rem;
    transition: var(--transition);
}

.custom-ratio-inputs input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(50, 146, 109, 0.1);
}

.ratio-separator {
    font-weight: 600;
    color: var(--text-color);
}

.apply-btn {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Dimension Inputs */
.dimension-inputs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.input-group input {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--bg-light);
    color: var(--text-color);
}

/* Setting Groups */
.setting-group {
    margin-bottom: 1.5rem;
}

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

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

.quality-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
    margin-top: 0.5rem;
}

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

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

.format-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.format-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(50, 146, 109, 0.1);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-btn {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
}

.action-btn.primary {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(50, 146, 109, 0.3);
}

.action-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(50, 146, 109, 0.4);
}

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

.action-btn.secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: #f8f9fa;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canvas-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 70vh;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

.cropper-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    cursor: grab;
}

.cropper-canvas:active {
    cursor: grabbing;
}

/* Crop Overlay */
.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);
    background: rgba(50, 146, 109, 0.1);
    pointer-events: all;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--white);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.crop-handle:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.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-handle.n { top: -6px; left: calc(50% - 6px); cursor: n-resize; }
.crop-handle.s { bottom: -6px; left: calc(50% - 6px); cursor: s-resize; }
.crop-handle.w { top: calc(50% - 6px); left: -6px; cursor: w-resize; }
.crop-handle.e { top: calc(50% - 6px); right: -6px; cursor: e-resize; }

.crop-move-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: move;
}

/* Crop Info Panel */
.crop-info-panel {
    background: var(--bg-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
}

.info-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.875rem;
}

.info-group span {
    background: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Export Section */
.export-section {
    padding: 2rem;
    background: var(--white);
}

.export-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.export-options {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.875rem;
}

.format-select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.format-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(50, 146, 109, 0.1);
}

.quality-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quality-slider {
    width: 120px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
}

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

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

.export-actions {
    display: flex;
    gap: 1rem;
}

.export-actions .action-btn {
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 50px;
}

.export-actions .action-btn.primary {
    background: var(--primary-color);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(50, 146, 109, 0.3);
}

.export-actions .action-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(50, 146, 109, 0.4);
}

.export-actions .action-btn.secondary {
    background: var(--white);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.export-actions .action-btn.secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

/* Loading Section */
.loading-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    margin: 2rem auto;
    max-width: 600px;
}

.loading-content {
    text-align: center;
    padding: 3rem;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.loading-content p {
    color: var(--text-light);
    font-size: 1rem;
}

/* Tool Features */
.tool-features {
    max-width: 1200px;
    margin: 4rem auto 0;
    padding: 3rem 2rem;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.tool-features h2 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 3rem;
}

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

.feature-item {
    text-align: center;
    padding: 2rem;
    background: var(--bg-light);
    border-radius: 15px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.feature-item i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: block;
}

.feature-item h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.feature-item p {
    color: var(--text-light);
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cropping-layout {
        flex-direction: column;
    }

    .controls-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding: 1.5rem;
    }

    .canvas-area {
        min-height: 60vh;
    }

    .aspect-ratio-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .action-buttons {
        flex-direction: row;
        gap: 1rem;
    }

    .action-btn {
        flex: 1;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 768px) {
    .tool-container {
        padding: 1rem;
    }

    .tool-header h1 {
        font-size: 2rem;
    }

    .tool-description {
        font-size: 1rem;
    }

    .canvas-header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .canvas-header h2 {
        text-align: center;
        font-size: 1.25rem;
    }

    .canvas-toolbar {
        justify-content: center;
        gap: 0.25rem;
    }

    .tool-btn {
        min-width: 32px;
        min-height: 32px;
        padding: 0.25rem;
    }

    .zoom-level {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        min-width: 40px;
    }

    .controls-sidebar {
        padding: 1rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .aspect-ratio-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .aspect-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    .custom-ratio-inputs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .custom-ratio-inputs input {
        width: 50px;
        padding: 0.5rem 0.25rem;
    }

    .dimension-inputs {
        gap: 0.75rem;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .action-btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .feature-item {
        padding: 1.5rem;
    }

    .canvas-wrapper {
        max-height: 50vh;
    }
}

@media (max-width: 480px) {
    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .upload-area h3 {
        font-size: 1.25rem;
    }

    .upload-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .info-item {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .custom-ratio-inputs {
        flex-direction: column;
        gap: 1rem;
    }

    .export-actions .action-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .crop-handle {
        width: 20px;
        height: 20px;
    }

    .crop-handle.nw { top: -10px; left: -10px; }
    .crop-handle.ne { top: -10px; right: -10px; }
    .crop-handle.sw { bottom: -10px; left: -10px; }
    .crop-handle.se { bottom: -10px; right: -10px; }
    .crop-handle.n { top: -10px; left: calc(50% - 10px); }
    .crop-handle.s { bottom: -10px; left: calc(50% - 10px); }
    .crop-handle.w { top: calc(50% - 10px); left: -10px; }
    .crop-handle.e { top: calc(50% - 10px); right: -10px; }

    .aspect-btn,
    .transform-btn,
    .zoom-btn,
    .action-btn {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }

    .upload-btn {
        min-height: 48px;
        padding: 1rem 2rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .crop-selection {
        border-width: 3px;
    }

    .crop-handle {
        border-width: 3px;
    }

    .aspect-btn.active {
        background: var(--text-color);
        color: var(--white);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner {
        animation: none;
        border-top-color: var(--primary-color);
    }
}
