/**
 * Sunflower Accessibility Enhancement CSS
 * アクセシビリティ向上のための追加スタイル
 */

/* ===============================
   キーボードナビゲーション強化
   =============================== */

/* フォーカス表示の改善 */
*:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* インタラクティブ要素のフォーカス強化 */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 
        0 0 0 3px rgba(44, 82, 130, 0.3),
        var(--shadow-md);
}

/* 危険なアクション（削除ボタンなど）のフォーカス */
.btn-danger:focus,
.btn-delete:focus {
    outline-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.3);
}

/* スキップリンク */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 9999;
    font-weight: 600;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 6px;
    outline: 2px solid white;
}

/* ===============================
   視覚的表示の改善
   =============================== */

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;
        --text-primary: #000000;
        --text-secondary: #000000;
        --border-color: #000000;
        --bg-primary: #ffffff;
        --bg-secondary: #f5f5f5;
    }
    
    .btn-primary {
        background-color: #000080;
        border-color: #000000;
        color: #ffffff;
    }
    
    .btn-secondary {
        background-color: #606060;
        border-color: #000000;
        color: #ffffff;
    }
    
    .card {
        border: 2px solid #000000;
    }
    
    .form-control {
        border: 2px solid #000000;
    }
}

/* 色に依存しない情報伝達 */
.status-success::before {
    content: "✓ ";
    color: var(--success-color);
    font-weight: bold;
}

.status-error::before {
    content: "✗ ";
    color: var(--danger-color);
    font-weight: bold;
}

.status-warning::before {
    content: "⚠ ";
    color: var(--warning-color);
    font-weight: bold;
}

.status-info::before {
    content: "ℹ ";
    color: var(--primary-color);
    font-weight: bold;
}

/* ===============================
   動きの制御（アニメーション配慮）
   =============================== */

/* アニメーション無効設定のユーザー向け */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .fade-in,
    .slide-in {
        animation: none;
    }
    
    /* ホバー効果も軽減 */
    .menu-card:hover {
        transform: none;
    }
}

/* ===============================
   スクリーンリーダー対応
   =============================== */

/* スクリーンリーダー専用テキスト */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: initial !important;
    margin: initial !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* アイコンボタンの改善 */
.icon-button {
    position: relative;
}

.icon-button[aria-label]::before {
    content: attr(aria-label);
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.icon-button:hover::before,
.icon-button:focus::before {
    opacity: 1;
}

/* ===============================
   フォームのアクセシビリティ向上
   =============================== */

/* 必須フィールドの視覚的表示 */
.form-required::after {
    content: " *";
    color: var(--danger-color);
    font-weight: bold;
}

/* エラー状態のフィールド */
.form-control.is-invalid {
    border-color: var(--danger-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid {
    border-color: var(--success-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.13-.03.11-.04.09-.06.07-.08.03-.09v-.7l-.06-.09-.08-.07-.09-.04-.11-.02-.11.02-.09.04-.08.07-.06.09v.7l.03.09.07.08.09.06.11.04.13.03zm4.29-5.22.5.52-.78.78-.46-.43-.15-.14-.71.71-.15.14-.31-.31.31-.31.71-.71.31-.31.31.31.71.71.15-.14.46-.43.78-.78.5-.52z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* エラーメッセージのスタイル */
.form-error {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--danger-color);
}

.form-error::before {
    content: "⚠ ";
    font-weight: bold;
}

/* フィールドセットの改善 */
fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

legend {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.1em;
}

/* ===============================
   ナビゲーションの改善
   =============================== */

/* パンくずリスト */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    list-style: none;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    color: var(--text-muted);
    margin: 0 0.5rem;
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ページ内ナビゲーション */
.page-nav {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 2rem;
}

.page-nav h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.page-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.page-nav li {
    margin-bottom: 0.5rem;
}

.page-nav a {
    color: var(--primary-color);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: block;
    transition: all var(--transition-fast);
}

.page-nav a:hover,
.page-nav a:focus {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

/* ===============================
   テーブルのアクセシビリティ
   =============================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    background-color: transparent;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    vertical-align: top;
    border-top: 1px solid var(--border-color);
    text-align: left;
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid var(--border-color);
    background-color: var(--bg-secondary);
    font-weight: 600;
}

.table tbody + tbody {
    border-top: 2px solid var(--border-color);
}

/* テーブルキャプション */
.table caption {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    color: var(--text-muted);
    text-align: left;
    caption-side: top;
    font-weight: 600;
    font-size: 1.1em;
}

/* ソート可能なテーブルヘッダー */
.table th[role="columnheader"] {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table th[role="columnheader"]:hover {
    background-color: var(--bg-muted);
}

.table th[aria-sort="ascending"]::after {
    content: " ↑";
    color: var(--primary-color);
    font-weight: bold;
}

.table th[aria-sort="descending"]::after {
    content: " ↓";
    color: var(--primary-color);
    font-weight: bold;
}

/* ===============================
   モーダル・ダイアログの改善
   =============================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    position: relative;
    width: 90%;
    max-width: 500px;
    margin: 1.75rem auto;
}

.modal-content {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    outline: 0;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.modal-close:hover,
.modal-close:focus {
    background-color: var(--bg-muted);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ===============================
   進捗インジケーター
   =============================== */

.progress {
    height: 1rem;
    background-color: var(--bg-muted);
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    position: relative;
}

.progress-bar[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.progress:hover .progress-bar::after {
    opacity: 1;
}

/* ===============================
   印刷スタイル
   =============================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    .navbar,
    .modal,
    .skip-link {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    .btn {
        border: 1px solid #000;
        background: white;
        color: black;
    }
}

/* ===============================
   レスポンシブテキスト
   =============================== */

@media (max-width: 576px) {
    .responsive-text-sm {
        font-size: 0.875rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
        width: calc(100% - 1rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}