/* ============================================
   松田林業 日報システム - 共通スタイル
   ============================================ */

/* --- ユーザー画面テーマ（森林グリーン） --- */
:root {
    --primary: #2D5016;
    --primary-light: #3D6B20;
    --secondary: #4A7C2E;
    --accent: #8B6914;
    --bg: #F5F2EB;
    --bg-card: #FFFFFF;
    --bg-header: #2D5016;
    --text: #333333;
    --text-light: #666666;
    --text-on-primary: #FFFFFF;
    --border: #D4CFBF;
    --table-header-bg: #E8E3D6;
    --table-stripe: #FAF8F3;
    --table-hover: #F0EDE3;
}

/* --- 管理者画面テーマ（木目ブラウン） --- */
.theme-admin {
    --primary: #5C3D2E;
    --primary-light: #7A5440;
    --secondary: #8B6F47;
    --accent: #3A6B35;
    --bg: #FAF6F1;
    --bg-card: #FFFFFF;
    --bg-header: #5C3D2E;
    --text: #3C3C3C;
    --text-light: #777777;
    --text-on-primary: #FFFFFF;
    --border: #DDD5CA;
    --table-header-bg: #EDE6DC;
    --table-stripe: #FBF8F4;
    --table-hover: #F3EDE4;
}

/* ===== 共通 ===== */
body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
    min-height: 100vh;
}

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

.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.login-header {
    background: var(--bg-header);
    color: var(--text-on-primary);
    padding: 32px 24px 20px;
    text-align: center;
}

.login-header .company-name {
    font-size: 13px;
    letter-spacing: 3px;
    margin-bottom: 4px;
    opacity: 0.85;
}

.login-header .system-title {
    font-size: 24px;
    font-weight: bold;
    margin: 0;
}

.login-body {
    background: var(--bg-card);
    padding: 32px;
}

.login-body .system-label {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

.login-body .form-control {
    height: 48px;
    border-radius: 8px;
    border-color: var(--border);
    margin-bottom: 16px;
}

.login-body .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

.theme-admin .login-body .form-control:focus {
    box-shadow: 0 0 0 3px rgba(92, 61, 46, 0.1);
}

.btn-login {
    width: 100%;
    height: 48px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 16px;
    border: none;
    background: var(--primary);
    color: var(--text-on-primary);
    margin-top: 8px;
    transition: background-color 0.2s;
}

.btn-login:hover {
    background: var(--primary-light);
    color: var(--text-on-primary);
}

/* ===== ナビバー（ユーザー画面用） ===== */
.navbar-app {
    background: var(--bg-header);
    padding: 12px 24px;
}

.navbar-app .navbar-brand {
    color: var(--text-on-primary);
    font-weight: bold;
    font-size: 16px;
}

.navbar-app .navbar-brand:hover {
    color: var(--text-on-primary);
}

.navbar-app .nav-user {
    color: var(--text-on-primary);
    font-size: 14px;
    opacity: 0.9;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--text-on-primary);
    color: var(--text-on-primary);
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 13px;
    opacity: 0.8;
    transition: all 0.2s;
}

.btn-logout:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-on-primary);
}

/* ===== 管理画面レイアウト（サイドバー + トップバー） ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    background: var(--bg-header);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

.admin-sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-sidebar-brand .brand-title {
    color: var(--text-on-primary);
    font-size: 17px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-sidebar-brand .brand-sub {
    color: var(--text-on-primary);
    font-size: 10px;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-top: 2px;
    padding-left: 28px;
}

.admin-sidebar-label {
    padding: 16px 20px 6px;
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--text-on-primary);
    opacity: 0.45;
    text-transform: uppercase;
    font-weight: 600;
}

.admin-sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.admin-sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 11px 20px;
    color: var(--text-on-primary);
    text-decoration: none;
    font-size: 13.5px;
    opacity: 0.7;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.admin-sidebar-nav a:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.admin-sidebar-nav a.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.13);
    border-left-color: #e8c170;
    font-weight: 600;
}

.admin-sidebar-nav a i {
    width: 22px;
    text-align: center;
    margin-right: 12px;
    font-size: 14px;
    opacity: 0.85;
}

.admin-sidebar-nav a.active i {
    opacity: 1;
    color: #e8c170;
}

.admin-sidebar-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 10px 20px;
}

.admin-body {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    background: var(--bg-card);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.admin-topbar .topbar-brand {
    color: var(--text);
    font-weight: bold;
    font-size: 16px;
}

.admin-topbar .topbar-brand i {
    margin-right: 8px;
    color: var(--primary);
}

.admin-topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-topbar .nav-user {
    color: var(--text);
    font-size: 14px;
    opacity: 0.8;
}

.admin-topbar .btn-logout {
    color: var(--text-light);
    border-color: var(--border);
    opacity: 1;
}

.admin-topbar .btn-logout:hover {
    color: var(--text);
    border-color: var(--text-light);
    background: var(--table-hover);
}

/* ===== メインコンテンツ ===== */
.main-content {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
}

.admin-body .main-content {
    flex: 1;
}

@media (max-width: 767px) {
    /* サイドバーをオフスクリーン化、ハンバーガーで開閉 */
    .admin-sidebar {
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.25s ease-out;
    }
    .admin-sidebar.is-open {
        transform: translateX(0);
    }
    .admin-sidebar-brand {
        padding: 20px 20px 16px;
        text-align: left;
    }
    .admin-sidebar-brand .brand-title {
        justify-content: flex-start;
    }
    .admin-sidebar-nav a {
        justify-content: flex-start;
        padding: 11px 20px;
        border-left: 3px solid transparent;
    }
    .admin-sidebar-nav a i {
        margin-right: 12px;
        font-size: 14px;
    }
    .admin-body {
        margin-left: 0;
    }
    .hamburger {
        display: inline-flex;
    }
    .admin-topbar {
        padding: 12px 16px;
        gap: 10px;
    }
    .admin-topbar .topbar-brand {
        font-size: 14px;
    }
    .admin-topbar .topbar-right {
        gap: 8px;
    }
    .admin-topbar .nav-user {
        display: none;
    }
    .admin-body {
        min-width: 0;
    }
    .main-content {
        overflow-x: hidden;
        max-width: 100%;
    }
}

/* ===== テーブル ===== */
.report-table-wrapper {
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    background: var(--bg-card);
}
@media (min-width: 768px) {
    .report-table-wrapper {
        overflow: hidden;
    }
}
@media (max-width: 767px) {
    .report-table {
        font-size: 13px;
    }
    .report-table thead th,
    .report-table tbody td {
        padding: 8px 10px;
    }
}

.report-table-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--primary);
    background: var(--bg-card);
}

.report-table-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    white-space: nowrap;
}

.report-table {
    margin: 0;
    font-size: 14px;
}

.report-table thead th {
    background: var(--table-header-bg);
    color: var(--text);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-color: var(--border);
    white-space: nowrap;
}

.report-table tbody td {
    padding: 10px 16px;
    vertical-align: middle;
    border-color: var(--border);
    white-space: nowrap;
}

.report-table tbody tr:nth-child(even) {
    background: var(--table-stripe);
}

.report-table tbody tr:hover {
    background: var(--table-hover);
}

.btn-edit {
    color: var(--primary);
    background: none;
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: var(--primary);
    color: var(--text-on-primary);
}

/* ===== 土日・祝日・休日行 ===== */
.report-table tbody tr.row-saturday td,
.report-table tbody tr.row-saturday th {
    background-color: #e8f4fd !important;
}
.report-table tbody tr.row-saturday:hover td,
.report-table tbody tr.row-saturday:hover th {
    background-color: #d4ecfa !important;
}

.report-table tbody tr.row-sunday td,
.report-table tbody tr.row-sunday th,
.report-table tbody tr.row-holiday td,
.report-table tbody tr.row-holiday th {
    background-color: #fde8e8 !important;
}
.report-table tbody tr.row-sunday:hover td,
.report-table tbody tr.row-sunday:hover th,
.report-table tbody tr.row-holiday:hover td,
.report-table tbody tr.row-holiday:hover th {
    background-color: #fad4d4 !important;
}

.report-table tbody tr.row-blocked td,
.report-table tbody tr.row-blocked th {
    opacity: 0.7;
}

.badge-holiday {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #f8d7da;
    color: #721c24;
}

.holiday-indicator {
    font-size: 10px;
    color: #c0392b;
    margin-left: 2px;
}

/* ===== モーダル ===== */
.modal-content {
    border-radius: 12px;
    overflow: hidden;
    border: none;
}

.modal-header {
    background: var(--bg-header);
    color: var(--text-on-primary);
    border-bottom: none;
    padding: 16px 24px;
}

.modal-header .modal-title {
    font-weight: bold;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-label {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text);
}

.modal-body .form-control,
.modal-body .form-select {
    border-radius: 8px;
    border-color: var(--border);
    height: 44px;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

.theme-admin .modal-body .form-control:focus,
.theme-admin .modal-body .form-select:focus {
    box-shadow: 0 0 0 3px rgba(92, 61, 46, 0.1);
}

.modal-body textarea.form-control {
    height: auto;
}

.modal-footer {
    justify-content: center;
    border-top: 1px solid var(--border);
    padding: 16px 24px;
}

.btn-submit {
    padding: 10px 48px;
    border-radius: 8px;
    font-weight: bold;
    border: none;
    background: var(--primary);
    color: var(--text-on-primary);
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background: var(--primary-light);
    color: var(--text-on-primary);
}

/* ===== 月選択 ===== */
.month-select {
    border-color: var(--border);
    border-radius: 8px;
    padding: 6px 36px 6px 12px;
    font-weight: 600;
    color: var(--text);
}

.month-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 80, 22, 0.1);
}

/* ===== バッジ ===== */
.paid-leave-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    background: var(--table-header-bg);
    color: var(--primary);
    line-height: 1.6;
    text-align: left;
}

.trip-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
}

/* ===== エラー画面 ===== */
.error-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.error-card {
    text-align: center;
    max-width: 420px;
    padding: 48px 32px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.error-card .error-icon {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 16px;
}

/* ===== ユーザーリスト（管理者） ===== */
.user-list-wrapper {
    max-width: 700px;
    margin: 24px auto;
    padding: 0 20px;
}

/* ===== 日報モーダル：日付バッジ ===== */
.modal-date-badge {
    text-align: center;
    padding: 10px 16px;
    margin-bottom: 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    background: var(--table-header-bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

/* ===== 日報モーダル：時間入力 ===== */
.time-entry {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.time-entry label {
    margin-right: 10px;
    width: 60px;
    text-align: right;
}

.time-entry div {
    display: flex;
    align-items: center;
}

.time-entry select {
    width: 100px;
    margin: 0 5px;
    font-size: 24px;
}

.time-entry span {
    margin: 0 5px;
}

/* ===== 日報モーダル：カテゴリ ===== */
.main-category {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
}

.sub-category {
    display: flex;
    justify-content: space-around;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.sub-category label {
    width: 150px;
    text-align: left;
}

.sub-category-item {
    display: inline-block;
    width: 30%;
    padding: 5px;
}

.main-category label,
.sub-category label,
.main-category-checkbox,
.sub-category input[type="checkbox"] {
    font-size: 18px;
}

.main-category-checkbox,
.sub-category input[type="checkbox"] {
    margin-right: 3px;
    width: 18px;
    height: 18px;
}

/* ===== 有休情報 ===== */
.paid-leave-box {
    text-align: left;
}

.paid-leave-label {
    display: inline-block;
    width: 7em;
}

/* ===== レスポンシブ ===== */
@media (max-width: 767px) {
    .report-table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .login-body {
        padding: 24px 20px;
    }

    .main-content {
        padding: 0 12px;
    }

    .sub-category {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .sub-category label {
        width: 120px;
        text-align: left;
    }
}

/* ===== ダッシュボード ===== */
.dashboard-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.dashboard-card-alert {
    border: 2px solid #e74c3c;
}

.dashboard-card-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.dashboard-card-value {
    font-size: 36px;
    font-weight: bold;
    color: var(--text);
    line-height: 1.2;
}

.dashboard-card-value small {
    font-size: 16px;
    font-weight: 600;
    margin-left: 2px;
}

.dashboard-card-label {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== カレンダーグリッド ===== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-header {
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 4px;
    color: var(--text-light);
}

.calendar-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    min-height: 60px;
}

.calendar-cell:hover:not(.calendar-cell-empty):not(.calendar-cell-future) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.calendar-cell-empty {
    cursor: default;
}

.calendar-day {
    font-size: 16px;
    font-weight: 600;
}

.calendar-count {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

.calendar-cell-complete {
    background: #d4edda;
    color: #155724;
}

.calendar-cell-complete .calendar-count {
    color: #155724;
}

.calendar-cell-partial {
    background: #fff3cd;
    color: #856404;
}

.calendar-cell-partial .calendar-count {
    color: #856404;
}

.calendar-cell-missing {
    background: #f8d7da;
    color: #721c24;
}

.calendar-cell-missing .calendar-count {
    color: #721c24;
}

.calendar-cell-future {
    background: var(--table-stripe);
    color: var(--text-light);
    cursor: default;
    opacity: 0.5;
}

.calendar-cell-sun .calendar-day {
    color: #c0392b;
}

.calendar-cell-sat .calendar-day {
    color: #2980b9;
}

.calendar-cell-holiday {
    border: 2px solid #c0392b !important;
}

.calendar-holiday-name {
    font-size: 8px;
    color: #c0392b;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.calendar-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-light);
}

.calendar-legend-box {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.calendar-legend-box.calendar-cell-holiday {
    background: #fff;
    border: 2px solid #c0392b !important;
}

/* ===== モバイル用ハンバーガー / オーバーレイ ===== */
.hamburger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    padding: 0;
    margin-right: 4px;
    border-radius: 6px;
}
.hamburger:hover {
    background: var(--table-hover);
}
.hamburger-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    margin: 4px 0;
    border-radius: 1px;
}

.admin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 998;
}
.admin-overlay.is-visible {
    display: block;
}

/* ===== モバイル用バッジ・ヘッダ調整 ===== */
@media (max-width: 575px) {
    .paid-leave-badge {
        font-size: 12px;
        white-space: normal;
        display: block;
        max-width: 100%;
        word-break: break-word;
    }
    .report-table-header {
        padding: 12px 16px;
    }
    .report-table-header h3 {
        font-size: 16px;
        white-space: normal;
    }
    .month-select {
        padding: 4px 28px 4px 8px;
        font-size: 13px;
    }
    /* 中抜け開始: 縦積み */
    #leave_start_wrapper .time-entry {
        flex-direction: column;
        align-items: flex-start;
    }
    #leave_start_wrapper .time-entry > label {
        width: auto;
        text-align: left;
        margin: 0 0 6px 0;
    }
    /* dashboard カレンダー */
    .calendar-cell {
        min-height: 48px;
    }
    .calendar-day {
        font-size: 14px;
    }
    .calendar-count {
        font-size: 10px;
    }
    .calendar-holiday-name {
        display: none;
    }
}

/* モバイル時のみハンバーガー表示（ベース定義より後に置いて優先） */
@media (max-width: 767px) {
    .hamburger {
        display: inline-flex;
    }
}

/* ===== メインカテゴリ：横スクロール + 矢印ボタン ===== */
.main-category-wrapper {
    position: relative;
    margin-bottom: 10px;
}
.main-category-wrapper .main-category {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-behavior: smooth;
    padding: 0 28px;
    margin-bottom: 0;
}
.main-category-wrapper .main-category > div {
    flex: 0 0 auto;
    white-space: nowrap;
}
.cat-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 32px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
    cursor: pointer;
    z-index: 2;
    border-radius: 4px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
    display: none;
    font-size: 18px;
    line-height: 1;
    padding: 0;
}
.cat-scroll-prev { left: 0; }
.cat-scroll-next { right: 0; }
@media (max-width: 767px) {
    .cat-scroll-btn { display: block; }
}

/* ===== 出張区分：囲み + 中央揃え ===== */
.trip-type-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}
.trip-type-box > label {
    display: block;
    margin-bottom: 8px;
    text-align: center;
}
.trip-type-box .form-check-inline {
    margin-right: 1rem;
}
