/* Google Fonts のインポート */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --primary-color: #2c3e50;
    /* 濃いネイビー */
    --accent-color: #3498db;
    /* 明るいブルー */
    --success-color: #27ae60;
    /* グリーン */
    --warning-color: #e67e22;
    /* オレンジ */
    --danger-color: #c0392b;
    /* レッド */
    --background-color: #f4f6f7;
    /* 薄いグレー背景 */
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #7f8c8d;
    --border-color: #e0e0e0;
}

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ヘッダー */
header {
    background-color: var(--card-bg);
    padding: 0;
    height: 64px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.header-inner.is-guest {
    justify-content: center;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

header h1 a {
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-name-badge {
    font-size: 0.9em;
    background: #f0f0f0;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 500;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 20px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--accent-color);
}

.logout-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1em;
    padding: 0;
    margin-left: 15px;
    font-family: inherit;
    font-weight: 500;
}

/* コンテンツエリア */
.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* カードスタイル */
.card,
article.case-detail,
.card-form {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 32px;
    margin-bottom: 24px;
}

/* テーブルスタイル */
.table-container {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: #f8f9fa;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    padding: 16px;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* 申請件名（左寄せ）のパディング調整 */
.text-left {
    text-align: left;
    padding-left: 30px !important;
}

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

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

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #fcfcfc;
}

/* リンク */
a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* リンク定義は上記で集約済み */

/* ユーティリティ */
/* .text-left 定義は上記で集約済み */

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

/* ステータスバッジ */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    min-width: 80px;
}

.status-draft {
    background: #ecf0f1;
    color: #7f8c8d;
}

.status-submitted {
    background: #e3f2fd;
    color: #3498db;
}

.status-approved {
    background: #e8f8f5;
    color: #27ae60;
}

.status-remanded {
    background: #fdedec;
    color: #c0392b;
}

/* ボタン */
button {
    font-family: inherit;
    cursor: pointer;
    /* 手のひらマークを基本設定へ */
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 24px;
    background-color: var(--accent-color);
    color: white !important;
    border-radius: 6px;
    font-weight: 500;
    font-size: 1rem;
    min-width: 120px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none !important;
    line-height: 1;
    box-sizing: border-box;
}

.button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 24px;
    background-color: #95a5a6;
    color: white !important;
    border-radius: 6px;
    font-weight: 500;
    font-size: 1rem;
    min-width: 120px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none !important;
    line-height: 1;
    box-sizing: border-box;
}

.button-success {
    background-color: var(--success-color) !important;
}

.button-danger {
    background-color: var(--danger-color) !important;
}

/* AIボタン */
.button-ai {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #6f42c1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* フォーム要素 */
input[type="text"],
textarea,
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

/* 詳細画面 */
.meta {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.95rem;
}

.case-body {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* 履歴タイムライン */
.history ul {
    padding-left: 20px;
}

.history li {
    padding-left: 24px;
    margin-bottom: 24px;
    border-left: 2px solid var(--border-color);
    position: relative;
    list-style: none;
}

.history li::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
}

/* アップロード */
.upload-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
}

.hidden-file-input {
    display: none !important;
}

/* --- レスポンシブ対応 (モバイル向け) --- */
@media screen and (max-width: 768px) {
    header {
        height: auto;
        padding: 15px 0;
    }

    .header-inner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 0 15px;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .user-info {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .user-name-badge {
        font-size: 0.85rem;
        padding: 4px 10px;
    }

    nav {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 20px;
        flex-wrap: wrap;
    }

    nav>form {
        display: contents;
        /* フォームの箱を消して、ボタンを直接 nav の子として扱う */
    }

    nav a,
    .logout-btn {
        margin: 0;
        padding: 0;
        font-size: 0.95rem;
        font-weight: 500;
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        /* 余計な指定を排除して親の align-items: center に任せる */
        display: inline-block;
        line-height: 1.5;
    }

    .logout-btn {
        color: #dc3545;
        font-family: inherit;
    }

    .container {
        margin: 20px auto;
    }

    .card,
    article.case-detail,
    .card-form {
        padding: 20px;
    }

    /* テーブル横スクロール */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th,
    td {
        padding: 12px 8px;
        font-size: 0.9rem;
    }

    /* 詳細画面メタ情報 */
    .meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* ボタン */
    .button,
    .button-secondary,
    .actions form {
        display: flex;
        /* blockからflexに戻して中央揃えを有効化 */
        align-items: center;
        justify-content: center;
        width: 100%;
        margin-left: 0 !important;
        margin-bottom: 12px;
        box-sizing: border-box;
    }

    .actions,
    .attachment-list,
    form>div[style*="display: flex"] {
        flex-direction: column !important;
        width: 100%;
    }

    .attachment-item {
        width: 100% !important;
    }
}