/* Milligram overrides */
:root {
    /* The following are official CakePHP colors */
    --color-cakephp-red: #8bc34a;
    --color-cakephp-gray: #404041;
    --color-cakephp-blue: var(--color-primary);
    --color-cakephp-lightblue: #34bdd7;

    /* Role-based colors */
    --color-admin: #8bc34a;
    --color-organization: #2196f3;
    --color-examinee: #ff9800;

    /* Default role color (admin) */
    --color-primary: var(--color-admin);

    /* These are additional colors */
    --color-lightgray: #606c76;
    --color-white: #fff;

    --color-main-bg: #f5f7fa;
    --color-links: var(--color-primary);
    --color-links-active: color-mix(in srgb, var(--color-primary) 85%, black);
    --color-headings: #363637;

    --color-message-success-bg: #e3fcec;
    --color-message-success-text: #1f9d55;
    --color-message-success-border: #51d88a;

    --color-message-warning-bg: #fffabc;
    --color-message-warning-text: #8d7b00;
    --color-message-warning-border: #d3b800;

    --color-message-error-bg: #fcebea;
    --color-message-error-text: #cc1f1a;
    --color-message-error-border: #ef5753;

    --color-message-info-bg: #eff8ff;
    --color-message-info-text: #2779bd;
    --color-message-info-border: #6cb2eb;
}

/* Role-based color overrides */
.role-admin,
.role-admin *,
.role-admin *::before,
.role-admin *::after {
    --color-primary: var(--color-admin);
}

.role-organization,
.role-organization *,
.role-organization *::before,
.role-organization *::after {
    --color-primary: var(--color-organization);
}

.role-examinee,
.role-examinee *,
.role-examinee *::before,
.role-examinee *::after {
    --color-primary: var(--color-examinee);
}

/* 役割別リンクの色を強制適用（ナビゲーションリンクを除外） */
/* .role-admin a:not(.top-nav-links a):not(.top-nav-title a),
.role-organization a:not(.top-nav-links a):not(.top-nav-title a),
.role-examinee a:not(.top-nav-links a):not(.top-nav-title a) {
    color: var(--color-primary);
} */

.role-admin a:not(.top-nav-links a):not(.top-nav-title a):hover,
.role-admin a:not(.top-nav-links a):not(.top-nav-title a):focus,
.role-admin a:not(.top-nav-links a):not(.top-nav-title a):active,
.role-organization a:not(.top-nav-links a):not(.top-nav-title a):hover,
.role-organization a:not(.top-nav-links a):not(.top-nav-title a):focus,
.role-organization a:not(.top-nav-links a):not(.top-nav-title a):active,
.role-examinee a:not(.top-nav-links a):not(.top-nav-title a):hover,
.role-examinee a:not(.top-nav-links a):not(.top-nav-title a):focus,
.role-examinee a:not(.top-nav-links a):not(.top-nav-title a):active {
    color: color-mix(in srgb, var(--color-primary) 85%, black);
}

/* より強力なCSS変数の継承 */
.role-organization {
    --color-primary: #2196f3;
}

/* .role-organization * {
    --color-primary: #2196f3;
} */

.role-organization *::before,
.role-organization *::after {
    --color-primary: #2196f3;
}

.button,
button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    font-size: 1.4rem;
    font-weight: 700;
}

.button:hover,
button:hover,
input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
    background-color: color-mix(in srgb, var(--color-primary) 85%, black);
    border-color: color-mix(in srgb, var(--color-primary) 85%, black);
    color: white !important;
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: 400;
    background: var(--color-main-bg);
}

.top-nav-links,
.side-nav,
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: "Raleway", sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 400;
    /* color: var(--color-headings); */
}

a {
    /* color: var(--color-links); */
    transition: color 0.2s linear;
}

a:hover,
a:focus,
a:active {
    color: var(--color-links-active);
    transition: color 0.2s ease-out;
}

.side-nav a,
.top-nav-links a,
th a,
.actions a {
    color: var(--color-lightgray);
}

.side-nav a:hover,
.side-nav a:focus,
.actions a:hover,
.actions a:focus {
    color: var(--color-links-active);
}

/* Utility */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Main */
.content {
    padding: 2rem;
    margin-bottom: 2rem;
    background: var(--color-white);
    border-radius: 0.4rem;
    /* Thanks Stripe */
    box-shadow: 0 7px 14px 0 rgba(60, 66, 87, 0.1),
        0 3px 6px 0 rgba(0, 0, 0, 0.07);
}
.content form {
    margin: 0;
}
.actions a {
    font-weight: bold;
    padding: 0 0.4rem;
}
.actions a:first-child {
    padding-left: 0;
}
th {
    white-space: nowrap;
}

/* Nav bar */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 90%;
    padding: 2rem;
    margin: 0 auto;
    background-color: var(--color-primary);
    border-radius: 0.4rem;
    box-shadow: 0 2px 8px 0 rgba(60, 66, 87, 0.08);
    margin-bottom: 2rem;
}
.top-nav-sub {
    background: var(--color-white);
    border-radius: 0.4rem;
    box-shadow: 0 2px 8px 0 rgba(60, 66, 87, 0.08);
    margin-bottom: 2rem;
    padding: 1rem 2rem;
}
.top-nav-sub .top-nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}
.top-nav-sub .top-nav-links a {
    color: var(--color-lightgray);
    font-size: 1.4rem;
    text-decoration: none;
    transition: color 0.2s ease;
}
.top-nav-sub .top-nav-links a:hover {
    color: var(--color-primary);
}
.top-nav-title a {
    font-size: 2.4rem;
    color: #ffffff;
}
.top-nav-title span {
    color: #ffffff;
}
.top-nav-links a {
    margin: 0 0.5rem;
    color: #ffffff;
}
.top-nav-links a:hover {
    color: #f1f8e9;
    text-decoration: underline;
}
.top-nav-title a,
.top-nav-links a {
    font-weight: bold;
}
.side-nav-item {
    display: block;
    padding: 0.5rem 0;
}

/* View action */
.view.content .text {
    /* margin-top: 1.2rem; */
}
.related {
    margin-top: 2rem;
}

/* Flash messages */
.message {
    padding: 0.5rem 1rem;
    background: var(--color-message-info-bg);
    color: var(--color-message-info-text);
    border-color: var(--color-message-info-border);
    border-width: 1px;
    border-style: solid;
    border-radius: 4px;
    margin-bottom: 1rem;
    cursor: pointer;
}
.message.hidden {
    display: none;
}
.message.success {
    background: var(--color-message-success-bg);
    color: var(--color-message-success-text);
    border-color: var(--color-message-success-border);
}
.message.warning {
    background: var(--color-message-warning-bg);
    color: var(--color-message-warning-text);
    border-color: var(--color-message-warning-border);
}
.message.error {
    background: var(--color-message-error-bg);
    color: var(--color-message-error-text);
    border-color: var(--color-message-error-border);
}

/* Forms */
.input.radio,
.input.checkbox,
.input.multicheckbox {
    margin-bottom: 2rem;
}
.input.radio input,
.input.checkbox input,
.input.multicheckbox input {
    margin: 0;
}
.input.radio label,
.input.checkbox label,
.input.multicheckbox label {
    margin: 0;
    display: flex;
    align-items: center;
}
.input.radio label > input,
.input.checkbox label > input,
.input.multicheckbox label > input {
    margin-right: 1rem;
}
/* チェックボックスのスタイリング - デフォルト形状を保ちつつ色を変更 */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-radius: 2px;
    background-color: #fff;
    cursor: pointer;
    position: relative;
    transform: scale(1.2);
    margin-right: 0.5rem;
}

input[type="checkbox"]:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* デフォルトのチェックマーク形状を再現 */
input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* カスタムチェックボックス（より詳細な制御が必要な場合） */
.custom-checkbox {
    position: relative;
    display: inline-block;
}

.custom-checkbox input[type="checkbox"] {
    opacity: 0;
    position: absolute;
    cursor: pointer;
}

.custom-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #fff;
    border: 2px solid var(--color-primary);
    border-radius: 3px;
}

.custom-checkbox:hover .checkmark {
    background-color: #f0f8ff;
}

.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--color-primary);
}

.custom-checkbox .checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="color"] {
    max-width: 4rem;
    padding: 0.3rem 0.5rem 0.3rem;
}

/* Paginator */
.paginator {
    text-align: right;
}
.paginator p {
    margin-bottom: 0;
}
.pagination {
    display: flex;
    justify-content: center;
    list-style: none;
    margin: 0 0 1rem 0;
    padding: 0;
}
.pagination li {
    display: inline-block;
    margin: 0.25em;
    text-align: center;
}
.pagination a {
    color: var(--color-primary);
    display: inline-block;
    font-size: 1.25rem;
    line-height: 3rem;
    min-width: 3rem;
    padding: 0;
    position: relative;
    text-decoration: none;
    transition: background 0.3s, color 0.3s;
}
.pagination li.active a,
.pagination a:hover {
    text-decoration: underline;
}
.pagination .disabled a {
    cursor: not-allowed;
    color: var(--color-lightgray);
    text-decoration: none;
}
.first a,
.prev a,
.next a,
.last a {
    padding: 0 0.75rem;
}
.disabled a:hover {
    background: initial;
    color: initial;
}
.asc:after {
    content: " \2193";
}
.desc:after {
    content: " \2191";
}

/* Error in non debug mode */
.error-container {
    align-items: center;
    display: flex;
    flex-direction: column;
    height: 100vh;
    justify-content: center;
}

@media screen and (max-width: 640px) {
    /* Fix milligram not having a responsive column system */
    .row .column[class*="column-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .top-nav {
        margin: 0 auto;
    }
    .side-nav {
        margin-bottom: 1rem;
    }
    .heading {
        margin-bottom: 1rem;
    }
    .side-nav-item {
        display: inline;
        margin: 0 1.5rem 0 0;
    }
    .asc:after {
        content: " \2192";
    }
    .desc:after {
        content: " \2190";
    }

    .actions {
        white-space: nowrap;
        min-width: 120px;
    }

    .btn-group {
        display: flex;
        gap: 5px;
    }
}

.actions {
    white-space: nowrap;
    min-width: 120px;
}

.btn-group {
    display: flex;
    gap: 5px;
}

.nowrap {
    white-space: nowrap;
}

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

.details-section {
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.details-section h4 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 1.2em;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

/* System info styles */
.system-info {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 12px;
    box-shadow: none;
}

.system-details {
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

.system-details p {
    margin: 0;
}

.system-details strong {
    color: #888;
    font-weight: 500;
}

.separator {
    margin: 0 10px;
    color: #ccc;
}

/* テーブルのスタイル */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.data-table th {
    background: color-mix(in srgb, var(--color-primary) 10%, white);
    padding: 8px 12px;
    font-weight: 600;
    border: 1px solid color-mix(in srgb, var(--color-primary) 20%, white);
    font-size: 0.9em;
    line-height: 1.2;
    color: #333333;
}

.data-table td {
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    color: #333;
    font-size: 0.9em;
    line-height: 1.2;
}

/* 行の交互の色 - 元の色を維持 */
.data-table tr:nth-child(even) {
    background-color: #fafafa;
}

/* ホバー時の色を変更 */
.data-table tr:hover {
    background: color-mix(in srgb, var(--color-primary) 10%, white);
    transition: background-color 0.2s ease;
}

/* ステータスラベルのスタイル */
.status-pending {
    color: #f0ad4e;
}
.status-disapproved {
    color: #d9534f;
}

.status-start {
    color: #007bff;
}
.status-user-creating {
    color: #007bff;
}
.status-approved {
    color: #5cb85c;
}
.status-end {
    color: #5cb85c;
}

.status-unknown {
    color: #d9534f;
}

/* 右寄せテキスト */
.text-right {
    text-align: right;
}

/* アクションリンク */
.view-link {
    display: inline-block;
    padding: 4px 12px;
    background: #007bff;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.view-link:hover {
    background: #0056b3;
    color: white;
}

/* レスポンシブ対応 */
.table-responsive {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
}

/* nowrapクラス */
.nowrap {
    white-space: nowrap;
}

/* アクションリンクのスタイル改善 */
.data-table td.actions {
    padding: 0; /* パディングを削除 */
    text-align: center;
    white-space: nowrap;
}

.data-table td.actions .action-links {
    display: flex; /* フレックスボックスで横並びに */
}

.data-table td.actions a {
    flex: 1; /* 均等に幅を分配 */
    padding: 6px 12px;
    /* color: var(--color-links); */
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.data-table td.actions a:hover {
    background-color: var(--color-primary);
    color: white !important;
}

/* 複数のアクションがある場合の区切り線（縦線） */
.data-table td.actions a + a {
    border-left: 1px solid #dee2e6; /* 左側に区切り線を追加 */
}
.data-table td.actions .action-links > form {
    flex: 1;
}

.data-table td.actions .post-link {
    display: block;
    width: 100%;
    padding: 6px 12px;
    color: var(--color-links);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
}

.data-table td.actions .post-link:hover {
    background-color: var(--color-links);
    color: white;
}

.data-table td.actions a + form,
.data-table td.actions form + a {
    border-left: 1px solid #dee2e6;
}

/* コンパクトな検索ボックス */
.search-box {
    background: #f8f9fa;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    align-items: end;
}

.search-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.search-item {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.search-item div {
    margin-bottom: 0;
}

.compact-label {
    font-size: 0.85em;
    margin-bottom: 2px;
    color: #666;
}

.compact-input {
    padding: 4px 8px;
    height: 3.8rem;
    font-size: 0.9em;
    border: 1px solid #ddd;
    border-radius: 3px;
    width: 100%;
    margin-bottom: 0;
}

.button-group {
    display: flex;
    gap: 4px;
    /* justify-content: flex-end; */
}

.compact-button {
    font-size: 0.9em;
    min-width: 60px;
    margin: 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .search-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .button-group {
        margin-top: 4px;
    }
}

/* フォームグループのマージンを削除 */
.form-group {
    margin-bottom: 0;
}

.error-message {
    color: #dc3545;
    font-size: 0.9em;
    margin: 5px 0 15px 0;
}

.button.secondary {
    background: #6c757d;
    color: white;
}

#submit-button:disabled {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
    cursor: not-allowed !important;
    opacity: 0.65 !important;
}
#approve-exam-button:disabled {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
    cursor: not-allowed !important;
    opacity: 0.65 !important;
}
