/* 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: #666;
    font-size: 1.1em;
}

/* 모드 선택 탭 */
.mode-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
}

.mode-tab {
    background: transparent;
    border: none;
    padding: 15px 25px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    transition: all 0.3s ease;
    color: #666;
    position: relative;
    white-space: nowrap;
    min-width: 150px;
}

.mode-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    transform: translateY(-2px);
}

.mode-tab:hover:not(.active) {
    background: #f0f2ff;
    color: #667eea;
}

/* 모드 컨텐츠 */
.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

/* 파일 업로드 섹션 */
.upload-section {
    text-align: center;
    margin-bottom: 30px;
}

.upload-box {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 50px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9ff;
}

.upload-box:hover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: translateY(-2px);
}

.upload-box.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.7;
}

.upload-box h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.upload-box p {
    color: #666;
    margin-bottom: 5px;
}

.file-info {
    font-size: 0.9em;
    color: #999;
}

/* 웹 이미지 섹션 */
.web-section {
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.input-group input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.url-info {
    background: #f9f9ff;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.url-info ul {
    margin-left: 20px;
    margin-top: 10px;
}

.url-info li {
    margin-bottom: 5px;
    color: #666;
}

/* AI 이미지 생성 섹션 */
.ai-section {
    margin-bottom: 30px;
}

.prompt-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.features-info {
    background: #f0f8ff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #4CAF50;
}

.features-info ul {
    margin-left: 20px;
    margin-top: 10px;
}

.features-info li {
    margin-bottom: 8px;
    color: #555;
}

.input-group textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.prompt-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: flex-end;
}

.example-prompts {
    margin-top: 20px;
}

.prompt-examples {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.example-prompt {
    background: #e8ebff;
    color: #667eea;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.example-prompt:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* 예시 URL 스타일 */
.example-urls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.example-url {
    background: #e8f4fd;
    color: #1976d2;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    border: 1px solid #bbdefb;
}

.example-url:hover {
    background: #1976d2;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(25, 118, 210, 0.3);
}

/* 웹 이미지 작업 공간 */
.web-workspace {
    margin-top: 30px;
    background: #f9f9ff;
    border-radius: 15px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.workspace-container {
    display: flex;
    height: 80vh; /* 화면 높이의 80%로 설정 */
    max-height: 800px;
    min-height: 600px;
}

/* 왼쪽 갤러리 패널 (1/3) */
.gallery-panel {
    width: 33.333%;
    border-right: 2px solid #e0e0e0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.gallery-header {
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #ffffff;
    flex-shrink: 0;
}

.gallery-panel h3 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.2em;
}

.gallery-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px 20px 20px;
}

.image-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

/* 오른쪽 미리보기 패널 (2/3) */
.preview-panel {
    width: 66.667%;
    padding: 20px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* 스크롤바 스타일링 */
.preview-panel::-webkit-scrollbar {
    width: 6px;
}

.preview-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.preview-panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.preview-panel::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.selected-preview {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.converted-result {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.selected-preview .image-display {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
    background: #f5f5f5;
    border-radius: 8px;
    margin-top: 10px;
}

.converted-result .image-display {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f5f5f5;
    border-radius: 8px;
    margin-top: 10px;
    height: 400px;
}

.image-display img, .image-display canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    object-fit: contain;
}

.result-actions {
    margin-top: 15px;
    text-align: center;
}

/* 이미지 로딩 상태 */
.loading-status {
    background: white;
    border-radius: 10px;
    padding: 40px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-content h3 {
    color: #667eea;
    margin: 15px 0 10px 0;
    font-size: 1.2em;
}

.loading-content p {
    color: #666;
    margin: 0;
    font-size: 0.95em;
}

.spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* 웹 이미지 컨트롤 섹션 */
.web-controls-section {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.web-controls-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.controls-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.web-action-buttons {
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

/* 웹 이미지 갤러리 (기존 호환성) */
.web-image-gallery {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9ff;
    border-radius: 15px;
    border: 1px solid #e0e0e0;
}

.web-image-gallery h3 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.gallery-image {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 3px solid transparent;
    background: white;
}

.gallery-image:hover {
    transform: scale(1.05);
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.gallery-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.gallery-image .image-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 5px;
    font-size: 0.8em;
    text-align: center;
}

.gallery-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.gallery-loading .spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 15px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* AI 결과 섹션 */
.ai-results {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9ff;
    border-radius: 15px;
    border: 1px solid #e0e0e0;
}

.ai-results h3 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.generated-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.generated-image-container {
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 3px solid transparent;
}

.generated-image-container:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

.generated-image-container img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

/* 이미지 미리보기 */
.preview-section {
    margin-bottom: 30px;
    text-align: center;
}

.preview-section h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9f9f9;
    border-radius: 15px;
    padding: 20px;
    min-height: 200px;
}

.image-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.image-container canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* 컨트롤 섹션 */
.controls-section {
    background: #f9f9ff;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-group input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.slider-group span {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
}

.control-group select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
    width: 100%;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-group label {
    cursor: pointer;
    font-weight: 600;
    color: #333;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* 결과 섹션 */
.result-section {
    text-align: center;
    margin-bottom: 30px;
}

.result-section h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

/* 버튼 스타일 */
.primary-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 13px 28px;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.secondary-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* 로딩 오버레이 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-spinner p {
    font-size: 1.2em;
    font-weight: 600;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px;
        border-radius: 15px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .mode-tabs {
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
        overflow-x: visible;
    }
    
    .mode-tab {
        min-width: auto;
        flex: 1;
        padding: 10px 8px;
        font-size: 0.85em;
        text-align: center;
        min-width: 90px;
        max-width: 120px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .prompt-controls {
        flex-direction: column;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .generated-images {
        grid-template-columns: 1fr;
    }
    
    .prompt-examples {
        justify-content: center;
    }
    
    /* 웹 워크스페이스 모바일 대응 */
    .workspace-container {
        flex-direction: column;
        height: auto;
        max-height: none;
    }
    
    .gallery-panel {
        width: 100%;
        height: 300px;
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }
    
    .gallery-header {
        padding: 15px;
    }
    
    .gallery-scrollable {
        padding: 10px 15px 15px 15px;
    }
    
    .image-grid-compact {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
    
    .preview-panel {
        width: 100%;
        height: auto;
        gap: 10px;
        overflow-y: auto;
    }
    
    .selected-preview {
        padding: 12px;
    }
    
    .converted-result {
        padding: 12px;
    }
    
    .selected-preview .image-display {
        height: 150px;
    }
    
    .converted-result .image-display {
        min-height: 180px;
    }
    
    .web-controls-section {
        padding: 12px;
    }
    
    .controls-grid-compact {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
        margin: 5px;
    }
    
    .mode-tabs {
        gap: 5px;
        margin-bottom: 20px;
    }
    
    .mode-tab {
        padding: 8px 4px;
        font-size: 0.75em;
        min-width: 70px;
        max-width: 100px;
        line-height: 1.2;
    }
    
    .upload-box {
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 3em;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .mode-tab {
        padding: 10px 15px;
        font-size: 0.9em;
    }
}