﻿/* ===== CSS Variables ===== */
:root {
    --sidebar-width: 3.5rem;
    --sidebar-open-width: 13rem;
    --sidebar-transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 3.5rem;
    --primary: #1569c7;
    --primary-hover: #1258a8;
    --sidebar-bg: #1a3870;
    --bg-page: #f0f2f5;
    --text-main: #555555;
    --text-muted: #888888;
    --border: #e5e7eb;
    --white: #ffffff;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
        Arial, "Noto Sans JP", sans-serif;
    color: var(--text-main);
    background: var(--bg-page);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== App Shell ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    z-index: 200;
    overflow: hidden;
    transition: width var(--sidebar-transition);
}

.sidebar-open .sidebar {
    width: var(--sidebar-open-width);
}

.sidebar-menu-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    padding: 0.875rem 0;
    width: 100%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    transition: color 0.15s;
    flex-shrink: 0;
}

.sidebar-menu-btn:hover {
    color: #fff;
}

.sidebar-menu-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* 展開時：ハンバーガーを右端へ */
.sidebar-open .sidebar-menu-btn {
    justify-content: flex-end;
    padding-right: 0.75rem;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.sidebar-nav-item a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 3rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: background 0.15s, color 0.15s, padding 0.15s;
    border-left: 3px solid transparent;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-open .sidebar-nav-item a {
    justify-content: flex-start;
    padding-left: 1rem;
    gap: 0.75rem;
}

.sidebar-nav-item a svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* ナビテキストラベル */
.nav-label {
    font-size: 0.85rem;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.18s ease, max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.sidebar-open .nav-label {
    opacity: 1;
    max-width: 10rem;
    pointer-events: auto;
    /* 開くとき：テキストはサイドバーが広がってから表示 */
    transition: opacity 0.25s ease 0.18s, max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav-item a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav-item.active a {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-left-color: #fff;
}

.sidebar-bottom {
    margin-top: auto;
    width: 100%;
    padding-bottom: 0.5rem;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--sidebar-transition);
}

.sidebar-open .main-wrapper {
    margin-left: var(--sidebar-open-width);
}

/* ===== Header ===== */
/* ヘッダーは常にフル幅。サイドバーは下に潜り込む */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 300;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    overflow: hidden;
    flex-shrink: 1;
}

.header-logo {
    font-weight: 900;
    font-size: 1.35rem;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
    text-shadow: 0 2px 0 rgba(21, 105, 199, 0.25);
    display: flex;
    align-items: center;
}

.header-logo img {
    display: block;
}

.header-logo:hover {
    text-decoration: none;
    color: var(--primary-hover);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.header-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
    gap: 0.1rem;
    line-height: 1;
    white-space: nowrap;
    transition: color 0.15s;
}

.header-icon-btn:hover {
    color: var(--primary);
}

.header-icon-btn svg {
    width: 1.15rem;
    height: 1.15rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-left: 1px solid var(--border);
    padding-left: 0.875rem;
    margin-left: 0.25rem;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
}

.header-building-icon {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.header-user-detail {
    display: flex;
    flex-direction: column;
    font-size: 0.72rem;
    line-height: 1.35;
    min-width: 0;
    overflow: hidden;
}

.header-company {
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-username {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-chevron {
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== Page Content ===== */
.page-content {
    margin-top: var(--header-height);
    padding: 1.5rem;
    flex: 1;
    background: var(--bg-page);
    min-height: calc(100vh - var(--header-height));
    overflow: auto;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 1.25rem;
}

/* ===== Mobile header menu trigger ===== */
.header-mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.4rem;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.header-mobile-menu-btn:hover {
    color: var(--primary);
}

.header-mobile-menu-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
}

/* ===== Mobile overlay menu ===== */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--white);
    z-index: 600;
    flex-direction: column;
}

.mobile-menu-overlay.is-open {
    display: flex;
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-menu-close {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1;
    transition: color 0.15s;
}

.mobile-menu-close:hover {
    color: var(--primary);
}

.mobile-menu-close svg {
    width: 1rem;
    height: 1rem;
}

.mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
}

.mobile-menu-list li {
    border-bottom: 1px solid var(--border);
}

.mobile-menu-list li a {
    display: block;
    padding: 1.1rem 1.5rem;
    font-size: 1rem;
    color: var(--text-main);
    text-decoration: none;
}

.mobile-menu-list li a:hover {
    background: var(--bg-page);
    text-decoration: none;
}

/* ===== Responsive: narrow screens ===== */
@media (max-width: 768px) {
    .header-desktop-only {
        display: none !important;
    }

    .header-mobile-menu-btn {
        display: flex;
    }
}
  bottom: 0;
  width: 100%;
  white-space: nowrap;
  line-height: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ===== Sidebar Logout Button ===== */
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 3rem;
    color: rgba(255, 255, 255, 0.6);
    background: none;
    border: none;
    border-left: 3px solid transparent;
    overflow: hidden;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sidebar-logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-logout-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.sidebar-open .sidebar-logout-btn {
    justify-content: flex-start;
    padding-left: 1rem;
    gap: 0.75rem;
}

/* ===== Card ===== */
.card {
    background: var(--white);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    background: #fafafa;
}

.card-body {
    padding: 1.5rem 1.25rem;
}

/* ===== Table ===== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
    background: #fafafa;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: #f8faff;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.btn-secondary {
    background: #f3f4f6;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #e9eaec;
    color: var(--text-main);
}

.btn-danger {
    background: #fff;
    color: #dc2626;
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge-master {
    background: #fef3c7;
    color: #92400e;
}

.badge-admin {
    background: #dbeafe;
    color: #1e40af;
}

.badge-member {
    background: #f3f4f6;
    color: #6b7280;
}

/* ===== Alerts ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.4rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.alert-error {
    background: #fff0f0;
    border: 1px solid #fca5a5;
    color: #dc2626;
}

/* ===== Form Controls ===== */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.required {
    color: #dc2626;
    margin-left: 0.15rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.9rem;
    color: var(--text-main);
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 105, 199, 0.12);
}

.form-check-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.form-check-inline input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.field-error {
    display: block;
    color: #dc2626;
    font-size: 0.78rem;
    margin-top: 0.25rem;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ===== Action Buttons in Table ===== */
.action-btns {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btns form {
    margin: 0;
}

/* ===== Logout Confirmation Modal ===== */
.cdlg-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: cdlgFadeIn 0.18s ease;
}

.cdlg-backdrop.is-open {
    display: flex;
}

@keyframes cdlgFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.cdlg-box {
    background: #fff;
    border-radius: 0.75rem;
    padding: 2rem 2rem 1.75rem;
    width: 100%;
    max-width: 360px;
    margin: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: cdlgSlideUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cdlgSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.cdlg-msg {
    font-size: 0.875rem;
    color: #666;
    margin: 0 0 1.5rem;
    line-height: 1.6;
}

.cdlg-actions {
    display: flex;
    flex-direction: row;
    gap: 0.6rem;
}

.cdlg-btn {
    flex: 1;
    padding: 0.7rem;
    border: none;
    border-radius: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    letter-spacing: 0.02em;
}

.cdlg-btn-primary {
    background: #1a3870;
    color: #fff;
    font-weight: 700;
}

.cdlg-btn-primary:hover {
    background: #142d5c;
}

.cdlg-btn-danger {
    background: #c0392b;
    color: #fff;
    font-weight: 700;
}

.cdlg-btn-danger:hover {
    background: #a93226;
}

.cdlg-btn-secondary {
    background: #fff;
    color: #555;
    border: 1px solid #d1d5db;
}

.cdlg-btn-secondary:hover {
    background: #f9fafb;
    border-color: #aaa;
}