/* MathDocs - 스타일시트 */

* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 900px;
    width: 100%;
}

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

h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 5px;
}

.description {
    font-size: 0.9rem;
    color: #999;
}

main {
    min-height: 300px;
}

/* 업로드 영역 */
.upload-section {
    margin-bottom: 20px;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-area.drag-over {
    border-color: #667eea;
    background: #f0f3ff;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.upload-area p {
    color: #666;
    margin-bottom: 20px;
}

/* 버튼 */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(17, 153, 142, 0.4);
}

.btn-download {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.1rem;
    padding: 15px 40px;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #666;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* 파일 정보 */
.file-info {
    background: #f8f9ff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-size: 1rem;
    color: #333;
}

.file-name span:last-child {
    margin-left: 10px;
}

/* 진행 상황 */
.progress-section {
    text-align: center;
    padding: 20px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.progress-message {
    color: #666;
    margin-top: 10px;
}

/* 결과 */
.result-section {
    text-align: center;
    padding: 20px;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.result-section h3 {
    color: #11998e;
    margin-bottom: 20px;
}

/* 에러 */
.error-section {
    text-align: center;
    padding: 20px;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.error-section h3 {
    color: #e74c3c;
    margin-bottom: 10px;
}

.error-section p {
    color: #666;
    margin-bottom: 20px;
}

/* 푸터 */
footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #999;
    font-size: 0.9rem;
}

/* 애니메이션 */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.processing .upload-icon {
    animation: pulse 1s infinite;
}

/* 반응형 */
@media (max-width: 900px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .file-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .btn {
        width: 100%;
        margin: 5px 0;
    }
}

/* 영역 지정 섹션 */
.region-section {
    max-width: 100%;
    overflow: visible;
}

#regionCanvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
}

/* ===== 페이지 관리 패널 ===== */
.page-manager {
    margin-top: 20px;
}

.pm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9ff;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 15px;
}

.pm-badge {
    background: #667eea;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 140px));
    gap: 8px;
    margin-bottom: 16px;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px;
}

@media (max-width: 480px) {
    .thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 120px));
        gap: 6px;
    }
}

.thumb-card {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    max-width: 140px;
}

.thumb-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102,126,234,0.2);
}

.thumb-card.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.3);
}

.thumb-card.excluded {
    opacity: 0.35;
    pointer-events: none;
}

.thumb-card.excluded .thumb-overlay {
    display: flex;
}

.thumb-img {
    width: 100%;
    height: auto;
    max-height: 180px;
    object-fit: contain;
    display: block;
    background: white;
}

.thumb-label {
    text-align: center;
    font-size: 12px;
    padding: 4px;
    background: #f0f0f0;
    font-weight: 600;
    color: #555;
}

.thumb-controls {
    display: flex;
    justify-content: center;
    gap: 2px;
    padding: 3px;
    background: #f8f8f8;
}

.thumb-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.thumb-btn:hover {
    background: #e0e0e0;
}

.thumb-btn.delete-btn:hover {
    background: #ffcccc;
}

.thumb-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    color: white;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
}

.thumb-rotation {
    font-size: 10px;
    color: #888;
    margin-left: 4px;
}

/* 미리보기 패널 */
.preview-panel {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
}

.preview-canvas-wrap {
    display: flex;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 12px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 40px;
    font-size: 1.1rem;
}

.pm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}
