/* 共通CSS変数定義 */
:root {
    --primary-color: #0056b3;
    --secondary-color: #4682B4;
    --accent-color: #CD853F;
    --light-bg: #f8f9fa;
    --text-color: #212529;
    --border-color: #dee2e6;
    --muted-color: #6c757d;
}

/* リセット・基本スタイル */
* {
    box-sizing: border-box;
}

/* ボディ */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.is-show-modal {
    overflow: hidden;
}

/* ヘッダー共通スタイル */
.main-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1000;
}

/* ヘッダー左エリア */
.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* ヘッダーナビゲーション */
.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-nav {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    text-decoration: none;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.35);
    color: white;
    text-decoration: none;
}

.btn-nav--active {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    border-color: transparent;
    font-weight: 600;
}

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

/* システムタイトル */
.system-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

/* ユーザー情報 */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

.user-name {
    font-weight: 500;
}

/* ログアウトボタン */
.logout-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.logout-btn:hover {
    background: #B8860B;
}

/* 不具合報告・改善要望ボタン（ヘッダー用） */
.bug-report-header-btn {
    background: #2457a6;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.bug-report-header-btn:hover {
    background: #1b4382;
}

.bug-report-header-btn--store {
    margin-left: 15px;
    align-self: center;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
}

.bug-report-header-btn--store:hover {
    background: rgba(255, 255, 255, 0.35);
}

@media screen and (max-width: 768px) {
    .main-header {
        flex-wrap: wrap;
        gap: 8px 12px;
        padding: 8px 12px;
    }

    .header-left {
        gap: 10px;
        min-width: 0;
    }

    .header-left .system-title {
        font-size: 16px;
    }

    .header-nav {
        flex-wrap: wrap;
        gap: 6px;
        flex-shrink: 1;
        width: 100%;
        justify-content: flex-start;
    }

    .btn-nav {
        padding: 5px 10px;
        font-size: 12px;
    }

    .user-info {
        flex-wrap: wrap;
        gap: 6px 10px;
        font-size: 12px;
    }

    .logout-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .bug-report-header-btn {
        padding: 5px 8px;
        font-size: 12px;
    }

    .bug-report-header-btn--store {
        padding: 5px 10px;
        font-size: 12px;
        margin-left: 0;
    }
}

/* メインコンテナ */
.main-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* サイドバー共通スタイル */
.sidebar {
    width: 250px;
    background: #f8f9fa;
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: block;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: #e9ecef;
    border-left-color: var(--primary-color);
}

.sidebar-menu a.active {
    background: #E0F0FF;
    border-left-color: var(--secondary-color);
    color: var(--secondary-color);
    font-weight: 600;
}

/* メニュータイトル */
.menu-title {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted-color);
    text-transform: uppercase;
    margin-top: 20px;
}

.menu-title:first-child {
    margin-top: 0;
}

/* コンテンツエリア */
.content {
    flex: 1;
    padding: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ページヘッダー */
.page-header {
    background: linear-gradient(135deg, var(--secondary-color), #87CEEB);
    color: white;
    padding: 20px;
    margin: -20px -20px 20px -20px;
    border-radius: 0 0 8px 8px;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

/* 情報セクション */
.info-section {
    background: #E0F0FF;
    border-left: 4px solid var(--secondary-color);
    padding: 12px 16px;
    margin-bottom: 20px;
}

/* 警告テキスト */
.warning-text {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 10px;
    padding: 8px 12px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 4px;
}
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.no-data-icon {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-data-text {
    font-size: 18px;
    margin-bottom: 10px;
}

.no-data-subtext {
    font-size: 14px;
    opacity: 0.7;
}

.no-data-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted-color);
    font-size: 16px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

/* 検索コンテナ */
.search-container {
    margin-bottom: 5px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-container input[type="text"] {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
    max-width: 300px;
}

.search-container input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(135, 206, 235, 0.2);
}


/* フッター共通スタイル */
.footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 15px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* モーダルダイアログ（共通） */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    overflow-x: hidden;
    overflow-y: auto;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header .close {
    flex-shrink: 0;
    margin-left: 12px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.modal-header .close:hover {
    color: black;
}

.modal-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    text-align: left;
    line-height: 1.4;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ボタン共通スタイル */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-search {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 36px;
}

.btn-search:hover {
    background: #6BB6FF;
}

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

.btn-insert:hover {
    background: #6BB6FF;
}

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

.btn-update:hover {
    background: #3a6b8a;
}

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

.btn-delete:hover {
    background: #FFA500;
}

.btn-back {
    background: #6c757d;
    color: white;
}

.btn-back:hover {
    background: #545b62;
}

.btn-clear {
    background: #6c757d;
    color: white;
}

.btn-clear:hover {
    background: #545b62;
}

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

.btn-print:hover {
    background: #6BB6FF;
}

/* フッターボタン */
.footer-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.footer-buttons .btn {
    min-width: 100px;
}

/* フォーム共通スタイル */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(11, 110, 246, 0.2);
}

/* テーブル共通スタイル */
.table-container {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 300px);
}

.table-wrapper {
    overflow: auto;
    max-height: calc(100vh - 450px); /* フッターの高さを考慮して調整 */
    min-height: 450px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    table-layout: fixed;
}

th {
    background: #f8f9fa;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    font-size: 14px;
    white-space: nowrap;
}

td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    white-space: nowrap;
}

/* 行の状態表示 */
tr:hover {
    background-color: #f8f9fa;
}

tr.selected {
    background-color: #e3f2fd;
}

tr.editing {
    background-color: #fff3cd !important;
    border: 2px solid var(--warning-color) !important;
}

tr.new-row {
    background-color: #d4edda;
    border: 2px solid var(--success-color);
}

/* 入力フィールドの高さ調整 */
input, select {
    height: 32px;
    box-sizing: border-box;
}


/* 編集可能フィールド */
.editable {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 6px;
    border-radius: 4px;
    width: 100%;
    font-size: 14px;
    transition: all 0.2s ease;
}

.editable:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 2px rgba(11, 110, 246, 0.2);
}

.editable.error {
    background: #fff5f5;
    border-color: #dc3545;
}

.readonly {
    background: #f8f9fa;
    color: var(--muted-color);
    font-weight: 500;
}

.select-dropdown {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 6px;
    border-radius: 4px;
    width: 100%;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 2px rgba(11, 110, 246, 0.2);
}

.select-dropdown.error {
    border-color: var(--danger-color);
    background: #fff5f5;
}

/* バリデーションメッセージ */
.validation-message {
    font-size: 12px;
    color: #dc3545;
    margin-top: 4px;
    display: none;
    word-wrap: break-word;
    white-space: initial;
}

.validation-message.show {
    display: block;
}

/* ステータスインジケーター */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

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

.status-editing {
    background: var(--warning-color);
}

.status-new {
    background: var(--primary-color);
}

/* テーブル行の選択状態 */
.selected-row {
    background-color: #e3f2fd;
}

.selected-row td {
    border-color: var(--primary-color);
}

/* 科目CD（読み取り専用） */
.readonly-field {
    background-color: #f8f9fa;
    color: var(--muted-color);
    cursor: not-allowed;
}

/* ユーティリティクラス */
.text-center {
    text-align: center;
}

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

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

.mb-1 {
    margin-bottom: 10px;
}

.mb-2 {
    margin-bottom: 20px;
}

.mb-3 {
    margin-bottom: 30px;
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: 10px;
}

.mt-2 {
    margin-top: 20px;
}

.mt-3 {
    margin-top: 30px;
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

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

.gap-1 {
    gap: 10px;
}

.gap-2 {
    gap: 20px;
}

.w-100 {
    width: 100%;
}

.h-100 {
    height: 100%;
}

/* センター情報表示エリア（その他の画面用） */
.center-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.center-info .center-label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.center-info .center-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

/* レスポンシブ対応 - センター情報表示 */
@media (max-width: 768px) {
    .center-info {
        margin-right: 5px;
        padding: 4px 8px;
    }
    
    .center-info .center-label {
        font-size: 12px;
    }
    
    .center-info .center-name {
        font-size: 12px;
    }
}

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

.is-invalid {
    border-color: #dc3545 !important;
}

.message-invalid {
    color: #dc3545;
    font-size: 12px;
    margin-top: 2px;
    display: block;
    width: 100%;
    float: left;
    white-space: break-spaces;
}

#toast-container>div {
    opacity: 1 !important;
}

button:disabled,
button[disabled] {
    pointer-events: none;
    opacity: 0.8;
    cursor: not-allowed;
}

.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0px;
    flex-wrap: wrap;
}
.pagination-wrapper .info {
    font-size: 14px;
    color: #555;
}

/* Pagination */
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
}
.pagination li {
    margin: 0 3px;
}
.pagination li a,
.pagination li span {
    display: block;
    padding: 5px 12px;
    border-radius: 3px;
    border: 1px solid #ddd;
    color: #0d6efd;
    text-decoration: none;
    transition: all 0.2s;
}
.pagination li a:hover {
    background-color: #e2f0ff;
    border-color: #0d6efd;
}
.pagination li.active span {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}
.pagination li.disabled span {
    color: #ccc;
    cursor: not-allowed;
    border-color: #ddd;
}

/* Responsive */
@media (max-width: 600px) {
    .pagination-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }
    .pagination-wrapper .links {
        margin-top: 10px;
    }
}

table tr td {
    word-break: break-all;
    white-space: initial;
}

#pagination-wrapper .links {
    width: 100%;
    float: left;
}

.number-input-container {
    display: flex;
    align-items: center;
}

.number-input-container button {
    width: 40px;
    height: 32px;
    font-size: 18px;
    border-radius: 0 !important;
    border: 1px solid #cccccc;
    cursor: pointer;
}

.number-input-container button.btn-minus {
    border-top-left-radius: 5px !important;
    border-bottom-left-radius: 5px !important;
}

.number-input-container button.btn-plus {
    border-top-right-radius: 5px !important;
    border-bottom-right-radius: 5px !important;
    margin-left: -22px;
}

.number-input-container input {
    width: 75px;
    text-align: center !important;
    border: 1px solid #ccc;
    border-radius: 0 !important;
}

.number-input-container input:focus {
    box-shadow: none;
    border-color: #cccccc;
}

.number-input-container.invalid .btn-plus {
    border-left-color: #dc3545;
}

.number-input-container.is-disabled button {
    cursor: not-allowed !important;
}