/* ===== リセット・基本スタイル ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: '"メイリオ", "Hiragino Sans", "ヒラギノ角ゴ Pro", "Yu Gothic", "游ゴシック", sans-serif';
    line-height: 1.6;
    color: #222;
    background-color: #f8f8f8;
    min-height: 100vh;
    padding: 20px;
    font-size: 16px;
}

/* ===== コンテナ ===== */
.container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: white;
}

/* ===== ヘッダー ===== */
header {
    background-color: #fff;
    color: #222;
    padding: 30px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header .subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.admin-link {
    display: inline-block;
    padding: 8px 16px;
    background-color: #f0f0f0;
    color: #0066cc;
    text-decoration: none;
    border-radius: 2px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.admin-link:hover {
    background-color: #e8e8e8;
}

/* ===== メインコンテンツ ===== */
main {
    padding: 40px 30px;
}

section {
    margin-bottom: 40px;
}

h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #222;
    font-weight: 700;
    padding-bottom: 10px;
    border-bottom: 2px solid #0066cc;
}

h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 15px;
    font-weight: 600;
}

/* ===== フォーム ===== */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

input[type="text"] {
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 14px;
    transition: border-color 0.2s;
    width: 100%;
    font-family: inherit;
}

input[type="text"]:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.url-input-wrapper {
    display: flex;
    gap: 10px;
}

.url-input-wrapper input {
    flex: 1;
}

/* ===== ボタン ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background-color: #0066cc;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #0052a3;
}

.btn-primary:active:not(:disabled) {
    background-color: #003d7a;
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #f0f0f0;
    color: #222;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e8e8e8;
}

/* ===== URL リスト ===== */
.url-list {
    margin: 30px 0;
    padding: 20px;
    background-color: #f5f5f5;
    border-radius: 0;
    border: 1px solid #ddd;
}

.url-list ul {
    list-style: none;
}

.url-list li {
    padding: 12px 15px;
    background-color: white;
    border-left: 3px solid #0066cc;
    margin-bottom: 8px;
    border-radius: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #ddd;
    border-left: 3px solid #0066cc;
}

.url-list li span {
    color: #999;
    font-size: 13px;
}

.url-list .remove-btn {
    background-color: #c41e3a;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.url-list .remove-btn:hover {
    background: #ee5a52;
}

/* ===== アクションボタン ===== */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.action-buttons button {
    flex: 1;
}

/* ===== ローディング ===== */
.loading {
    text-align: center;
    padding: 40px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* プログレスバー */
.progress-container {
    margin-top: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background-color: #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0066cc 0%, #0088ff 100%);
    border-radius: 12px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
    font-weight: 600;
}

/* ===== アラート ===== */
.alert {
    padding: 15px 20px;
    border-radius: 2px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-left: 4px solid #0066cc;
}

.alert-error {
    background: #fff5f5;
    border-left-color: #c41e3a;
    color: #c41e3a;
}

.alert-success {
    background: #f0fff4;
    border-left-color: #22c55e;
    color: #155e3a;
}

.alert.hidden {
    display: none;
}

/* ===== 結果セクション ===== */
.result-section {
    margin-top: 40px;
}

.result-section.hidden {
    display: none;
}

.result-summary {
    background: #f0f7ff;
    border-left: 4px solid #0066cc;
    padding: 20px;
    border-radius: 2px;
    margin-bottom: 30px;
    border: 1px solid #ddd;
}

.result-summary p {
    margin-bottom: 15px;
    font-size: 16px;
    color: #222;
}

.result-summary strong {
    color: #0066cc;
    font-weight: 700;
}

.export-buttons {
    display: flex;
    gap: 10px;
}

/* ===== 結果テーブル ===== */
.results-container {
    max-height: 800px;
    overflow-y: auto;
}

.result-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 2px;
    margin-bottom: 20px;
    overflow: hidden;
}

.result-header {
    background: #f5f5f5;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.result-header h3 {
    margin: 0;
    color: #222;
    font-size: 16px;
    font-weight: 600;
}

.result-header .url {
    color: #0066cc;
    font-size: 13px;
    word-break: break-all;
}

.score-badge {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
}

.score-badge .score-value {
    font-size: 20px;
}

.score-badge .score-label {
    font-size: 12px;
}

.score-badge .score-level-text {
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.9;
}

.score-excellent {
    background: #e8f5e9;
    color: #2e7d32;
}

.score-good {
    background: #e3f2fd;
    color: #1976d2;
}

.score-fair {
    background: #fff3e0;
    color: #f57c00;
}

.score-poor {
    background: #ffebee;
    color: #c62828;
}

.score-critical {
    background: #ffcdd2;
    color: #b71c1c;
    font-weight: 700;
}

.result-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 600;
}

.result-status.success {
    background: #d9e8f3;
    color: #0066cc;
}

.result-status.error {
    background: #fff5f5;
    color: #c41e3a;
}

.result-content {
    padding: 20px;
}

.error-list {
    list-style: none;
}

.error-item {
    padding: 15px;
    background: #fff;
    border-left: 4px solid #c41e3a;
    margin-bottom: 15px;
    border-radius: 0;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.error-item strong {
    color: #222;
    font-weight: 600;
}

.error-comparison {
    display: flex;
    align-items: stretch;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.error-field {
    padding: 12px;
    border-radius: 3px;
    font-size: 14px;
    flex-grow: 1;
    min-width: 180px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.error-field.incorrect {
    background-color: #fff5f5;
    border-color: #c41e3a;
    border-left: 3px solid #c41e3a;
}

.error-field.correct {
    background-color: #f0fff4;
    border-color: #22c55e;
    border-left: 3px solid #22c55e;
}

.error-field label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin: 0;
    padding: 0;
    display: block;
}

.error-field.incorrect label {
    color: #c41e3a;
}

.error-field.correct label {
    color: #155e3a;
}

.error-field strong {
    display: block;
    word-break: break-all;
    font-size: 15px;
    color: #222;
}

.error-arrow {
    font-size: 20px;
    color: #666;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.error-context {
    background: #f8f8f8;
    padding: 10px 12px;
    border-left: 3px solid #c41e3a;
    margin: 12px 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
    border-radius: 0 4px 4px 0;
}

.error-context strong {
    color: #c41e3a;
    font-weight: 700;
    background-color: #ffe5e5;
    padding: 2px 4px;
    border-radius: 2px;
}

.error-score {
    display: inline-block;
    background: #fff3e0;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 13px;
    color: #f57c00;
    font-weight: 700;
    border: 1px solid #ffe0b2;
}

.confidence {
    display: inline-block;
    background: #e3f2fd;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    color: #1976d2;
    font-weight: 600;
    border: 1px solid #bbdefb;
}

.error-position {
    color: #0066cc;
    font-size: 13px;
    font-weight: 600;
    background-color: #f0f7ff;
    padding: 8px 12px;
    border-radius: 3px;
    border-left: 2px solid #0066cc;
    display: inline-block;
}

.error-suggestion {
    color: #666;
    font-size: 13px;
    margin-top: 5px;
}

.error-reason {
    color: #888;
    margin-top: 8px;
    font-size: 13px;
    padding: 8px 10px;
    background: #f5f5f5;
    border-left: 2px solid #999;
    border-radius: 2px;
}

.error-reason::before {
    content: "💡 ";
}

.no-errors {
    text-align: center;
    padding: 20px;
    color: #155e3a;
    background: #f0fff4;
    border-radius: 2px;
    border: 1px solid #ddd;
}

/* ===== HTML文脈表示（Diff形式） ===== */
.html-context-container {
    margin: 12px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    overflow: hidden;
}

.context-header {
    padding: 10px 15px;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.context-header:hover {
    background: #e8e8e8;
}

.toggle-icon {
    font-size: 10px;
    margin-left: 8px;
    transition: transform 0.2s;
}

.context-occurrences {
    max-height: 600px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.context-occurrences.collapsed {
    max-height: 0;
    overflow: hidden;
}

.occurrence {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

.occurrence:first-child {
    border-top: none;
}

.occurrence-title {
    font-size: 12px;
    font-weight: 600;
    color: #0066cc;
    margin-bottom: 10px;
    padding: 4px 8px;
    background: #e3f2fd;
    border-radius: 3px;
    display: inline-block;
}

.code-block {
    background: #2b2b2b;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.5;
}

.code-line {
    display: flex;
    padding: 2px 0;
    color: #f8f8f2;
}

.code-line.error-line {
    background: rgba(255, 82, 82, 0.15);
    border-left: 3px solid #ff5252;
}

.line-number {
    display: inline-block;
    width: 50px;
    padding: 0 10px;
    text-align: right;
    color: #6d6d6d;
    background: #1e1e1e;
    user-select: none;
    flex-shrink: 0;
}

.code-line.error-line .line-number {
    background: rgba(255, 82, 82, 0.2);
    color: #ff8a80;
    font-weight: bold;
}

.line-content {
    padding: 0 15px;
    flex: 1;
    white-space: pre-wrap;
    word-break: break-all;
}

.error-highlight {
    background: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: bold;
}

/* ===== フッター ===== */
footer {
    background: white;
    padding: 20px 30px;
    text-align: center;
    color: #999;
    font-size: 13px;
    border-top: 1px solid #ddd;
    margin-top: 40px;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .container {
        border-radius: 2px;
        margin: 0;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 28px;
    }

    main {
        padding: 20px;
    }

    .url-input-wrapper {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
    }

    .export-buttons {
        flex-direction: column;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-header .url {
        margin-top: 10px;
    }
}

/* ===== Basic認証ダイアログ ===== */
.auth-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-dialog-overlay.hidden {
    display: none;
}

.auth-dialog {
    background: white;
    border-radius: 2px;
    padding: 30px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
}

.auth-dialog h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #222;
    font-weight: 700;
}

.auth-dialog .auth-url {
    background-color: #f5f5f5;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
    word-break: break-all;
    font-family: monospace;
}

.auth-form {
    margin-bottom: 20px;
}

.auth-form .form-group {
    margin-bottom: 15px;
}

.auth-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
    color: #222;
}

.auth-form input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.auth-buttons .btn {
    flex: 1;
    padding: 12px 18px;
    border: none;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.auth-buttons .btn-primary {
    background-color: #0066cc;
    color: white;
}

.auth-buttons .btn-primary:hover {
    background-color: #0052a3;
}

.auth-buttons .btn-primary:active {
    background-color: #003d7a;
}

.auth-buttons .btn-secondary {
    background-color: #f0f0f0;
    color: #222;
    border: 1px solid #ddd;
}

.auth-buttons .btn-secondary:hover {
    background-color: #e8e8e8;
}
