/* ===============================================
   総人件費シミュレーター - スタイルシート
   =============================================== */

/* リセット & ベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --highlight-bg: #fef08a;
    --highlight-text: #713f12;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ヘッダー */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* メインコンテンツ */
main {
    padding: 2rem;
}

section {
    margin-bottom: 3rem;
}

h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--primary-color);
}

h3 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 2rem 0 1rem 0;
}

.help-text {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

small.help-text {
    display: block;
    margin-top: 0.25rem;
    margin-left: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* フォームモード表示 */
.form-mode-indicator {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
}

.mode-badge {
    background: rgba(255, 255, 255, 0.3);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 700;
}

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

/* フォームセクション */
.form-section {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.insurance-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.required {
    color: var(--danger-color);
    font-weight: 700;
}

input[type="text"],
input[type="number"],
select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select {
    cursor: pointer;
    background: white;
}

input::placeholder {
    color: #cbd5e1;
}

/* ボタン */
.btn {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-2px);
}

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

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

.btn-warning:hover {
    background: #d97706;
}

.btn-info {
    background: #3b82f6;
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

.form-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* 手当入力エリア */
#allowances-container {
    margin-bottom: 1rem;
}

.allowance-row {
    margin-bottom: 0.75rem;
}

.allowance-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.allowance-name {
    width: 100%;
}

.allowance-amount {
    width: 100%;
}

.btn-remove-allowance {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-allowance:hover {
    background: #dc2626;
    transform: scale(1.1);
}

#add-allowance-btn {
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
}

/* 手当テンプレート */
.template-section {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.template-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.template-select {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
}

.template-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 部署入力グループ */
.department-input-group {
    display: flex;
    gap: 0.5rem;
}

.department-input-group select,
.department-input-group input {
    flex: 1;
}

/* フィルターセクション */
.filter-section {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.department-filter {
    flex: 1;
    max-width: 300px;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
}

/* 部署別集計 */
.department-summary-table {
    width: 100%;
    margin-top: 1rem;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.department-summary-table th {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 1rem;
    text-align: left;
}

.department-summary-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.department-summary-table tr:hover {
    background: #f1f5f9;
}

.department-summary-table .highlight {
    background: #fde047 !important;
    color: #422006 !important;
    font-weight: 700;
}

/* 比較モード */
.comparison-section {
    background: var(--surface-color);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.comparison-controls {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-group label {
    margin: 0;
    font-weight: 600;
}

.control-group select {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.comparison-panel {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.before-panel {
    border-color: #94a3b8;
}

.after-panel {
    border-color: #10b981;
}

.diff-panel {
    border-color: #f59e0b;
}

.comparison-panel h3 {
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    font-size: 1.1rem;
}

.summary-box {
    font-size: 0.95rem;
}

.summary-box .summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-box .summary-item:last-child {
    border-bottom: none;
}

.summary-box .summary-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.summary-box .summary-value {
    font-weight: 700;
    color: var(--text-primary);
}

.summary-box .highlight-value {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.summary-box .positive {
    color: var(--danger-color);
}

.summary-box .negative {
    color: var(--success-color);
}

.summary-box .no-data {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* 給与サマリー */
.salary-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin: 2rem 0;
    box-shadow: var(--shadow-md);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.summary-label {
    font-size: 1.1rem;
    font-weight: 500;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.summary-detail {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.8;
    white-space: pre-line;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-top: 1rem;
}

/* テーブルセクション */
.table-section {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    margin-bottom: 0;
    border-bottom: none;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.table-container {
    overflow-x: auto;
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 1rem 0.75rem;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

td {
    padding: 0.875rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

/* 操作列のスタイル */
td:last-child {
    white-space: nowrap;
    min-width: 180px;
    padding: 0.5rem;
}

td:last-child .btn-edit,
td:last-child .btn-delete {
    display: inline-block;
    margin: 0.25rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    vertical-align: middle;
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: #f1f5f9;
}

.empty-state td {
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.number {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.highlight {
    background: #fde047 !important;
    color: #422006 !important;
    font-weight: 700;
}

.highlight-card {
    background: var(--highlight-bg);
    border: 2px solid var(--warning-color);
}

tfoot {
    background: #f8fafc;
    font-weight: 700;
}

.total-row td {
    border-top: 3px solid var(--primary-color);
    padding: 1.25rem 0.75rem;
    font-size: 1rem;
}

.btn-delete {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-delete:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.btn-edit {
    background: var(--warning-color);
    color: white;
    border: none;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-right: 0.25rem;
    white-space: nowrap;
}

.btn-edit:hover {
    background: #d97706;
    transform: scale(1.05);
}

/* 情報セクション */
.info-section {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.info-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.formula {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin: 0;
}

.note {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* 用語集 */
.glossary {
    display: grid;
    gap: 1.5rem;
}

dt {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

dd {
    margin-left: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

dd ul {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
}

dd li {
    margin-bottom: 0.25rem;
}

/* フッター */
footer {
    background: #1e293b;
    color: white;
    text-align: center;
    padding: 1.5rem;
    font-size: 0.9rem;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .container {
        border-radius: 8px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    main {
        padding: 1rem;
    }

    .form-section,
    .info-section {
        padding: 1.5rem;
    }

    .form-grid,
    .insurance-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions .btn {
        width: 100%;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.5rem 0.35rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* モバイル向け手当入力 */
    .allowance-inputs {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .btn-remove-allowance {
        width: 100%;
        height: 36px;
    }

    .summary-value {
        font-size: 1.5rem;
    }

    /* 比較モード - モバイル */
    .comparison-grid {
        grid-template-columns: 1fr;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group select {
        min-width: 100%;
    }

    /* ボタンをモバイルで縦並びに */
    td:last-child {
        min-width: auto;
    }
    
    td:last-child .btn-edit,
    td:last-child .btn-delete {
        display: block;
        width: 100%;
        margin: 0.25rem 0;
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
    }
}

/* プリント対応 */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
    }

    .form-section,
    .btn,
    footer {
        display: none;
    }

    .table-section {
        page-break-inside: avoid;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

tbody tr {
    animation: fadeIn 0.3s ease;
}

/* スクロールバーのカスタマイズ */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #475569;
}