/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    min-height: 100vh;
}

/* ===== Input Page ===== */
.input-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.input-page .header {
    text-align: center;
    margin-bottom: 3rem;
}

.input-page h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.input-page .subtitle {
    color: var(--gray-500);
    font-size: 1.1rem;
}

.test-form {
    width: 100%;
    max-width: 600px;
}

.main-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.main-input input {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.main-input input:focus {
    border-color: var(--primary);
}

.main-input button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.main-input button:hover {
    background: var(--primary-dark);
}

.main-input button:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

.hint {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.advanced-toggle {
    text-align: center;
    margin-bottom: 1rem;
}

.advanced-toggle button {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 auto;
}

.advanced-toggle button:hover {
    color: var(--gray-700);
}

.toggle-icon {
    font-weight: bold;
    font-size: 1.2rem;
}

.advanced-options {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.option-group {
    margin-bottom: 1.5rem;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.input-row {
    display: flex;
    gap: 0.75rem;
}

.input-row input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
}

.input-row input:focus {
    border-color: var(--primary);
}

.input-with-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-with-label span {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.input-with-label input {
    width: 100%;
}

textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

textarea:focus {
    border-color: var(--primary);
}

.error-message {
    margin-top: 1rem;
    padding: 1rem;
    background: #fef2f2;
    color: var(--error);
    border-radius: 8px;
    text-align: center;
}

/* ===== Test Page ===== */
.test-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.test-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.back-btn {
    font-size: 1.5rem;
    color: var(--gray-500);
    text-decoration: none;
    padding: 0.5rem;
}

.back-btn:hover {
    color: var(--gray-700);
}

.header-info {
    flex: 1;
}

.header-info h1 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--gray-100);
    color: var(--gray-600);
    margin-left: 0.5rem;
}

.status-badge.pending { background: var(--gray-100); color: var(--gray-600); }
.status-badge.initializing { background: #e0e7ff; color: #4338ca; }
.status-badge.crawling { background: #dbeafe; color: #1d4ed8; }
.status-badge.analyzing { background: #fef3c7; color: #b45309; }
.status-badge.generating { background: #fce7f3; color: #be185d; }
.status-badge.executing { background: #d1fae5; color: #047857; }
.status-badge.completed { background: #d1fae5; color: #047857; }
.status-badge.failed { background: #fee2e2; color: #b91c1c; }
.status-badge.stopped { background: #fef3c7; color: #b45309; }

.stop-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--error);
    background: white;
    border: 1px solid var(--error);
    border-radius: 8px;
    cursor: pointer;
}

.stop-btn:hover {
    background: #fef2f2;
}

.test-content {
    flex: 1;
    display: flex;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
}

.screenshot-panel {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

.current-url {
    color: var(--gray-500);
    font-size: 0.85rem;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.screenshot-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    overflow: hidden;
}

.screenshot-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: none;
}

.screenshot-placeholder {
    text-align: center;
    color: var(--gray-400);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.current-action {
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    font-size: 0.9rem;
    color: var(--gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-panel {
    width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-section {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.progress-text {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: right;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.summary-card {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.card-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.summary-card.passed .card-value { color: var(--success); }
.summary-card.failed .card-value { color: var(--error); }

.log-section {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
    font-weight: 500;
}

.auto-scroll-toggle {
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.log-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.85rem;
}

.log-entry {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.log-entry:hover {
    background: var(--gray-50);
}

.log-time {
    color: var(--gray-400);
    font-size: 0.8rem;
}

.log-icon {
    width: 1em;
}

.log-entry.success .log-icon { color: var(--success); }
.log-entry.warning .log-icon { color: var(--warning); }
.log-entry.error .log-icon { color: var(--error); }
.log-entry.info .log-icon { color: var(--primary); }

.log-message {
    flex: 1;
    color: var(--gray-700);
}

/* ===== Report Page ===== */
.report-page {
    min-height: 100vh;
    padding-bottom: 2rem;
}

.report-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
}

.report-header .header-info {
    flex: 1;
}

.report-header h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.target-url {
    font-size: 0.9rem;
    color: var(--gray-500);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-primary, .btn-secondary {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.report-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.summary-section {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: stretch;
}

.grade-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.grade {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
}

.grade-A { color: var(--success); }
.grade-B { color: #84cc16; }
.grade-C { color: var(--warning); }
.grade-D { color: #f97316; }
.grade-F { color: var(--error); }

.grade-label {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

.stats-cards {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.stat-card.passed .stat-value { color: var(--success); }
.stat-card.failed .stat-value { color: var(--error); }
.stat-card.errors .stat-value { color: var(--warning); }

.coverage-bar {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.coverage-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    white-space: nowrap;
}

.coverage-track {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.coverage-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.coverage-value {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 40px;
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-600);
}

.tab.active {
    background: var(--gray-800);
    color: white;
    border-color: var(--gray-800);
}

.results-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.result-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
}

.result-item:last-child {
    border-bottom: none;
}

.result-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.result-icon {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

.result-item.passed .result-icon { color: var(--success); }
.result-item.failed .result-icon { color: var(--error); }
.result-item.error .result-icon { color: var(--warning); }

.result-info {
    flex: 1;
}

.result-info h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.result-type {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    background: var(--gray-100);
    border-radius: 4px;
    margin-right: 0.5rem;
}

.result-url {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.result-duration {
    font-size: 0.85rem;
    color: var(--gray-400);
}

.result-error {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #fef2f2;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--error);
}

.result-steps {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    background: white;
    border-radius: 4px;
}

.step.passed { border-left: 2px solid var(--success); }
.step.failed { border-left: 2px solid var(--error); }
.step.error { border-left: 2px solid var(--warning); }

.step-num {
    color: var(--gray-400);
    font-size: 0.75rem;
}

.step-action {
    font-weight: 500;
}

.step-target {
    color: var(--gray-500);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--gray-500);
}

.discovery-section, .logs-section {
    margin-bottom: 1.5rem;
}

.discovery-section h2, .logs-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.discovery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.discovery-card {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.discovery-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
}

.discovery-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.discovery-list li {
    padding: 0.25rem 0;
    font-size: 0.85rem;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
}

.discovery-list li a {
    color: var(--primary);
    text-decoration: none;
}

.discovery-list li a:hover {
    text-decoration: underline;
}

.discovery-list .more {
    color: var(--gray-400);
    font-style: italic;
}

.api-method {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--gray-100);
    border-radius: 3px;
    margin-right: 0.5rem;
}

.logs-container {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.85rem;
}

/* ===== Issues Section ===== */
.issues-section {
    margin-top: 2rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1.5rem;
}

.issues-section h2 {
    color: var(--error);
    margin-bottom: 1rem;
}

.issues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.issue-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--error);
}

.issue-card h3 {
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.issue-list {
    list-style: none;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

.issue-list li {
    padding: 0.5rem;
    border-bottom: 1px solid var(--gray-100);
    word-break: break-all;
}

.issue-list li:last-child {
    border-bottom: none;
}

.issue-type {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--warning);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.25rem;
}

.issue-method {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--error);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.25rem;
}

.issue-list small {
    color: var(--gray-500);
}

/* ===== Connection Error ===== */
.connection-error {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--error);
    color: white;
    padding: 0.75rem 1rem;
    text-align: center;
    font-weight: 500;
    z-index: 9999;
    display: none;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ===== Print Styles ===== */
@media print {
    .back-btn, .stop-btn, .header-actions, .filter-tabs { display: none !important; }
    .report-page { padding: 0; }
    .report-content { max-width: 100%; }
    .connection-error { display: none !important; }
}
