/**
 * DVTV 承認ワークフロー v2.1
 */

/* 共通 */
.dvtv-notice { padding: 10px 14px; background: #f0f6fc; border-left: 3px solid #2271b1; color: #1d2327; font-size: 13px; }
.dvtv-status-badge { display: inline-block; padding: 4px 14px; border-radius: 3px; font-size: 14px; font-weight: 700; }
.status-approved { background: #d4edda; color: #155724; }
.status-rejected { background: #f8d7da; color: #721c24; }
.status-returned { background: #fff3cd; color: #856404; }
.status-pending { background: #cce5ff; color: #004085; }

/* 共通ボタン - 青/赤 */
.dvtv-btn-primary { display: inline-block; padding: 8px 20px; background: #2271b1; color: #fff !important; border: none; border-radius: 4px; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none; }
.dvtv-btn-primary:hover { background: #1a5a8a; }
.dvtv-btn-danger { display: inline-block; padding: 6px 14px; background: #dc3545; color: #fff !important; border: none; border-radius: 4px; font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: none; }
.dvtv-btn-danger:hover { background: #c82333; }

/* 承認ログテーブル */
.dvtv-approval-log { background: #fff; border: 1px solid #ccc; margin: 8px 0; font-size: 12px; }
.dvtv-log-note-top { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #f0f6fc; border-bottom: 1px solid #ccc; }
.dvtv-log-note-top .note-text { color: #666; font-size: 12px; }
.dvtv-final-approver-box { padding: 8px 12px; background: #e8f5e9; color: #2e7d32; font-weight: 600; font-size: 13px; border-top: 1px solid #ccc; }
.dvtv-log-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dvtv-log-table { width: 100%; border-collapse: collapse; font-size: 11px; min-width: 600px; }
.dvtv-log-table th, .dvtv-log-table td { padding: 5px 8px; text-align: center; border: 1px solid #ccc; white-space: nowrap; }
.dvtv-log-table th { font-weight: 600; color: #fff; font-size: 11px; }
.dvtv-log-table th.col-date { background: #556; font-size: 11px; min-width: 200px; white-space: nowrap; }
.dvtv-log-table th.step-a2z { background: #7b68ee; }
.dvtv-log-table th.step-a21 { background: #4169e1; }
.dvtv-log-table th.step-a22 { background: #20b2aa; }
.dvtv-log-table th.step-a23 { background: #66cdaa; }
.dvtv-log-table th.step-a24 { background: #f4a460; }
.dvtv-log-table td { background: #fff; font-size: 11px; }
.dvtv-log-table td.row-label { background: #e8e8f0; font-weight: 600; color: #336; width: 80px; }
.dvtv-log-table tr.row-next td { background: #fffde0; }
.dvtv-log-table tr.row-next td.row-label { background: #ffd700; color: #333; }
.dvtv-log-table .result-approved { color: #090; font-weight: 600; }
.dvtv-log-table .result-rejected { color: #c00; font-weight: 600; }
.dvtv-log-table .result-reapply { color: #f60; font-weight: 600; }
.dvtv-reject-reasons { padding: 8px 12px; background: #fff5f5; border-top: 1px solid #fcc; font-size: 11px; }
.dvtv-reject-reasons .reason-step { color: #c00; font-weight: 600; }

/* 承認フォーム */
.dvtv-approval-form { margin: 8px 0; }
.dvtv-form-toggle-btn { display: block; width: 100%; padding: 10px 16px; background: #2271b1; color: #fff; border: none; font-size: 14px; font-weight: 700; cursor: pointer; text-align: left; }
.dvtv-form-toggle-btn:hover { background: #1a5a8a; }
.dvtv-form-body { padding: 12px; background: #fff; border: 1px solid #ccc; border-top: none; }

/* アクションタブ - 1行表示、太字、選択時点滅 */
.dvtv-action-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.action-tab { flex: 1; cursor: pointer; }
.action-tab input { display: none; }
.action-tab .tab-box { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 8px; background: #f5f5f5; border: 2px solid #ddd; border-radius: 4px; transition: all 0.2s; }
.action-tab:hover .tab-box { background: #eee; border-color: #bbb; }
.action-tab .tab-icon { font-size: 22px; line-height: 1; }
.action-tab .tab-label { font-size: 15px; font-weight: 700; color: #333; white-space: nowrap; }

/* 承認して次へ / 最終承認 - 選択時は青背景+点滅 */
.action-tab.tab-approve.active .tab-box,
.action-tab.tab-finalize.active .tab-box { background: #1a5a8a; border-color: #1a5a8a; animation: tab-blink 1s infinite; }
.action-tab.tab-approve.active .tab-icon, .action-tab.tab-approve.active .tab-label,
.action-tab.tab-finalize.active .tab-icon, .action-tab.tab-finalize.active .tab-label { color: #fff; }

/* 差戻し - 選択時はピンク背景+点滅 */
.action-tab.tab-return.active .tab-box { background: #ff9999; border-color: #ff6666; animation: tab-blink 1s infinite; }
.action-tab.tab-return.active .tab-icon, .action-tab.tab-return.active .tab-label { color: #fff; }

/* 却下 - 選択時は赤背景+点滅 */
.action-tab.tab-reject.active .tab-box { background: #dc3545; border-color: #c82333; animation: tab-blink 1s infinite; }
.action-tab.tab-reject.active .tab-icon, .action-tab.tab-reject.active .tab-label { color: #fff; }

@keyframes tab-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

.dvtv-form-fields { margin-bottom: 12px; }
.field-group { margin-bottom: 10px; }
.field-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: #333; }
.field-group .required { color: #c00; font-size: 10px; }
.field-group .field-hint { color: #666; font-size: 10px; margin-top: 4px; }
.field-group select, .field-group textarea { width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 3px; font-size: 13px; }
.dvtv-form-actions { display: flex; align-items: center; justify-content: center; gap: 12px; }
.dvtv-finalize-only { text-align: center; padding: 15px; }
.finalize-notice { color: #f60; font-size: 13px; margin-bottom: 12px; }

/* 承認完了ダイアログ */
.dvtv-complete-dialog { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.dvtv-complete-dialog .dialog-content { background: #fff; padding: 30px 40px; border-radius: 8px; text-align: center; min-width: 300px; }
.dvtv-complete-dialog .dialog-icon { font-size: 48px; color: #28a745; margin-bottom: 10px; }
.dvtv-complete-dialog .dialog-message { font-size: 16px; font-weight: 600; margin-bottom: 20px; }
.dvtv-complete-dialog .dialog-buttons { display: flex; flex-direction: column; gap: 10px; }
.dvtv-complete-dialog .dialog-buttons .dvtv-btn-primary { width: 100%; }

/* 一覧表示 */
.dvtv-pending-list, .dvtv-my-requests { background: #fff; border: 1px solid #ccc; margin: 8px 0; }
.list-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #343a40; color: #fff; }
.header-icon { font-size: 16px; }
.header-title { flex: 1; font-weight: 600; font-size: 14px; }
.header-count { background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.btn-completed-popup { padding: 4px 12px; background: #28a745; color: #fff; border: none; border-radius: 4px; font-size: 11px; font-weight: 600; cursor: pointer; }
.btn-completed-popup:hover { background: #218838; }
.list-body { padding: 8px; max-height: 400px; overflow-y: auto; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: #f8f9fa; border-radius: 4px; margin-bottom: 6px; border-left: 3px solid transparent; }
.list-item.needs-action { background: #fff8e1; border-left-color: #f60; }
.list-item.alert-warning { background: #fff3cd; border-left-color: #f0ad4e; }
.list-item.alert-urgent { background: #f8d7da; border-left-color: #dc3545; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.7; } }
.item-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.item-badge { background: #6c757d; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 10px; }
.item-status { padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; }
.alert-badge { background: #dc3545; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; }
.days-badge { background: #f0ad4e; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 10px; }
.item-title { color: #333; text-decoration: none; font-weight: 500; font-size: 13px; }
.item-title:hover { color: #2271b1; }
.item-date { color: #888; font-size: 11px; }
.item-actions { display: flex; gap: 4px; }
.item-btn, .btn-detail { padding: 5px 12px; background: #2271b1; color: #fff; border: none; border-radius: 3px; font-size: 11px; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn-edit { padding: 5px 12px; background: #2271b1; color: #fff; border: none; border-radius: 3px; font-size: 11px; font-weight: 700; text-decoration: none; }
.btn-delete { padding: 5px 12px; background: #dc3545; color: #fff; border: none; border-radius: 3px; font-size: 11px; font-weight: 700; cursor: pointer; }
.btn-resubmit { padding: 5px 12px; background: #2271b1; color: #fff; border: none; border-radius: 3px; font-size: 11px; font-weight: 700; cursor: pointer; }
.empty-message { text-align: center; color: #888; padding: 20px; font-size: 13px; }

/* 承認完了済ポップアップ */
.dvtv-completed-popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; }
.dvtv-completed-popup .popup-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); }
.dvtv-completed-popup .popup-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: 8px; width: 90%; max-width: 800px; max-height: 80vh; display: flex; flex-direction: column; }
.dvtv-completed-popup .popup-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #28a745; color: #fff; border-radius: 8px 8px 0 0; }
.dvtv-completed-popup .popup-title { font-size: 16px; font-weight: 700; }
.dvtv-completed-popup .popup-close { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }
.dvtv-completed-popup .popup-search { padding: 10px 16px; border-bottom: 1px solid #eee; }
.dvtv-completed-popup .popup-search input { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
.dvtv-completed-popup .popup-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.dvtv-completed-popup .popup-pagination { padding: 10px 16px; border-top: 1px solid #eee; display: flex; align-items: center; justify-content: center; gap: 12px; }
.dvtv-completed-popup .page-info { color: #666; font-size: 12px; }
.dvtv-completed-popup .page-btn { padding: 6px 14px; background: #2271b1; color: #fff; border: none; border-radius: 4px; font-size: 12px; cursor: pointer; }
.dvtv-completed-popup .page-btn:hover { background: #1a5a8a; }
.dvtv-completed-popup .loading { text-align: center; color: #888; padding: 30px; }
.dvtv-completed-popup .completed-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dvtv-completed-popup .completed-table th, .dvtv-completed-popup .completed-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eee; }
.dvtv-completed-popup .completed-table th { background: #f5f5f5; font-weight: 600; }
.dvtv-completed-popup .completed-table a { color: #2271b1; text-decoration: none; }
.dvtv-completed-popup .completed-table a:hover { text-decoration: underline; }

/* ダッシュボード */
.dvtv-dashboard { background: #fff; border: 1px solid #ccc; margin: 8px 0; }
.dashboard-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #495057; color: #fff; }
.dashboard-stats { display: flex; gap: 10px; padding: 12px; }
.stat-card { flex: 1; text-align: center; padding: 12px; border-radius: 6px; }
.stat-card.pending { background: #e3f2fd; }
.stat-card.approved { background: #e8f5e9; }
.stat-card.rejected { background: #ffebee; }
.stat-card.returned { background: #fff8e1; }
.stat-num { font-size: 28px; font-weight: 700; color: #333; }
.stat-label { font-size: 12px; color: #666; }

/* 編集ログ */
.dvtv-edit-log { background: #fff; border: 1px solid #ccc; margin: 8px 0; }
.edit-log-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #6c757d; color: #fff; font-weight: 600; font-size: 13px; }
.edit-log-body { padding: 8px; max-height: 200px; overflow-y: auto; }
.edit-log-item { display: flex; gap: 12px; padding: 6px 8px; border-bottom: 1px solid #eee; font-size: 12px; }
.edit-log-item:last-child { border-bottom: none; }
.log-date { color: #666; min-width: 130px; }
.log-user { color: #333; font-weight: 500; min-width: 80px; }
.log-action { color: #2271b1; }

/* 設定ボックス */
.dvtv-settings-box { background: #fff; border: 1px solid #ccc; border-radius: 4px; margin: 10px 0; }
.settings-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; font-weight: 600; font-size: 14px; }
.settings-header.orange { background: #e67e22; }
.settings-header.purple { background: #6c5ce7; }
.settings-header.green { background: #00b894; }
.settings-header.navy { background: #1e3a5f; }
.settings-header.blue { background: #2271b1; }
.settings-header.gray { background: #495057; }
.settings-body { padding: 12px; }
.settings-body .desc { color: #666; font-size: 12px; margin-bottom: 12px; }
.settings-body .empty { color: #999; text-align: center; padding: 15px; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px; max-height: 200px; overflow-y: auto; padding: 8px; background: #f9f9f9; border-radius: 4px; margin-bottom: 10px; }
.user-check { display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: #fff; border: 1px solid #ddd; border-radius: 3px; font-size: 11px; cursor: pointer; }
.user-check:hover { border-color: #2271b1; }
.add-form { padding-top: 12px; border-top: 1px solid #eee; }
.add-form h4 { margin: 0 0 10px; font-size: 13px; }
.form-row { margin-bottom: 10px; }
.form-row label { font-size: 12px; font-weight: 600; margin-bottom: 4px; display: block; }
.form-row input[type="text"], .form-row select { width: 100%; max-width: 300px; padding: 6px 8px; border: 1px solid #ccc; border-radius: 3px; font-size: 12px; }
.form-row-inline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.form-row-inline .form-field { flex: 1; min-width: 150px; }
.form-row-inline .form-field label { font-size: 11px; font-weight: 600; margin-bottom: 3px; display: block; }
.form-row-inline .form-field select { width: 100%; padding: 6px; font-size: 12px; }
.approvers-inline { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.approvers-inline select { width: 120px; padding: 4px; font-size: 11px; }
.arrow-sep { color: #999; margin: 0 2px; }
.user-settings-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.user-settings-table th, .user-settings-table td { padding: 6px 10px; border: 1px solid #ddd; text-align: left; }
.user-settings-table th { background: #f5f5f5; font-weight: 600; }
.user-settings-table td.center { text-align: center; }
.ur-tag { background: #e3f2fd; color: #1565c0; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.ur-arrow { color: #2271b1; font-weight: bold; }
.user-route-list, .delegate-list { margin-bottom: 12px; }
.user-route-item, .delegate-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #f8f9fa; border-radius: 4px; margin-bottom: 6px; font-size: 12px; }
.ur-user { background: #e3f2fd; padding: 2px 6px; border-radius: 3px; font-size: 11px; }
.ur-approvers { flex: 1; color: #666; font-size: 11px; }
.d-from, .d-to { font-weight: 600; }
.d-arrow { color: #00b894; }
.d-period { color: #888; font-size: 11px; }
.d-status { padding: 2px 6px; border-radius: 3px; font-size: 10px; background: #e9ecef; color: #666; }
.d-status.active { background: #d4edda; color: #155724; }
.btn-del-route, .btn-del-delegate, .btn-del-ur { padding: 4px 10px; background: #dc3545; color: #fff; border: none; border-radius: 3px; font-size: 11px; font-weight: 700; cursor: pointer; }
.role-row { display: flex; align-items: center; gap: 12px; padding: 10px; background: #f8f9fa; border-radius: 4px; margin-bottom: 8px; }
.role-row label { font-weight: 600; min-width: 100px; font-size: 13px; }
.role-row select { flex: 1; max-width: 250px; padding: 6px; font-size: 12px; }
.period-dates { margin-top: 8px; }
.period-dates input { padding: 4px 6px; font-size: 12px; }

/* レスポンシブ */
@media (max-width: 600px) {
    .dvtv-log-table { font-size: 10px; }
    .dvtv-log-table th, .dvtv-log-table td { padding: 3px 4px; }
    .dvtv-log-table th.col-date { min-width: 140px; }
    .dvtv-action-tabs { flex-wrap: wrap; }
    .action-tab { min-width: 45%; }
    .form-row-inline { flex-direction: column; }
    .user-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-stats { flex-wrap: wrap; }
    .stat-card { min-width: 45%; }
    .dvtv-completed-popup .popup-content { width: 95%; }
}

/* 再申請/削除ボタンエリア（投稿ページ用） */
.dvtv-resubmit-buttons { background: #fff8e1; border: 1px solid #f0ad4e; border-radius: 4px; padding: 15px; margin: 10px 0; }
.dvtv-resubmit-buttons .resubmit-notice { color: #856404; font-size: 13px; margin: 0 0 12px 0; }
.dvtv-resubmit-buttons .resubmit-actions { display: flex; gap: 10px; }

/* ダッシュボード詳細テーブル */
.dashboard-section { margin-top: 15px; border: 1px solid #ddd; border-radius: 4px; overflow: hidden; }
.section-header { padding: 10px 12px; color: #fff; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.section-header.pending { background: #2271b1; }
.section-header.approved { background: #28a745; }
.section-header.rejected { background: #dc3545; }
.section-header.returned { background: #f0ad4e; }
.section-body { max-height: 300px; overflow-y: auto; }
.dashboard-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dashboard-table th, .dashboard-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eee; }
.dashboard-table th { background: #f5f5f5; font-weight: 600; position: sticky; top: 0; }
.dashboard-table tbody tr:hover { background: #f9f9f9; }
.dashboard-table a { color: #2271b1; text-decoration: none; }
.dashboard-table a:hover { text-decoration: underline; }
.step-badge { background: #6c757d; color: #fff; padding: 2px 8px; border-radius: 3px; font-size: 10px; }
.btn-detail-sm { display: inline-block; padding: 3px 10px; background: #2271b1; color: #fff !important; border-radius: 3px; font-size: 11px; font-weight: 600; text-decoration: none !important; }

/* エラーメッセージ */
.field-error { color: #dc3545; font-size: 12px; background: #fff5f5; padding: 8px 12px; border-radius: 4px; border-left: 3px solid #dc3545; }
