/* (★) admin_contacts.php / admin_approval.php / admin_home.php 共通CSS */
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; background-color: #f4f7f6; margin: 0; padding: 0; color: #333; }
.header { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; background-color: #ffffff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.header h1 { margin: 0; font-size: 1.3em; flex: 1; }
.header-nav { display: flex; align-items: center; gap: 20px; }
.header-nav a { color: #007bff; text-decoration: none; font-weight: 600; font-size: 0.9em; }
.header-nav a:hover { text-decoration: underline; }
.header-nav .logout-link { color: #d9534f; }
.container { max-width: 900px; margin: 20px auto; }

/* (★) ログインフォーム */
.login-container { background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); padding: 40px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; }
.form-group input[type="password"],
.form-group input[type="text"], /* (★) admin_home.php用 */
.form-group textarea { /* (★) admin_home.php用 */
    width: 100%; 
    padding: 12px; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    box-sizing: border-box; 
    font-size: 1em; 
}
.btn-login { width: 100%; padding: 12px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 1.1em; font-weight: 600; }
.btn-login:hover { background-color: #0056b3; }
.status-error { color: #d9534f; background-color: #f2dede; border: 1px solid #ebccd1; padding: 10px; border-radius: 4px; text-align: center; margin-top: 15px; }

/* (★) 履歴リスト */
.history-list-container { background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); padding: 20px; overflow-x: auto; /* (★) 念のため横スクロール許可 */ }
.history-item { border: 1px solid #ddd; border-radius: 4px; margin-bottom: 15px; }
.history-header { background-color: #f9f9f9; padding: 12px 15px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.history-header-info { display: flex; flex-direction: column; }
.history-business-name { font-weight: bold; font-size: 1.1em; color: #007bff; }
.history-user-info { font-size: 0.9em; color: #555; }
/* (★) メッセージID用のスタイルを追加 */
.history-item-id { 
    font-size: 0.8em; 
    color: #999; 
    font-family: monospace;
    margin-top: 2px;
}
.history-timestamp { font-size: 0.9em; color: #777; }
.history-status-toggle { display: flex; align-items: center; gap: 10px; flex-shrink: 0; /* (★) 縮まないように */ }
.history-status { font-weight: bold; font-size: 0.9em; padding: 3px 8px; border-radius: 4px; }
.history-status.status-pending { background-color: #f0ad4e; color: white; }
.history-status.status-closed { background-color: #5cb85c; color: white; }
.btn-toggle-status { font-size: 0.9em; padding: 5px 10px; cursor: pointer; background-color: #6c757d; color: white; border: none; border-radius: 4px; }
.btn-toggle-status:hover { background-color: #5a6268; }
.history-body { padding: 15px; }
.history-message { white-space: pre-wrap; word-wrap: break-word; background-color: #fff; border: 1px solid #eee; padding: 10px; border-radius: 4px; }

/* (★) 返信エリア */
.history-replies { margin-top: 15px; padding-top: 15px; border-top: 1px dashed #ccc; }
.history-reply { background-color: #e6f7ff; border: 1px solid #bce8f1; border-radius: 4px; padding: 12px; margin-top: 10px; }
.history-reply-header { font-weight: bold; color: #31708f; font-size: 0.95em; margin-bottom: 5px; display: flex; justify-content: space-between; }
.history-reply-timestamp { font-size: 0.9em; color: #777; font-weight: normal; }
.history-reply-message { white-space: pre-wrap; word-wrap: break-word; color: #333; }
.btn-reply { background-color: #5bc0de; color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; margin-top: 10px; }
.btn-reply:hover { background-color: #31b0d5; }

/* (★) 返信モーダル */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background-color: #fff; border-radius: 8px; padding: 30px; width: 90%; max-width: 600px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.modal-content h3 { margin-top: 0; }
.modal-content textarea { width: 100%; box-sizing: border-box; height: 120px; border: 1px solid #ddd; border-radius: 4px; padding: 8px; }
.modal-actions { margin-top: 20px; text-align: right; }
.btn-cancel { background-color: #6c757d; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; margin-right: 10px; }
.btn-cancel:hover { background-color: #5a6268; }
.btn-send { background-color: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; }
.btn-send:hover { background-color: #0056b3; }

/* 汎用ステータス（JS用） */
.status-message { margin-top: 15px; font-weight: bold; min-height: 1.2em; padding: 10px; border-radius: 4px; display: none; }
.status-error { color: #d9534f; background-color: #f2dede; border: 1px solid #ebccd1; display: block; }
.status-success { color: #3c763d; background-color: #dff0d8; border: 1px solid #d6e9c6; display: block; }
.status-loading { color: #777; background-color: #f0f0f0; border: 1px solid #ddd; display: block; }

/* (★) 申請管理ページ用 */
.application-details {
    padding: 10px;
    background-color: #fdfdfd;
    border-top: 1px solid #eee;
    margin-top: 10px;
}
.application-details h4 { margin-top: 0; margin-bottom: 10px; color: #333; }
.application-details pre {
    background-color: #eee;
    padding: 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
    max-height: 300px;
    overflow-y: auto;
}
.application-actions {
    text-align: right;
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.btn-approve, .btn-deny {
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: white;
}
.btn-approve { background-color: #28a745; } /* 緑 */
.btn-approve:hover { background-color: #218838; }
.btn-deny { background-color: #dc3545; } /* 赤 */
.btn-deny:hover { background-color: #c82333; }

/* (★) 「管理者HOME」ダッシュボード用 */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.dashboard-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 20px;
    text-decoration: none;
    color: #333;
    transition: box-shadow 0.2s ease;
}
.dashboard-card:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.dashboard-card h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
}
.dashboard-card h3 span {
    font-size: 1.5em; /* 絵文字サイズ */
    margin-right: 10px;
}
.dashboard-card .stat-number {
    font-size: 2.5em;
    font-weight: bold;
    color: #007bff;
    text-align: center;
    margin: 10px 0;
}
.dashboard-card .stat-label {
    text-align: center;
    font-size: 0.9em;
    color: #777;
}
.dashboard-card.highlight {
    border: 2px solid #f0ad4e;
}
.dashboard-card.highlight .stat-number {
    color: #f0ad4e;
}

/* (★) 問い合わせ管理 削除ボタン用 */
.history-body-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-danger:hover {
    background-color: #c82333;
}


/* (★) 「事業者一覧」テーブル用 */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    table-layout: auto; 
    word-wrap: break-word; 
}
.admin-table th, .admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    text-align: left;
    vertical-align: top;
    font-size: 0.9em; 
}
.admin-table th:nth-child(1), .admin-table td:nth-child(1) { min-width: 150px; } /* 事業者名 */
.admin-table th:nth-child(2), .admin-table td:nth-child(2) { min-width: 150px; } /* 法人/個人名 */
.admin-table th:nth-child(3), .admin-table td:nth-child(3) { min-width: 160px; } /* Email */
.admin-table th:nth-child(4), .admin-table td:nth-child(4) { min-width: 80px; }  /* ステータス */
.admin-table th:nth-child(5), .admin-table td:nth-child(5) { min-width: 90px; }  /* 登録日 */
.admin-table th:nth-child(6), .admin-table td:nth-child(6) { min-width: 120px; } /* 操作 */

.admin-table th {
    background-color: #f9f9f9;
    font-weight: 600;
    white-space: nowrap; 
}
.admin-table tbody tr:hover {
    background-color: #fdfdfd;
}
.admin-table td .item-id {
    font-size: 0.9em; 
    color: #999;
    font-family: monospace;
    margin-top: 2px;
    word-break: break-all;
}
.admin-table td .status-badge {
    font-weight: bold;
    font-size: 1em; 
    padding: 3px 8px;
    border-radius: 4px;
    color: white;
    white-space: nowrap; 
}
.status-badge.status-approved { background-color: #5cb85c; } /* 承認済み */
.status-badge.status-suspended { background-color: #f0ad4e; } /* 凍結中 */
.status-badge.status-error-text { color: #dc3545; font-weight: bold; } /* データ破損 */

.admin-table .actions-cell {
    display: flex;
    flex-direction: column; 
    gap: 8px;
    align-items: stretch; 
    min-width: 120px; 
}
.admin-table .actions-cell button {
    border: none;
    padding: 8px 10px; 
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em; 
    font-weight: 600;
    color: white;
    text-align: center; 
    width: 100%; 
    box-sizing: border-box; 
    white-space: nowrap;
}
.btn-suspend { background-color: #f0ad4e; } 
.btn-suspend:hover { background-color: #ec971f; }
.btn-approve { background-color: #28a745; }
.btn-approve:hover { background-color: #218838; }
.btn-danger { background-color: #dc3545; } 
.btn-danger:hover { background-color: #c82333; }
.btn-edit { background-color: #007bff; } 
.btn-edit:hover { background-color: #0056b3; }

/* (★) 「お知らせ更新」フォーム用 */
.announcement-form {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 20px;
    margin-top: 20px;
}
.announcement-form h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.announcement-form .form-group input,
.announcement-form .form-group textarea {
    max-width: none; /* (★) 幅を100%にする */
}
.announcement-form textarea {
    height: 100px;
}
.announcement-form .btn-save {
    margin-top: 0; /* (★) フォーム内のマージン調整 */
    font-size: 1em;
    font-weight: 600;
}

/* ▼▼▼ (★) 「お知らせ履歴」用 (ここから追記) ▼▼▼ */
.announcement-history {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #ccc;
}
.announcement-history-item {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 10px;
}
.announcement-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.announcement-history-title {
    font-weight: bold;
    font-size: 1.1em;
    color: #333;
}
.announcement-history-timestamp {
    font-size: 0.9em;
    color: #777;
}
.announcement-history-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #555;
}
/* ▲▲▲ (★) CSSの追記ここまで ▲▲▲ */
.btn-edit {
    background-color: #007bff; /* 青色 (例) */
    color: white;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-right: 5px;
}
.btn-edit:hover {
    background-color: #0056b3;
}

/* (★) スマホ対応 (768px以下) */
@media (max-width: 768px) {
    
    /* --- ヘッダー --- */
    .header {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .header h1 {
        font-size: 1.1em;
        flex-basis: 100%;
        margin: 0;
    }
    .header-nav {
        flex-basis: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .header-nav a {
        font-size: 0.8em;
        padding: 6px 10px;
        border: 1px solid #007bff;
        border-radius: 4px;
        background-color: #e6f2ff;
        flex: 1;
        text-align: center;
    }
    .header-nav .logout-link {
        background-color: #ffe6e6;
        border-color: #d9534f;
    }
    
    /* --- コンテナ --- */
    .container {
        max-width: 100%;
        margin: 10px auto;
        padding: 10px;
    }
    
    /* --- ログインコンテナ --- */
    .login-container {
        padding: 20px;
        border-radius: 6px;
    }
    
    /* --- フォームグループ --- */
    .form-group {
        margin-bottom: 15px;
    }
    .form-group label {
        font-size: 0.9em;
        margin-bottom: 5px;
    }
    .form-group input[type="password"],
    .form-group input[type="text"],
    .form-group textarea {
        padding: 10px;
        font-size: 16px;
        width: 100%;
        box-sizing: border-box;
    }
    .form-group textarea {
        min-height: 100px;
    }
    
    /* --- ボタン --- */
    .btn-login,
    .btn-send,
    .btn-cancel,
    .btn-reply,
    .btn-toggle-status,
    .btn-approve,
    .btn-deny,
    .btn-suspend,
    .btn-danger,
    .btn-edit,
    .btn-save {
        padding: 12px 15px;
        font-size: 0.95em;
        min-height: 44px;
        width: 100%;
        margin-bottom: 8px;
    }
    
    /* --- 履歴リスト --- */
    .history-list-container {
        padding: 15px;
        overflow-x: auto;
    }
    .history-item {
        margin-bottom: 12px;
    }
    .history-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .history-header-info {
        flex-basis: 100%;
    }
    .history-business-name {
        font-size: 1em;
    }
    .history-body {
        padding: 12px;
    }
    .history-message {
        padding: 8px;
        font-size: 0.9em;
    }
    .history-replies {
        margin-top: 10px;
        padding-top: 10px;
    }
    .history-reply {
        padding: 10px;
        margin-top: 8px;
    }
    
    /* --- モーダル --- */
    .modal-content {
        width: 95%;
        max-width: 100%;
        padding: 20px;
    }
    .modal-content h3 {
        font-size: 1.1em;
    }
    .modal-content textarea {
        font-size: 16px;
        min-height: 100px;
    }
    .modal-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .btn-cancel,
    .btn-send {
        flex: 1;
        min-width: 100px;
    }
    
    /* --- ダッシュボードグリッド --- */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .dashboard-card {
        padding: 15px;
    }
    .dashboard-card h3 {
        font-size: 1em;
    }
    .dashboard-card .stat-number {
        font-size: 2em;
    }
    
    /* --- テーブル --- */
    .admin-table {
        font-size: 0.85em;
    }
    .admin-table th,
    .admin-table td {
        padding: 10px 8px;
    }
    .admin-table th:nth-child(1),
    .admin-table td:nth-child(1) { min-width: 120px; }
    .admin-table th:nth-child(2),
    .admin-table td:nth-child(2) { min-width: 120px; }
    .admin-table th:nth-child(3),
    .admin-table td:nth-child(3) { min-width: 140px; }
    .admin-table .actions-cell {
        flex-direction: row;
        gap: 5px;
    }
    .admin-table .actions-cell button {
        padding: 8px 10px;
        font-size: 0.85em;
        flex: 1;
    }
    
    /* --- お知らせフォーム --- */
    .announcement-form {
        padding: 15px;
    }
    .announcement-form .form-group input,
    .announcement-form .form-group textarea {
        max-width: 100%;
    }
    .announcement-form textarea {
        min-height: 80px;
    }
    
    /* --- お知らせ履歴 --- */
    .announcement-history-item {
        padding: 12px;
        margin-bottom: 8px;
    }
    .announcement-history-header {
        flex-wrap: wrap;
        gap: 5px;
    }
    .announcement-history-title {
        font-size: 1em;
    }
    .announcement-history-timestamp {
        flex-basis: 100%;
        font-size: 0.8em;
    }
    .announcement-history-content {
        font-size: 0.9em;
    }
    
    /* --- ステータスメッセージ --- */
    .status-message {
        padding: 12px;
        font-size: 0.9em;
    }
    
    /* --- 申請詳細 --- */
    .application-details {
        padding: 12px;
    }
    .application-details pre {
        font-size: 0.85em;
        max-height: 200px;
    }
    .application-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    .application-actions button {
        flex: 1;
        min-width: 100px;
    }
}

/* (★) 超小型スマホ対応 (480px以下) */
@media (max-width: 480px) {
    
    .header h1 {
        font-size: 1em;
    }
    
    .header-nav a {
        font-size: 0.7em;
        padding: 5px 8px;
    }
    
    .login-container {
        padding: 15px;
    }
    
    .form-group input[type="password"],
    .form-group input[type="text"],
    .form-group textarea {
        padding: 8px;
        font-size: 16px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .btn-login,
    .btn-send,
    .btn-cancel,
    .btn-reply,
    .btn-toggle-status,
    .btn-approve,
    .btn-deny,
    .btn-suspend,
    .btn-danger,
    .btn-edit,
    .btn-save {
        padding: 10px 12px;
        font-size: 0.9em;
        min-height: 40px;
    }
    
    .history-list-container {
        padding: 10px;
    }
    
    .history-header {
        padding: 8px 10px;
    }
    
    .history-body {
        padding: 10px;
    }
    
    .modal-content {
        padding: 15px;
    }
    
    .admin-table {
        font-size: 0.8em;
    }
    .admin-table th,
    .admin-table td {
        padding: 8px 6px;
    }
    .admin-table .actions-cell button {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    
    .announcement-form {
        padding: 12px;
    }
    
    .dashboard-card {
        padding: 12px;
    }
}