/* HIRA Crawler WebApp - Modern Beautiful UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --purple-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --bg-solid: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12), 0 4px 10px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 20px rgba(0,0,0,0.12), 0 3px 8px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-solid);
    background-image: var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Header - 더 예쁘게 */
header {
    text-align: center;
    padding: 40px 0 32px;
    margin-bottom: 8px;
}

header h1 {
    font-size: 2.25em;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(99, 102, 241, 0.1);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1em;
    font-weight: 500;
    margin-top: 4px;
}

/* Layout */
main {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 960px) {
    main { grid-template-columns: 1fr; grid-template-rows: none; }
    #settings-panel, #progress-panel, #vnc-panel { grid-column: 1; grid-row: auto; }
}

/* Card / Panel - 더 세련되게 */
.panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255,255,255,0.8);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.panel:hover {
    box-shadow: var(--shadow-hover);
}

.panel h2 {
    font-size: 1.15em;
    font-weight: 700;
    margin-bottom: 28px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

.panel h2::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 22px;
    background: var(--primary-gradient);
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Form - 더 깔끔하게 */
.form-group {
    margin-bottom: 22px;
}

.form-group > label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--text);
    letter-spacing: -0.01em;
}

.hint {
    font-size: 0.8em;
    color: var(--text-muted);
    font-weight: 400;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    transition: all 0.25s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

textarea {
    resize: vertical;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    line-height: 1.6;
    min-height: 120px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-inputs input { width: 85px; }

.date-inputs span {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Radio / Toggle - 더 모던하게 */
.radio-group {
    display: flex;
    gap: 6px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 2px solid transparent;
}

.radio-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88em;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 8px;
    transition: all 0.25s ease;
    color: var(--text-secondary);
    flex: 1;
    text-align: center;
    position: relative;
}

.radio-label:has(input:checked) {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: var(--shadow);
    transform: scale(1.02);
}

.radio-label input[type="radio"] {
    display: none;
}

/* Buttons - 더 예쁘게 */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 28px;
}

.button-row {
    display: flex;
    gap: 12px;
}

button {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: -0.01em;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:hover:not(:disabled)::before {
    width: 300px;
    height: 300px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* 공통 hover: 모든 버튼 translateY(-2px) + shadow 강화 */
button:hover:not(:disabled) {
    transform: translateY(-2px);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login {
    background: var(--purple-gradient);
    color: white;
    flex: 1;
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.25);
}
.btn-login:hover:not(:disabled) {
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}

.btn-login-confirm {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    flex: 1;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}
.btn-login-confirm:hover:not(:disabled) {
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    flex: 1;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.25);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.btn-danger {
    background: white;
    color: var(--danger);
    border: 2px solid var(--danger);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.1);
}
.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: white;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background: var(--border-light);
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 0.85em;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    transition: all 0.25s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.btn-secondary:hover {
    background: var(--border);
    border-color: var(--border);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.btn-small {
    background: transparent;
    color: var(--primary);
    padding: 6px 14px;
    font-size: 0.8em;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.25s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.btn-small:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.12);
}

.btn-secondary-sm {
    padding: 5px 12px;
    font-size: 0.8em;
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0;
    /* btn-secondary 스타일을 상속받아 동일하게 표시 */
    text-align: center;
    user-select: none;
}

.code-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.sub-option {
    margin-top: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
}

.sub-option code {
    display: inline-block;
    background: var(--text);
    color: #e2e8f0;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    margin-top: 6px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.hidden { display: none !important; }

/* VNC Embedded Panel - 더 예쁘게 */
.vnc-panel {
    grid-column: 1 / -1;
    margin-top: 8px;
}

.vnc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

.vnc-header h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.vnc-controls {
    display: flex;
    gap: 10px;
}

.vnc-guide {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--purple-light) 0%, #f3e8ff 100%);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--purple);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
    line-height: 1.7;
}

.vnc-iframe-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--border);
    background: #1e293b;
    box-shadow: var(--shadow-lg);
}

.vnc-iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* 레이아웃: 1행 = 크롤링설정(좌) | 진행상황(우), 2행 = HIRA 로그인(전체 너비) */
#vnc-panel.hidden { display: none !important; }

main:has(.vnc-panel:not(.hidden)) {
    grid-template-columns: 1fr 1.2fr;
    grid-template-rows: auto auto;
}

main:has(.vnc-panel:not(.hidden)) #settings-panel {
    grid-column: 1;
    grid-row: 1;
}

main:has(.vnc-panel:not(.hidden)) #progress-panel {
    grid-column: 2;
    grid-row: 1;
}

main:has(.vnc-panel:not(.hidden)) #vnc-panel {
    grid-column: 1 / -1;
    grid-row: 2;
}

/* Step indicator on buttons - 더 예쁘게 */
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    font-size: 0.8em;
    font-weight: 800;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.5);
}

/* Status Badge - 더 예쁘게 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 0.85em;
    font-weight: 700;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    letter-spacing: 0.02em;
}

.status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.status-idle {
    background: var(--border-light);
    color: var(--text-muted);
}
.status-idle::before { background: var(--text-muted); }

.status-login_waiting {
    background: linear-gradient(135deg, var(--purple-light) 0%, #f3e8ff 100%);
    color: var(--purple);
}
.status-login_waiting::before {
    background: var(--purple);
    animation: pulse 2s infinite;
}

.status-running {
    background: linear-gradient(135deg, var(--primary-light) 0%, #e0e7ff 100%);
    color: var(--primary);
}
.status-running::before {
    background: var(--primary);
    animation: pulse 1.5s infinite;
}

.status-completed {
    background: linear-gradient(135deg, var(--success-light) 0%, #a7f3d0 100%);
    color: var(--success);
}
.status-completed::before { background: var(--success); }

.status-stopped {
    background: linear-gradient(135deg, var(--warning-light) 0%, #fde68a 100%);
    color: var(--warning);
}
.status-stopped::before { background: var(--warning); }

.status-error {
    background: linear-gradient(135deg, var(--danger-light) 0%, #fecaca 100%);
    color: var(--danger);
}
.status-error::before { background: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Progress Bar - 더 예쁘게 */
.progress-bar-container {
    position: relative;
    width: 100%;
    height: 12px;
    background: var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    position: absolute;
    top: -26px;
    right: 0;
    font-size: 0.9em;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.progress-wrapper {
    position: relative;
    padding-top: 28px;
    margin-bottom: 8px;
}

/* Stats Grid - 더 예쁘게 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-item {
    text-align: center;
    padding: 18px 12px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-light);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-item:hover::before {
    transform: scaleX(1);
}

.stat-label {
    display: block;
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.stat-value {
    display: block;
    font-size: 1.4em;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-value.success { 
    color: var(--success);
    text-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}
.stat-value.danger { 
    color: var(--danger);
    text-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

/* Message Area - 더 예쁘게 */
.message-area {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 24px;
    min-height: 50px;
    display: flex;
    align-items: center;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    line-height: 1.6;
}

/* Files & Logs sections - 더 예쁘게 */
.files-section, .logs-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 2px solid var(--border-light);
}

.files-section h3, .logs-section h3 {
    font-size: 0.95em;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.file-list {
    max-height: 220px;
    overflow-y: auto;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.88em;
    transition: all 0.2s ease;
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { 
    background: var(--primary-light);
    padding-left: 22px;
}

.file-item a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}
.file-item a:hover { 
    text-decoration: underline;
    color: var(--primary-hover);
}

.file-size {
    color: var(--text-muted);
    font-size: 0.85em;
    font-weight: 500;
}

/* Logs details/summary */
.logs-section[open] .logs-summary {
    margin-bottom: 14px;
}

.logs-summary {
    font-size: 0.95em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    letter-spacing: -0.01em;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.logs-summary::-webkit-details-marker { display: none; }

.logs-summary > span:first-child::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    font-size: 0.7em;
    transition: transform 0.2s;
}

.logs-section[open] .logs-summary > span:first-child::before {
    transform: rotate(90deg);
}

.logs-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn-small-danger {
    background: var(--danger) !important;
    color: #fff !important;
    border-color: var(--danger) !important;
}

.btn-small-danger:hover {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.25) !important;
}

/* Logs - 더 예쁘게 */
.log-area {
    max-height: 280px;
    overflow-y: auto;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #cbd5e1;
    padding: 18px;
    border-radius: var(--radius-sm);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8em;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid #334155;
}

/* Footer - 더 예쁘게 */
footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.85em;
    font-weight: 500;
    margin-top: 24px;
}

/* Scrollbar - 더 예쁘게 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb { 
    background: var(--border); 
    border-radius: 4px;
    border: 2px solid var(--border-light);
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--text-muted);
}

/* 추가 애니메이션 효과 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel {
    animation: fadeIn 0.4s ease-out;
}

#settings-panel { animation-delay: 0.1s; }
#progress-panel { animation-delay: 0.2s; }
#vnc-panel { animation-delay: 0.3s; }
