/* Crop Modal Styles */
.crop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.crop-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    animation: cropModalSlideIn 0.3s ease-out;
}

@keyframes cropModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.crop-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.crop-modal-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 4px;
}

.crop-modal-title i {
    color: #007bff;
}

.crop-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.crop-modal-close:hover {
    background: #e9ecef;
    color: #333;
}

.crop-modal-body {
    padding: 8px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

/* Crop Container */
.crop-container {
    display: grid;
    gap: 24px;
    align-items: start;
}

/* Desktop Layout */
@media (min-width: 768px) {
    .crop-container {
        grid-template-columns: 1fr 300px;
    }
    
    .crop-modal-content {
        width: 900px;
        max-width: 90vw;
    }
}

/* Mobile Layout */
@media (max-width: 767px) {
    .crop-container {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .crop-modal-content {
        margin: 40px 5px 60px 5px; /* Üst ve alt margin'i artırdık */
        max-height: calc(100vh - 110px); /* Max height'ı daha da azalttık */
    }
    
    .crop-modal-body {
        padding: 6px;
        max-height: calc(100vh - 110px); /* Body max height'ını da azalttık */
    }
    
    .crop-modal-header {
        padding: 4px 8px;
    }
    
    .crop-modal-title {
        font-size: 12px;
        gap: 2px;
    }
    
    .crop-modal-close {
        padding: 4px;
        font-size: 16px;
    }
}

/* Crop Preview Area */
.crop-preview-area {
    position: relative;
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.crop-main-area {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 150px;
}

/* Crop Result Preview */
.crop-result-preview {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.crop-result-header {
    background: #f8f9fa;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
}

.crop-result-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.crop-result-container {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    background: #fafafa;
}

.crop-result-canvas {
    max-width: 100%;
    max-height: 100px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Mobile Layout Adjustments */
@media (max-width: 767px) {
    .crop-preview-area {
        flex-direction: column;
        gap: 6px;
        padding: 6px;
        min-height: 120px;
    }
    
    .crop-main-area {
        min-height: 100px;
    }
    
    .crop-result-container {
        min-height: 50px;
        padding: 6px;
    }
    
    .crop-result-canvas {
        max-height: 40px;
    }
}

.crop-canvas-container {
    position: relative;
    display: inline-block;
    border: 2px solid #007bff;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.crop-canvas {
    display: block;
    cursor: grab;
    transition: cursor 0.2s ease;
}

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

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.crop-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0.3;
}

.crop-grid-line {
    position: absolute;
    background: #fff;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
}

.crop-grid-line.horizontal {
    height: 1px;
    left: 0;
    right: 0;
}

.crop-grid-line.vertical {
    width: 1px;
    top: 0;
    bottom: 0;
}

/* Crop Controls */
.crop-controls {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 8px;
}

.crop-control-group {
    margin-bottom: 8px;
}

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

.crop-control-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.crop-zoom-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.crop-zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px;
    color: #6c757d;
}

.crop-zoom-btn:hover {
    background: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
}

.crop-zoom-btn:active {
    background: #e9ecef;
    transform: scale(0.95);
}

.crop-zoom-slider-container {
    flex: 1;
    position: relative;
}

.crop-zoom-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e9ecef;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.crop-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.crop-zoom-slider::-webkit-slider-thumb:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.crop-zoom-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.crop-zoom-slider::-moz-range-thumb:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.crop-zoom-value {
    font-size: 11px;
    font-weight: 600;
    color: #007bff;
    min-width: 35px;
    text-align: center;
    background: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #e9ecef;
}


/* Crop Mode Toggle */
.crop-mode-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crop-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.crop-mode-toggle input[type="checkbox"] {
    display: none;
}

.crop-mode-slider {
    position: relative;
    width: 36px;
    height: 18px;
    background: #ccc;
    border-radius: 9px;
    transition: background 0.3s ease;
}

.crop-mode-slider::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.crop-mode-toggle input[type="checkbox"]:checked + .crop-mode-slider {
    background: #007bff;
}

.crop-mode-toggle input[type="checkbox"]:checked + .crop-mode-slider::before {
    transform: translateX(18px);
}

/* Mobilde toggle butonunu küçült */
@media (max-width: 767px) {
    .crop-mode-slider {
        width: 28px;
        height: 14px;
        border-radius: 7px;
    }
    
    .crop-mode-slider::before {
        width: 12px;
        height: 12px;
        top: 1px;
        left: 1px;
    }
    
    .crop-mode-toggle input[type="checkbox"]:checked + .crop-mode-slider::before {
        transform: translateX(14px);
    }
    
    .crop-mode-toggle {
        gap: 6px;
    }
}

.crop-mode-text {
    font-size: 12px;
    font-weight: 500;
    color: #333;
}

.crop-mode-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crop-mode-info span {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.crop-mode-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.crop-mode-tooltip-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-left: 4px;
}

/* Mobilde tooltip iconunu daha küçük yap */
@media (max-width: 767px) {
    .crop-mode-tooltip-icon {
        width: 12px;
        height: 12px;
        font-size: 8px;
        margin-left: 2px;
    }
}

.crop-mode-tooltip-content {
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.crop-mode-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}

.crop-mode-tooltip.active .crop-mode-tooltip-content {
    opacity: 1;
    visibility: visible;
}

.crop-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.crop-btn {
    padding: 6px 8px;
    border: none;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.crop-btn i {
    font-size: 9px;
}

.crop-btn-secondary {
    background: #6c757d;
    color: white;
}

.crop-btn-secondary:hover {
    background: #5a6268;
}

.crop-btn-outline {
    background: transparent;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.crop-btn-outline:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.crop-btn-primary {
    background: #007bff;
    color: white;
}

.crop-btn-primary:hover {
    background: #0056b3;
}

.crop-btn-success {
    background: #28a745;
    color: white;
}

.crop-btn-success:hover {
    background: #1e7e34;
}

/* Crop Info */
.crop-info {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
    color: #1565c0;
    display: none; /* Mobilde gizle, canvas üstünde göster */
}

.crop-info i {
    margin-right: 4px;
}

.crop-canvas-info {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    z-index: 10;
    display: none;
}

.crop-info-close {
    position: absolute;
    top: 2px;
    right: 4px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s ease;
}

.crop-info-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.crop-info-close:active {
    transform: scale(0.95);
}

@media (max-width: 767px) {
    .crop-canvas-info {
        display: block;
        padding: 6px 24px 6px 8px; /* Sağ tarafta kapatma tuşu için yer bırak */
    }
    
    .crop-info-close {
        width: 16px;
        height: 16px;
        font-size: 9px;
        top: 3px;
        right: 3px;
    }
}

/* Loading State */
.crop-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.crop-loading i {
    font-size: 24px;
    color: #007bff;
    animation: spin 1s linear infinite;
}

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

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    .crop-btn {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .crop-zoom-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .crop-zoom-slider {
        height: 12px;
    }
    
    .crop-zoom-slider::-webkit-slider-thumb {
        width: 32px;
        height: 32px;
        border: 4px solid #fff;
    }
    
    .crop-zoom-slider::-moz-range-thumb {
        width: 32px;
        height: 32px;
        border: 4px solid #fff;
    }
    
    .crop-canvas {
        touch-action: none;
    }
    
    /* Mobil için zoom kontrolleri daha büyük */
    .crop-zoom-container {
        gap: 12px;
        margin-bottom: 16px;
    }
    
    /* Mobil için daha büyük dokunmatik hedefler */
    .crop-mode-toggle {
        padding: 8px 0;
    }
    
    .crop-mode-slider {
        width: 60px;
        height: 30px;
    }
    
    .crop-mode-slider::before {
        width: 26px;
        height: 26px;
        top: 2px;
        left: 2px;
    }
    
    .crop-mode-toggle input[type="checkbox"]:checked + .crop-mode-slider::before {
        transform: translateX(30px);
    }
}

/* Mobil landscape optimizasyonu */
@media (max-width: 767px) and (orientation: landscape) {
    .crop-modal-content {
        margin: 5px;
        max-height: calc(100vh - 10px);
    }
    
    .crop-modal-body {
        padding: 8px;
    }
    
    .crop-preview-area {
        padding: 6px;
        gap: 6px;
    }
    
    .crop-main-area {
        min-height: 120px;
    }
    
    .crop-controls {
        padding: 8px;
    }
    
    .crop-control-group {
        margin-bottom: 8px;
    }
    
    .crop-btn {
        padding: 6px 8px;
        font-size: 11px;
    }
}

/* Çok küçük ekranlar için */
@media (max-width: 480px) {
    .crop-controls {
        padding: 6px;
    }
    
    .crop-control-group {
        margin-bottom: 6px;
    }
    
    .crop-btn {
        padding: 5px 6px;
        font-size: 9px;
    }
    
    .crop-zoom-container {
        gap: 4px;
    }
    
    .crop-zoom-btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    
    .crop-zoom-value {
        font-size: 10px;
        padding: 1px 3px;
        min-width: 30px;
    }
    
    .crop-control-label {
        font-size: 12px;
        margin-bottom: 4px;
    }
    
    .crop-mode-text {
        font-size: 11px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .crop-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
.crop-modal:focus-within {
    outline: none;
}

.crop-btn:focus,
.crop-zoom-slider:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Animation for smooth transitions */
.crop-canvas-container {
    transition: transform 0.1s ease-out;
}

.crop-zoom-transition {
    transition: transform 0.2s ease-out;
}
