/* Image Cropper Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.subtitle {
    text-align: center;
    margin-bottom: 40px;
    color: #666;
    font-size: 1.2em;
}

/* セクション共通スタイル */
.upload-section,
.cropping-section,
.result-section,
.usage-section,
.ad-section {
    background: white;
    margin-bottom: 30px;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

/* ===== セクションタイトル ===== */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== アップロードセクション ===== */
.upload-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.upload-area {
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 500px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.upload-area.dragover {
    border-color: #3b82f6;
    background-color: #eff6ff;
    transform: scale(1.02);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

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

.upload-text {
    text-align: center;
}

.upload-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.upload-subtitle {
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.upload-formats,
.upload-size {
    font-size: 0.875rem;
    color: #9ca3af;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    pointer-events: none;
}

.upload-options {
    display: flex;
    justify-content: center;
}

.format-select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
}

/* ===== ズーム制御 ===== */
.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 600;
}

.zoom-btn:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
    color: #3b82f6;
}

.zoom-btn:active {
    transform: scale(0.95);
}

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

.zoom-btn:disabled:hover {
    background: white;
    border-color: #d1d5db;
    color: #374151;
    transform: none;
}

.zoom-reset {
    margin-left: 0.5rem;
    background: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

.zoom-reset:hover {
    background: #dbeafe;
}

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

/* ===== トリミングセクション ===== */
.cropping-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

.image-preview-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.crop-guide {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    color: #1e40af;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}

.image-preview-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-image {
    display: block;
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
}

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

.crop-selection {
    position: absolute;
    border: 2px solid #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    pointer-events: all;
    cursor: move;
    min-width: 20px;
    min-height: 20px;
    z-index: 11;
}

.crop-selection::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    background: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    pointer-events: all;
    z-index: 12;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.e {
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle.s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.w {
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    cursor: w-resize;
}

.move-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: move;
}

/* ===== トリミングパネル ===== */
.cropping-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== トリミングプレビューカード ===== */
.crop-preview-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.preview-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
    text-align: center;
}

.preview-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}

.preview-canvas-wrapper {
    overflow: auto;
    max-width: 100%;
    max-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    min-height: 200px;
}

.preview-canvas {
    max-width: 100%;
    max-height: 500px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    background: white;
    transition: transform 0.2s ease;
    width: auto;
    height: auto;
}

.preview-info {
    text-align: center;
}

.preview-size {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.crop-info,
.crop-controls {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.info-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
}

.info-grid,
.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    font-size: 0.875rem;
    min-width: 0;
    box-sizing: border-box;
}

.info-label {
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-value {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    box-sizing: border-box;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
}

.control-input {
    padding: 0.375rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

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

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    justify-content: center;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-info {
    background: #06b6d4;
    color: white;
}

.btn-info:hover {
    background: #0891b2;
    transform: translateY(-1px);
}

/* ===== 結果セクション ===== */
.result-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
}

.result-preview {
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.result-canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.download-options {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.format-selection,
.quality-selection {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.quality-selection:last-child {
    margin-bottom: 0;
}

.quality-slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

.quality-value {
    font-weight: 600;
    color: #3b82f6;
    min-width: 35px;
}

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

/* ===== 使い方セクション ===== */
.usage-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.usage-card {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
    transition: all 0.2s ease;
}

.usage-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.usage-step {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.usage-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.usage-content p {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.6;
}

/* ===== レスポンシブデザイン ===== */
@media (max-width: 768px) {
    .subtitle {
        font-size: 1rem;
    }
    
    .upload-section,
    .cropping-section,
    .result-section,
    .usage-section,
    .ad-section {
        padding: 20px;
    }
    
    .upload-area {
        padding: 2rem;
    }
    
    .cropping-container,
    .result-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .info-grid,
    .control-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons,
    .result-actions {
        flex-direction: column;
    }
    
    .usage-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .usage-card {
        padding: 1rem;
    }
    
    .upload-area {
        padding: 1.5rem;
    }
    
    .resize-handle {
        width: 16px;
        height: 16px;
    }
    
    .resize-handle.nw,
    .resize-handle.ne,
    .resize-handle.sw,
    .resize-handle.se {
        top: -8px;
        left: -8px;
    }
    
    .resize-handle.ne,
    .resize-handle.se {
        right: -8px;
        left: auto;
    }
    
    .resize-handle.sw,
    .resize-handle.se {
        bottom: -8px;
        top: auto;
    }
}