/* ============================================
   PMS - 給与管理システム スタイル
   サイドバー型レイアウト
   ============================================ */

:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: rgba(255,255,255,0.7);
    --sidebar-text-dim: rgba(255,255,255,0.4);
    --sidebar-border: rgba(255,255,255,0.1);
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bg: #f8fafc;
    --white: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

/* テーマ: ブルー（デフォルト） */
[data-theme="blue"] {
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
}

/* テーマ: グレー */
[data-theme="gray"] {
    --sidebar-bg: #374151;
    --sidebar-hover: #4b5563;
    --sidebar-active: #6b7280;
    --accent: #6b7280;
    --accent-hover: #4b5563;
}

/* テーマ: レッド */
[data-theme="red"] {
    --sidebar-bg: #7f1d1d;
    --sidebar-hover: #991b1b;
    --sidebar-active: #dc2626;
    --accent: #dc2626;
    --accent-hover: #b91c1c;
}

/* テーマ: グリーン */
[data-theme="green"] {
    --sidebar-bg: #14532d;
    --sidebar-hover: #166534;
    --sidebar-active: #16a34a;
    --accent: #16a34a;
    --accent-hover: #15803d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ============================================
   サイドバー
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    padding: 24px;
    border-bottom: 1px solid var(--sidebar-border);
    text-align: center;
}

.sidebar-logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.sidebar-logo .app-subtitle {
    font-size: 11px;
    color: var(--sidebar-text-dim);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-text-dim);
    padding: 12px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text-muted);
    text-decoration: none;
    border-radius: 8px;
    margin: 2px 0;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    color: var(--sidebar-text-muted);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
}

.user-name {
    font-size: 14px;
    color: var(--sidebar-text);
}

.user-role {
    font-size: 11px;
    color: var(--sidebar-text-dim);
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 10px;
    margin-top: 12px;
    background: rgba(255,255,255,0.1);
    color: var(--sidebar-text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--sidebar-text);
}

/* ============================================
   メインコンテンツ
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ============================================
   カード
   ============================================ */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ============================================
   ボタン
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ============================================
   フォーム
   ============================================ */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-group .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-select {
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 20px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* ============================================
   テーブル
   ============================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8fafc;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table .amount {
    font-weight: 600;
    font-family: 'Consolas', monospace;
}

/* ============================================
   ステータスバッジ
   ============================================ */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.status-badge.active,
.status-badge.confirmed {
    background: #dcfce7;
    color: #166534;
}

.status-badge.inactive,
.status-badge.draft {
    background: #f1f5f9;
    color: #475569;
}

/* ============================================
   モーダル
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* ============================================
   ローディング
   ============================================ */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   アラート
   ============================================ */
.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ============================================
   ログインページ
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 3px;
}

.login-logo p {
    color: var(--text-light);
    margin-top: 8px;
}

.login-box .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 8px;
}

/* ============================================
   給与サマリー
   ============================================ */
.salary-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.summary-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.summary-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
}

/* ============================================
   設定ページ
   ============================================ */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: #f8fafc;
}

.list-item-sub {
    font-size: 13px;
    color: var(--text-light);
}

/* ============================================
   エラーページ
   ============================================ */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.error-content {
    text-align: center;
}

.error-content h1 {
    font-size: 48px;
    color: var(--danger);
    margin-bottom: 16px;
}

.error-content p {
    color: var(--text-light);
    margin-bottom: 24px;
}

/* ============================================
   タイムカード
   ============================================ */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.summary-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.summary-item .summary-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.summary-item .summary-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.row-holiday {
    background: #f3f4f6 !important;
}

.row-holiday td {
    color: #9ca3af;
}

.row-paid-leave {
    background: #ecfdf5 !important;
}

.row-absent {
    background: #fef2f2 !important;
}

.form-control-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.filter-form .form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

/* ============================================
   レスポンシブ
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .form-row {
        flex-direction: column;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .salary-summary {
        grid-template-columns: 1fr;
    }
}
