/* ===== 디자인 시스템 (Tokens) ===== */
:root {
    --bg-dark: #0f0f1a;
    --bg-card: rgba(30, 30, 50, 0.7);
    --bg-hover: rgba(99, 102, 241, 0.15);
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --radius-lg: 16px;
    --radius-md: 8px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 전역 설정 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* ===== 앱 레이아웃 (애플리케이션 베이스) ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    /* 패딩 제거하여 전체 영역 활용 */
}

/* ===== 헤더 ===== */
.header {
    flex-shrink: 0;
    padding: 12px 24px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(15, 15, 26, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== 툴바 ===== */
.toolbar {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(20, 20, 35, 0.6);
    border-bottom: 1px solid var(--border);
}

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

/* ===== 버튼 스타일에 프리미엄 적용 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: var(--success-gradient);
    border: none;
    color: white;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== 내비게이션 정보 ===== */
.page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    min-width: 60px;
    text-align: center;
}

/* ===== 메인 컨텐츠 영역 ===== */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    /* 자식 스크롤 허용 위해 부모는 숨김 */
    background: rgba(0, 0, 0, 0.2);
}

/* ===== 캔버스 (PDF 뷰어) ===== */
.canvas-container {
    flex: 1;
    overflow: auto;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    background-image:
        radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: 24px 24px;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: none;
}

.canvas-wrapper.active {
    display: block;
}

#pdfCanvas {
    display: block;
    background-color: white;
}

#overlayCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

/* ===== 플레이스 홀더 ===== */
.placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.placeholder-icon {
    font-size: 3rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 16px;
}

.placeholder p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 사이드바 ===== */
.sidebar {
    width: 300px;
    background: rgba(20, 20, 35, 0.8);
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--border);
    padding: 24px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== 객체 리스트 ===== */
.image-list {
    list-style: none;
    margin-bottom: 24px;
}

.image-list-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 40px 0;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

.image-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.image-list-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.image-list-item.selected {
    background: var(--bg-hover);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.image-list-item img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
}

.image-list-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-weight: 700;
    color: var(--primary);
}

.image-list-item-info {
    flex: 1;
    min-width: 0;
}

.image-list-item-name {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-list-item-page {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.image-list-item-delete {
    opacity: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.image-list-item:hover .image-list-item-delete {
    opacity: 1;
}

.image-list-item-delete:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* ===== 단축키 가이드 ===== */
.shortcut-info {
    margin-top: 24px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.shortcut-info h4 {
    font-size: 0.8rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.shortcut-info ul {
    list-style: none;
}

.shortcut-info li {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.shortcut-info .key {
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: monospace;
    color: var(--text-primary);
}

/* ===== 객체 속성 바 (Fixed Bottom) ===== */
.property-bar {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    background: rgba(20, 20, 35, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--primary);
    border-radius: 100px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    animation: bounceUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.property-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.property-group input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 20px;
    outline: none;
    width: 150px;
    font-size: 0.85rem;
}

.property-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
}

.property-group input[type="color"] {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
}

/* ===== 유틸리티 ===== */
.status-bar {
    flex-shrink: 0;
    padding: 6px 24px;
    background: rgba(15, 15, 26, 0.9);
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.hidden {
    display: none !important;
}

@keyframes bounceUp {
    from {
        transform: translate(-50%, 100px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* ===== 반응형 브레이크포인트 ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        height: 200px;
    }
}

/* ===== 보안 배지 ===== */
.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: auto;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ===== 기부 버튼 전용 스타일 ===== */
.btn-donation {
    background: #ffdd00 !important;
    color: #000000 !important;
    font-weight: 700 !important;
    border: none !important;
    text-decoration: none;
}

.btn-donation:hover {
    background: #ffea00 !important;
    box-shadow: 0 0 15px rgba(255, 221, 0, 0.4) !important;
    transform: translateY(-1px);
}

.divider-v {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

/* ===== 사이드바 기부 카드 ===== */
.donation-card {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(255, 221, 0, 0.05) 0%, transparent 100%);
    border: 1px solid rgba(255, 221, 0, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.donation-card-icon {
    font-size: 1.5rem;
}

.donation-card-content h5 {
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: #ffdd00;
}

.donation-card-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 12px;
}

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

/* ===== 모달 시스템 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-dark);
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    padding: 32px 24px 16px;
    text-align: center;
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.modal-body {
    padding: 0 32px 24px;
    text-align: center;
}

.modal-body p {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

.security-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.donation-prompt {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.domain-info {
    font-family: monospace;
    opacity: 0.5;
    font-size: 0.7rem;
}