/* === A2 Lab - 車両修理見積もりシステム === */

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #252833;
    --border: #2e3140;
    --text: #e4e6ed;
    --text-dim: #8b8fa3;
    --accent: #f0883e;
    --accent-hover: #d87a35;
    --danger: #e05555;
    --danger-hover: #c94444;
    --success: #4caf7d;
    --warning: #e8a94a;
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* --- ログイン画面 --- */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
}

.login-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* --- ヘッダー --- */
header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.cashier {
    background: #2d4a2d;
    color: #6fcf6f;
}

.role-badge.manager {
    background: #4a3d2d;
    color: #e8a94a;
}

.role-badge.admin {
    background: #3d2d4a;
    color: #b88af5;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 2px;
}

/* --- タブ --- */
.tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 16px 16px 0;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.95rem;
    padding: 10px 24px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
}

/* --- カード --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 {
    margin-bottom: 0;
}

/* --- グリッドレイアウト --- */
.estimate-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
}

.manage-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* --- 修理チェックリスト --- */
.repair-item {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) auto auto;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

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

.repair-item:hover {
    background: rgba(91, 138, 245, 0.05);
}

.repair-item label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.repair-item .item-name {
    white-space: nowrap;
}

.repair-item .item-options {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: end;
}

/* オプションなしの項目はグリッド2列目を空にして価格を揃える */
.repair-item .item-price:nth-child(2) {
    grid-column: 3;
}

.repair-item select,
.repair-item input[type="number"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    width: auto;
}

.repair-item select {
    min-width: 80px;
}

.repair-item input[type="number"] {
    width: 60px;
    text-align: center;
}

.damage-checks {
    display: flex;
    gap: 12px;
}

.damage-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 130px;
}

.item-price {
    color: var(--warning);
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 100px;
    text-align: right;
}

.dispatch-row {
    padding: 12px;
    margin-top: 8px;
    border-top: 2px solid var(--border);
}

.dispatch-row label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.price {
    color: var(--warning);
}

/* --- 合計表示 --- */
.total-display {
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
}

.total-final {
    border-top: 2px solid var(--accent);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

/* --- フォーム --- */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

select,
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- ボタン --- */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
    margin-bottom: 8px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-dim);
    width: 100%;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.85rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.btn-small:hover {
    background: var(--accent-hover);
}

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

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85rem;
    border-radius: 4px;
}

.btn-icon:hover {
    background: var(--bg-input);
    color: var(--text);
}

.btn-icon.delete:hover {
    color: var(--danger);
}

/* --- テーブル --- */
.table-wrap {
    overflow-x: auto;
}

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

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr:hover {
    background: rgba(91, 138, 245, 0.05);
}

/* --- インラインフォーム --- */
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.inline-form input[type="text"] {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-dim);
    white-space: nowrap;
    cursor: pointer;
}

/* --- エンティティリスト --- */
.entity-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.entity-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.entity-list li:last-child {
    border-bottom: none;
}

.entity-list .badge {
    font-size: 0.7rem;
    background: var(--accent);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* --- モーダル --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
    width: auto;
}

/* --- チェックボックス スタイル --- */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* --- トースト通知 --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 2000;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.5s forwards;
}

.toast.error {
    background: var(--danger);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* --- 未請求エリア --- */
.unbilled-area {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.unbilled-breakdown {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
}

.unbilled-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.unbilled-label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.unbilled-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    min-width: 90px;
    text-align: right;
}

.unbilled-final {
    border-top: 1px solid var(--border);
    padding-top: 4px;
    margin-top: 2px;
}

.unbilled-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--warning);
    min-width: 90px;
    text-align: right;
}

.unbilled-amount.zero {
    color: var(--success);
}

.btn-billing {
    background: var(--warning);
    color: #1a1d27;
}

.btn-billing:hover {
    background: #d09a3a;
}

/* 給与支払いボタン — アクションであることを明確化 */
.btn-pay-salary {
    background: transparent;
    color: var(--success);
    border: 1px solid var(--success);
    font-weight: 600;
}

.btn-pay-salary:hover {
    background: var(--success);
    color: #fff;
}

/* --- 給与テーブル合計行 --- */
.total-final-row td {
    border-top: 2px solid var(--accent);
    font-weight: 700;
    color: var(--accent);
    padding-top: 12px;
}

/* --- 請求済み行 --- */
tr.billed td {
    opacity: 0.45;
}

td .status-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

td .status-badge.unbilled {
    background: rgba(232, 169, 74, 0.15);
    color: var(--warning);
}

td .status-badge.billed {
    background: rgba(76, 175, 125, 0.15);
    color: var(--success);
}

/* --- ユーティリティ --- */
.text-dim {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 6px;
}

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

    .tabs {
        gap: 0;
    }

    .tab {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .repair-item {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .repair-item .item-options {
        justify-self: start;
    }

    .item-price {
        min-width: auto;
        justify-self: end;
    }

    .inline-form {
        flex-wrap: wrap;
    }
}
