/* ===== 基本設定 ===== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #059669;
    --success-hover: #047857;
    --info-color: #0891b2;
    --info-hover: #0e7490;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --secondary-color: #6b7280;
    --border-color: #d1d5db;
    --background-color: #f9fafb;
    --card-background: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    min-height: 100vh;
}

/* ===== レイアウト ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    text-align: center;
    padding: 2rem 0;
    background: linear-gradient(135deg, var(--primary-color), var(--info-color));
    color: white;
    margin-bottom: 2rem;
    border-radius: var(--border-radius);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    backdrop-filter: blur(10px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success-color);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    transition: var(--transition);
}

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

.card h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* ===== フォーム要素 ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== ボタン ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    min-width: 120px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-success:hover:not(:disabled) {
    background-color: var(--success-hover);
}

.btn-info {
    background-color: var(--info-color);
    color: white;
}

.btn-info:hover:not(:disabled) {
    background-color: var(--info-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ===== エンティティタイプ選択 ===== */
.entity-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: normal;
}

.checkbox-label:hover {
    background-color: var(--background-color);
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

/* ===== シナリオ選択 ===== */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.scenario-card {
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.scenario-card:hover {
    border-color: var(--primary-color);
    background-color: var(--background-color);
    transform: translateY(-2px);
}

.scenario-card.selected {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
}

.scenario-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

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

/* ===== 結果表示 ===== */
.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
}

.summary-item {
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.summary-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.highlighted-text-container,
.entities-container {
    margin-bottom: 1.5rem;
}

.highlighted-text-container h3,
.entities-container h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.highlighted-text {
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    line-height: 1.8;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
}

/* ===== エンティティハイライト ===== */
.entity-highlight {
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    position: relative;
    cursor: help;
}

.entity-highlight.PERSON {
    background-color: rgba(59, 130, 246, 0.2);
    color: rgb(29, 78, 216);
}

.entity-highlight.EMAIL {
    background-color: rgba(16, 185, 129, 0.2);
    color: rgb(5, 150, 105);
}

.entity-highlight.PHONE {
    background-color: rgba(245, 158, 11, 0.2);
    color: rgb(217, 119, 6);
}

.entity-highlight.LOCATION {
    background-color: rgba(236, 72, 153, 0.2);
    color: rgb(190, 24, 93);
}

.entity-highlight.ORGANIZATION {
    background-color: rgba(139, 69, 19, 0.2);
    color: rgb(120, 53, 15);
}

.entity-highlight.CREDIT_CARD {
    background-color: rgba(220, 38, 38, 0.2);
    color: rgb(185, 28, 28);
}

.entity-highlight.DATE {
    background-color: rgba(147, 51, 234, 0.2);
    color: rgb(124, 58, 237);
}

.entities-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.entity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.entity-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
}

.entity-text {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.entity-type {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

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

.confidence-bar {
    width: 60px;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-left: 0.5rem;
}

.confidence-fill {
    height: 100%;
    background-color: var(--success-color);
    transition: width 0.3s ease;
}

/* ===== タブ ===== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.management-results {
    padding: 1rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    min-height: 200px;
}

/* ===== ローディング ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== トーストメッセージ ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1001;
    max-width: 300px;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background-color: var(--success-color);
}

.toast.error {
    background-color: var(--danger-color);
}

.toast.info {
    background-color: var(--info-color);
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .button-group,
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .scenario-grid {
        grid-template-columns: 1fr;
    }
    
    .results-summary {
        grid-template-columns: 1fr;
    }
    
    .entity-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1rem;
        margin: 0 -0.5rem 1rem;
        border-radius: 0;
    }
    
    .card {
        padding: 1rem;
        margin: 0 -0.5rem;
        border-radius: 0;
    }
}

/* ===== ユーティリティ ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mt-1 {
    margin-top: 0.5rem !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 簡素化されたUI機能 ===== */

/* ロゴナビゲーション */
#logoNavigation {
    cursor: pointer;
    transition: transform 0.2s ease;
}

#logoNavigation:hover {
    transform: scale(1.05);
}

#logoNavigation:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ホバー選択ツールチップ */
.selection-tooltip {
    position: absolute;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    z-index: 1000;
    min-width: 200px;
}

.tooltip-header {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.type-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.type-option {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.type-option:hover {
    background: var(--primary-color);
    color: white;
}

/* エンティティ表示の改善 */
.entity-display {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(37, 99, 235, 0.2);
}

/* ローディング状態 */
.btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}