:root {
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2828;
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-grid-line: #f3f4f6;
    --color-text-main: #1f2937;
    --color-text-muted: #6b7280;
    
    --header-height: 64px;
    --staff-header-height: 50px;
    
    /* タイムテーブル入れ替え用の変数 */
    --time-column-width: 40px; /* 15分枠の幅 */
    --staff-column-width: 120px; /* 縦軸スタッフ名の幅 */
    --row-height: 80px; /* スタッフ行の高さ */
}

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

body {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ヘッダー */
.app-header {
    height: var(--header-height);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 10;
}

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

.date-display {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 16px;
    min-width: 200px;
    text-align: center;
    cursor: pointer;
    transition: color 0.2s;
}

.date-display:hover {
    color: var(--color-primary);
}

.date-picker {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    border: none;
    pointer-events: none;
}

/* ボタン */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background-color: transparent;
}

.btn:hover {
    background-color: rgba(0,0,0,0.05);
}

.btn-outline {
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
}

.btn-outline:hover {
    background-color: var(--color-bg);
    border-color: #d1d5db;
}

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

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

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

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

.app-main {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

/* メニューパレット（ドラッグ＆ドロップ用） */
.menu-palette {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background-color: var(--color-surface);
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow-x: auto; /* 画面が狭い場合 */
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: grab;
    user-select: none;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.menu-item:active {
    cursor: grabbing;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.menu-item[data-menu="カット"] { background-color: #e3f2fd; color: #1e3a8a; }
.menu-item[data-menu="カラー"] { background-color: #fce4ec; color: #831843; }
.menu-item[data-menu="パーマ"] { background-color: #f1f8e9; color: #14532d; }
.menu-item[data-menu="縮毛矯正"] { background-color: #f3e5f5; color: #581c87; }
.menu-item[data-menu="その他"] { background-color: #fff8e1; color: #78350f; }

.menu-icon {
    font-size: 1.1rem;
}

.timetable-container {
    background-color: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    min-width: 800px;
    border: 1px solid var(--color-border);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background-color: var(--color-surface);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh; /* 画面外に見切れるのを防ぐ */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 24px;
    overflow-y: auto; /* 中身が増えたらスクロールできるようにする */
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
}

.form-group input[type="text"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.time-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-group > div {
    flex: 1;
}

.time-separator {
    margin-top: 24px; /* label分の高さを調整 */
    color: var(--color-text-muted);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    background-color: var(--color-bg);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.footer-right {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

.hidden {
    display: none !important;
}

/* タイムテーブル横スクロール・縦スタッフ対応 */
.timetable {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.timetable-container {
    overflow-x: hidden;
}

.timetable-header-row {
    display: flex;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 15;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    width: var(--staff-column-width);
    min-width: var(--staff-column-width);
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.time-cell {
    flex: 1 1 0;
    min-width: 0;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
}

.time-cell.mark-00 {
    position: relative;
    /* justify-content 等は不要になるため削除 */
}

.time-label {
    position: absolute;
    left: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 5;
    color: var(--color-text-main);
}

.time-cell.mark-15 {
    border-right: 1px dashed var(--color-border);
}

.time-cell.mark-45 {
    border-right: 1px solid var(--color-border);
}

.header-cell {
    height: var(--staff-header-height);
    background-color: #fafafa;
}

.staff-row {
    height: var(--row-height);
}

.timetable-body-scroll {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background-color: white;
}

.timetable-row {
    display: flex;
    border-bottom: 1px solid var(--color-grid-line);
}

.grid-cell {
    flex: 1 1 0;
    min-width: 0;
    cursor: pointer;
    transition: background-color 0.1s;
}

.grid-cell.mark-15 {
    border-right: 1px dashed #e5e7eb; /* 30分経過の点線 */
}

.grid-cell.mark-45 {
    border-right: 1px solid var(--color-border); /* 1時間経過の実線 */
}

.grid-cell:hover {
    background-color: #f0f9ff;
}

/* 予約ブロック用レイヤー */
.appointments-layer {
    position: absolute;
    top: 0;
    left: var(--staff-column-width);
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.staff-row-layer {
    height: var(--row-height);
    position: relative;
    width: 100%;
}

/* 予約ブロック */
.appointment-block {
    position: absolute;
    top: 6px;
    bottom: 6px;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.8rem;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.15s, box-shadow 0.15s;
    border-left: 4px solid rgba(0,0,0,0.15); /* アクセント */
    z-index: 10;
    pointer-events: auto; /* レイヤーを越えてクリック可能に */
}

.appointment-block:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 20;
}

.appt-time {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 2px;
    color: rgba(0, 0, 0, 0.7);
}

.appt-customer {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0px;
}

.appt-menu {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
    color: rgba(0,0,0,0.8);
}

/* 顧客カルテ検索用UI */
.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 50;
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
}
.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--color-grid-line);
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover {
    background-color: #f0f9ff;
}
.customer-preview {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #4b5563;
}
