* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    padding: 5px;
    background: #f5f7fa;
}

.container {
    min-width: 100%;
    margin-top: 5px;
    margin-bottom: 5px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header h1 {
    font-size: 1.6em;
    margin-bottom: 5px;
}

.header p {
    font-size: .8em;
    opacity: 0.9;
}

.content {
    padding: 10px;
}

.main-content {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.upload-section {
    width: 100%;
}

.preview-process-section {
    width: 70%;
    display: flex;
    gap: 20px;
    display: none;
    border: 2px dashed #18defe;
    border-radius: 8px;
    padding: 10px;
    transition: all 0.3s ease;
}

.preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.process-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.preview-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.upload-area {
    border: 2px dashed #4facfe;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #e3f2fd;
}

.upload-icon {
    font-size: 3em;
    color: #4facfe;
    margin-bottom: 10px;
}

.preview-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.format-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.format-option {
    padding: 5px;
    border: 2px solid #0de6fe;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.format-option:hover {
    border-color: #4facfe;
    transform: translateY(-2px);
}

.format-option.selected {
    border-color: #4facfe;
    background: #4facfe;
    color: white;
}

.size-selector {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 5px;
    margin-bottom: 15px;
}

.size-option {
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8em;
}

.size-option:hover {
    border-color: #4facfe;
}

.size-option.selected {
    border-color: #4facfe;
    background: #4facfe;
    color: white;
}

.button-container {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    justify-content: center;
}

.convert-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.convert-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

.convert-btn:disabled {
    background: #35c3fe;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.download-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

.loading {
    display: none;
    text-align: center;
    padding: 15px;
}

.loading.show {
    display: block;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4facfe;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 6px;
    margin-top: 15px;
    display: none;
}

.error.show {
    display: block;
}

.ico-preview-note {
    color: #666;
    font-size: 0.9em;
    margin-top: 10px;
    text-align: center;
}

/* Crop Modal Styles */
.crop-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
}

.crop-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    margin: 30px auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.crop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.crop-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

.crop-close {
    background: none;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.crop-close:hover {
    color: #f44336;
}

.crop-content {
    padding: 20px;
}

.crop-canvas-container {
    max-height: 60vh;
    overflow: hidden;
    text-align: center;
}

#cropImage {
    max-width: 100%;
    max-height: 60vh;
    display: block;
    margin: 0 auto;
}

.crop-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
}

.crop-confirm-btn {
    padding: 10px 30px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.crop-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

.crop-cancel-btn {
    padding: 10px 30px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.crop-cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3);
}

/* Responsive Design */
@media (min-width: 1025px) {
    .preview-section,
    .result-section {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 5px 0;
    }

    .preview-image {
        max-height: 150px;
        height: auto;
        width: auto;
        max-width: 100%;
    }

    .preview-process-section {
        height: 200px;
        align-items: center;
        justify-content: space-around;
        padding: 5px;
    }

    .upload-section {
        width: 100%;
    }

    .preview-process-section {
        width: 70%;
    }

    .upload-area {
        height: 200px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .has-image .upload-section {
        width: 30%;
    }

    .has-image .preview-process-section {
        width: 70%;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
        gap: 15px;
    }

    .upload-section {
        width: 100%;
        order: 1;
    }

    .preview-process-section {
        width: 100%;
        flex-direction: column;
        gap: 15px;
        order: 2;
        align-items: center;
        min-height: auto;
    }

    .preview-section {
        order: 1;
        width: 100%;
        text-align: center;
    }

    .process-section {
        order: 2;
        width: 100%;
        text-align: center;
    }

    .result-section {
        order: 3;
        width: 100%;
        text-align: center;
    }

    .format-selector {
        order: 3;
        margin-top: 20px;
    }

    .size-selector {
        order: 4;
    }

    .button-container {
        order: 5;
        flex-direction: row;
        justify-content: center;
    }

    .error {
        order: 6;
    }

    .upload-area {
        padding: 15px;
        width: 100%;
    }

    .upload-icon {
        font-size: 2.5em;
    }

    .preview-image {
        max-height: 150px;
    }

    .convert-btn,
    .download-btn {
        width: auto;
    }
    
    .crop-container {
        width: 95%;
        margin: 20px auto;
    }
}

@media (max-width: 768px) {
    .crop-container {
        width: 98%;
        margin: 10px auto;
    }
    
    .crop-content {
        padding: 10px;
    }
    
    .crop-actions {
        padding: 10px;
    }
    
    .crop-confirm-btn,
    .crop-cancel-btn {
        padding: 8px 20px;
        font-size: 0.9em;
    }
}

@media (max-width: 450px) {
    .format-selector {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .crop-title {
        font-size: 1em;
    }
    
    .crop-actions {
        flex-direction: column;
    }
    
    .crop-confirm-btn,
    .crop-cancel-btn {
        width: 100%;
        padding: 8px 15px;
    }
}