/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: #1a1a2e; background: #f5f6fa; min-height: 100vh; display: flex; flex-direction: column; }

/* ===== Header ===== */
.header { background: #fff; border-bottom: 1px solid #e1e4e8; padding: 0 1.5rem; height: 60px; }
.header-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 100%; }
.logo { font-size: 1.5rem; font-weight: 700; color: #2d3436; text-decoration: none; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { background: #6c5ce7; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; }
.username { font-size: 0.875rem; color: #636e72; }

/* ===== User Dropdown Menu ===== */
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 0.5rem; background: none; border: 1px solid transparent; border-radius: 8px; padding: 0.3rem 0.5rem; cursor: pointer; transition: all 0.2s; }
.user-menu-btn:hover { background: #f5f6fa; border-color: #e1e4e8; }
.chevron { font-size: 0.7rem; color: #b2bec3; }
.user-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid #e1e4e8; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.1); min-width: 160px; z-index: 100; overflow: hidden; }
.user-dropdown.show { display: block; }
.dropdown-item { display: block; width: 100%; padding: 0.6rem 1rem; text-align: left; background: none; border: none; font-size: 0.875rem; color: #2d3436; cursor: pointer; text-decoration: none; }
.dropdown-item:hover { background: #f5f6fa; }
.dropdown-item-danger { color: #e17055; }
.dropdown-item-danger:hover { background: #fff5f5; }
.dropdown-divider { height: 1px; background: #e1e4e8; margin: 0; }

/* ===== Main ===== */
.main-content { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 2rem 1.5rem; }

/* ===== Footer ===== */
.footer { background: #fff; border-top: 1px solid #e1e4e8; padding: 1rem 1.5rem; text-align: center; }
.footer-inner { max-width: 1200px; margin: 0 auto; color: #636e72; font-size: 0.8rem; }

/* ===== Buttons ===== */
.btn { display: inline-block; padding: 0.5rem 1.25rem; border-radius: 6px; border: 1px solid transparent; font-size: 0.875rem; font-weight: 500; cursor: pointer; text-decoration: none; text-align: center; transition: all 0.2s; }
.btn-primary { background: #6c5ce7; color: #fff; border-color: #6c5ce7; }
.btn-primary:hover { background: #5f3dc4; }
.btn-outline { background: transparent; color: #636e72; border-color: #dfe6e9; }
.btn-outline:hover { background: #f5f6fa; border-color: #b2bec3; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: #636e72; margin-bottom: 0.3rem; }
.form-input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #dfe6e9; border-radius: 6px; font-size: 0.9rem; transition: border-color 0.2s; outline: none; }
.form-input:focus { border-color: #6c5ce7; box-shadow: 0 0 0 3px rgba(108,92,231,0.1); }
.form-textarea { min-height: 80px; resize: vertical; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 12px; font-size: 0.75rem; font-weight: 500; }
.badge-gray { background: #dfe6e9; color: #636e72; }
.badge-orange { background: #ffeaa7; color: #d35400; }

/* ===== Alerts ===== */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.875rem; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #28a745; }

/* ===== Divider ===== */
.divider { display: flex; align-items: center; margin: 1.5rem 0; color: #b2bec3; font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #e1e4e8; }
.divider span { padding: 0 1rem; }

/* ===== Auth Links ===== */
.auth-links { text-align: center; font-size: 0.85rem; color: #636e72; }
.auth-links a { color: #6c5ce7; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ===== Login Page ===== */
.login-body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); display: flex; align-items: center; justify-content: center; }
.login-container { text-align: center; }
.login-card { background: #fff; border-radius: 16px; padding: 2.5rem 2rem; box-shadow: 0 20px 60px rgba(0,0,0,0.15); min-width: 380px; text-align: left; }
.login-logo { font-size: 2rem; font-weight: 700; color: #2d3436; text-align: center; }
.login-subtitle { color: #636e72; text-align: center; margin-bottom: 1.5rem; }
.login-header { text-align: center; margin-bottom: 1.5rem; }
.telegram-widget-area { display: flex; justify-content: center; min-height: 46px; }
.error-area { background: #ffe0e0; color: #c0392b; padding: 0.75rem 1rem; border-radius: 6px; margin-top: 1rem; font-size: 0.875rem; }
.success-area { background: #d4edda; color: #155724; padding: 0.75rem 1rem; border-radius: 6px; margin-top: 1rem; font-size: 0.875rem; text-align: center; }
.login-footer { margin-top: 2rem; color: rgba(255,255,255,0.7); font-size: 0.8rem; }
.telegram-badge { background: #e3f2fd; color: #1976d2; padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.85rem; text-align: center; margin-bottom: 1rem; }
.message-icon { font-size: 3rem; margin-bottom: 0.5rem; }

/* ===== Spinner ===== */
.spinner { width: 32px; height: 32px; border: 3px solid #e1e4e8; border-top-color: #6c5ce7; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Dashboard ===== */
.section-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.service-card { background: #fff; border-radius: 12px; padding: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: box-shadow 0.2s, transform 0.2s; }
.service-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.1); transform: translateY(-2px); }
.service-inactive { opacity: 0.7; }
.service-icon { width: 48px; height: 48px; margin-bottom: 1rem; }
.service-icon img { width: 100%; height: 100%; object-fit: contain; }
.service-icon-fallback { width: 48px; height: 48px; background: #6c5ce7; color: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 700; }
.service-name { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.service-description { color: #636e72; font-size: 0.875rem; line-height: 1.5; margin-bottom: 1.25rem; }
.service-footer { display: flex; align-items: center; }
.empty-state { text-align: center; padding: 3rem; color: #636e72; }

/* ===== Profile ===== */
.profile-container { max-width: 600px; }
.profile-container h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.profile-avatar-section { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; padding: 1.5rem; background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.avatar-large { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; font-size: 2rem; }
.avatar-upload .hint { font-size: 0.75rem; color: #b2bec3; margin-top: 0.3rem; }
.profile-section { background: #fff; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.profile-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #f0f0f0; }
.profile-field { display: flex; justify-content: space-between; padding: 0.5rem 0; font-size: 0.9rem; }
.profile-field label { color: #636e72; font-weight: 500; }
.profile-field span { color: #2d3436; }
.save-result { margin-left: 1rem; font-size: 0.85rem; }
.save-success { color: #00b894; }
.save-error { color: #e17055; }

/* ===== EPUB Converter ===== */
.service-page { max-width: 700px; margin: 0 auto; }
.breadcrumb { display: inline-block; color: #636e72; text-decoration: none; font-size: 0.875rem; margin-bottom: 1.5rem; }
.breadcrumb:hover { color: #6c5ce7; }
.service-header { margin-bottom: 2rem; }
.service-header h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.service-header p { color: #636e72; }

.upload-section { margin-bottom: 1.5rem; }
.drop-zone { border: 2px dashed #dfe6e9; border-radius: 12px; padding: 3rem 2rem; text-align: center; transition: all 0.2s; cursor: pointer; background: #fff; }
.drop-zone.drag-over { border-color: #6c5ce7; background: #f3f0ff; }
.drop-zone-content p { color: #636e72; margin: 0.5rem 0; }
.drop-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.drop-hint { font-size: 0.8rem; color: #b2bec3; margin-top: 1rem !important; }

.options-section { background: #fff; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.options-section h3 { font-size: 1rem; margin-bottom: 1rem; }
.format-options { display: flex; gap: 1rem; }
.format-option { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; padding: 0.5rem 1rem; border: 1px solid #dfe6e9; border-radius: 8px; transition: all 0.2s; }
.format-option:has(input:checked) { border-color: #6c5ce7; background: #f3f0ff; }
.format-option input { accent-color: #6c5ce7; }
.format-label { font-size: 0.875rem; font-weight: 500; }

.file-info { background: #fff; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.file-info p { margin-bottom: 0.5rem; color: #636e72; font-size: 0.875rem; }

.result-section { background: #fff; border-radius: 12px; padding: 2rem; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.progress-bar { width: 100%; height: 8px; background: #e1e4e8; border-radius: 4px; overflow: hidden; margin-bottom: 1rem; }
.progress-fill { height: 100%; background: #6c5ce7; border-radius: 4px; transition: width 0.3s; animation: progress-anim 2s ease-in-out infinite; width: 60%; }
@keyframes progress-anim { 0% { width: 10%; } 50% { width: 80%; } 100% { width: 10%; } }
.progress-text { color: #636e72; font-size: 0.875rem; }
.success-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.success-text { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.5rem; color: #00b894; }
#downloadLink { margin-right: 0.75rem; }

.error-page { text-align: center; padding: 3rem; }
.error-page h2 { margin-bottom: 1rem; }
.error-page p { color: #636e72; margin-bottom: 2rem; }

/* ===== Duplicate Alert ===== */
.duplicate-alert { background: #fff3cd; border: 1px solid #ffc107; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.duplicate-alert-title { font-weight: 600; color: #856404; margin-bottom: 0.5rem; }
.duplicate-alert-detail { color: #856404; font-size: 0.875rem; margin-bottom: 1rem; }
.duplicate-alert-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ===== Conversion History ===== */
.history-section { margin-top: 2rem; }
.history-section h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.history-table-wrapper { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.history-table th { background: #f5f6fa; padding: 0.75rem 1rem; text-align: left; font-size: 0.8rem; font-weight: 600; color: #636e72; border-bottom: 1px solid #e1e4e8; }
.history-table td { padding: 0.75rem 1rem; font-size: 0.85rem; border-bottom: 1px solid #f0f0f0; color: #2d3436; }
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: #f9f9fb; }
.history-dl-btn { background: none; border: none; color: #6c5ce7; cursor: pointer; font-size: 1rem; padding: 0.25rem 0.5rem; border-radius: 4px; transition: background 0.2s; }
.history-dl-btn:hover { background: #f3f0ff; }
.history-dl-btn:disabled { color: #b2bec3; cursor: not-allowed; }
.history-dl-btn:disabled:hover { background: none; }
.format-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.format-badge-pdf { background: #ffe0e0; color: #c0392b; }
.format-badge-text { background: #e0f0ff; color: #2980b9; }
.format-badge-html { background: #e0ffe0; color: #27ae60; }
.format-badge-icon { background: #e0f7f0; color: #00a37a; text-transform: none; }
#loadMoreBtn { display: block; margin: 1rem auto 0; }

/* ===== 아이콘 생성기 전용 ===== */
.mode-options { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.mode-option { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; padding: 0.5rem 1rem; border: 1px solid #dfe6e9; border-radius: 8px; transition: all 0.2s; font-size: 0.875rem; }
.mode-option:has(input:checked) { border-color: #00b894; background: #e0f7f0; }
.mode-option input { accent-color: #00b894; }
.preview-meta { color: #636e72; font-size: 0.85rem; margin-bottom: 0.75rem; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.9rem; }
.preview-card { background: #fff; border: 1px solid #e1e4e8; border-radius: 8px; padding: 0.6rem; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.preview-thumb { width: 100%; aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; background: #f5f6fa; border-radius: 6px; margin-bottom: 0.5rem; overflow: hidden; }
.preview-thumb img { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.preview-name { font-size: 0.75rem; color: #2d3436; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.15rem; }
.preview-meta-small { font-size: 0.7rem; color: #b2bec3; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .service-grid { grid-template-columns: 1fr; }
    .login-card { min-width: auto; margin: 0 1rem; }
    .format-options { flex-direction: column; }
    .mode-options { flex-direction: column; }
    .profile-avatar-section { flex-direction: column; text-align: center; }
}
