/* ============================================================
   CRM スタイルシート
   テーマカラー: #94434f（メイン）/ #6c2735（アクセント）
   ============================================================ */

/* CSS変数 */
:root {
    --color-primary:       #94434f;   /* メインカラー */
    --color-primary-light: #b05a67;   /* メインより明るい */
    --color-primary-dark:  #6c2735;   /* アクセント（濃い） */
    --color-bg:            #f4f6f8;
    --color-white:         #ffffff;
    --color-text:          #333333;
    --color-text-light:    #777777;
    --color-border:        #dde1e7;
    --color-success:       #28a745;
    --color-warning:       #e6a817;
    --color-danger:        #dc3545;
    --color-info:          #17a2b8;
    --sidebar-width:       220px;
    --header-height:       60px;
    --radius:              8px;
    --shadow:              0 2px 8px rgba(0,0,0,0.08);
}

/* リセット */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.7;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-light); }
h1, h2, h3, h4 { margin: 0 0 16px; line-height: 1.3; }

/* ============================================================
   ログインページ
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
}

.login-card {
    background: var(--color-white);
    border-radius: 14px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo h1 {
    color: var(--color-primary);
    font-size: 22px;
    font-weight: bold;
    margin: 0;
    letter-spacing: 0.05em;
}

.login-logo p {
    color: var(--color-text-light);
    font-size: 12px;
    margin: 6px 0 0;
}

/* ============================================================
   フォーム部品
   ============================================================ */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 13px;
}

.required {
    color: var(--color-danger);
    margin-left: 3px;
    font-size: 11px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(148, 67, 79, 0.12);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

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

.form-hint {
    font-size: 12px;
    color: var(--color-text-light);
    margin-top: 4px;
}

/* ラジオ・チェックボックス */
.radio-group, .check-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.radio-group label, .check-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
    font-size: 14px;
}

/* ============================================================
   ボタン
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.18s;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1.2;
}

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

.btn-secondary { background: #e9ecef; color: var(--color-text); }
.btn-secondary:hover { background: #dee2e6; color: var(--color-text); }

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

.btn-outline  { background: transparent; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn-outline:hover { background: var(--color-primary); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   アラート
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
    border-left: 4px solid;
}

.alert-danger  { background: #fff0f1; color: #721c24; border-color: var(--color-danger); }
.alert-success { background: #f0fff4; color: #155724; border-color: var(--color-success); }
.alert-warning { background: #fffbf0; color: #856404; border-color: var(--color-warning); }
.alert-info    { background: #f0faff; color: #0c5460; border-color: var(--color-info); }

/* ============================================================
   レイアウト（ログイン後の管理画面）
   ============================================================ */
.crm-layout {
    display: flex;
    min-height: 100vh;
}

/* サイドバー */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary); /* サイドバー背景色 */
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 18px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    margin: 0;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.05em;
    line-height: 1.4;
    color: #fff;
}

.sidebar-header p {
    margin: 4px 0 0;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

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

.sidebar-section {
    padding: 14px 16px 4px;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.6);
    text-transform: uppercase;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 11px 20px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    gap: 8px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: rgba(255,255,255,0.6);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    text-decoration: none;
}

.sidebar-footer a:hover { color: #fff; }

/* メインコンテンツ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    height: var(--header-height);
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.main-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    flex: 1;
}

.main-body { padding: 24px; flex: 1; }

/* ============================================================
   カード
   ============================================================ */
.card {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header h3 { margin: 0; font-size: 14px; font-weight: bold; flex: 1; }
.card-body { padding: 20px; }

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th, .table td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table th {
    font-weight: bold;
    background: #f8f9fa;
    color: var(--color-text-light);
    font-size: 12px;
    white-space: nowrap;
}

.table tbody tr:hover { background: #fdf8f8; }
.table tbody tr:last-child td { border-bottom: none; }

/* 患者一覧の氏名リンク */
.table-link {
    font-size: 16px;
    color: var(--color-primary);
    text-decoration: none;
}
.table-link:hover { text-decoration: underline; }

/* ============================================================
   バッジ
   ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

.badge-primary   { background: #f0e6e8; color: var(--color-primary); }
.badge-success   { background: #d4edda; color: #155724; }
.badge-warning   { background: #fff3cd; color: #856404; }
.badge-danger    { background: #f8d7da; color: #721c24; }
.badge-secondary { background: #e9ecef; color: #6c757d; }

/* ============================================================
   パスワード表示ボックス（患者登録直後に1回だけ表示）
   ============================================================ */
.password-reveal {
    background: #fff8e6;
    border: 2px solid var(--color-warning);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.password-reveal h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #7a5900;
}

.password-value {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 0.12em;
    color: var(--color-text);
    background: #fff;
    padding: 10px 16px;
    border-radius: 4px;
    border: 1px solid #e8d49a;
    display: inline-block;
    margin: 4px 0 12px;
    user-select: all;
}

.password-reveal p {
    margin: 0;
    font-size: 12px;
    color: #7a5900;
    line-height: 1.6;
}

/* ============================================================
   患者詳細ページ: 情報グリッド
   ============================================================ */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0;
}

.info-row {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    min-height: 44px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
    width: 120px;
    flex-shrink: 0;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--color-text-light);
    background: #f8f9fa;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.info-value {
    flex: 1;
    padding: 10px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* ============================================================
   ダッシュボード: 数値カード
   ============================================================ */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--color-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--color-text-light);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--color-primary);
    line-height: 1;
}

.stat-unit {
    font-size: 14px;
    color: var(--color-text-light);
    margin-left: 4px;
}

/* ============================================================
   ページネーション
   ============================================================ */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 4px;
    font-size: 13px;
}

.pagination a {
    color: var(--color-primary);
    border: 1px solid var(--color-border);
    text-decoration: none;
}

.pagination a:hover { background: #f0e6e8; }
.pagination .current { background: var(--color-primary); color: #fff; }
.pagination .dots { color: var(--color-text-light); }

/* ============================================================
   検索フォーム（患者一覧）
   ============================================================ */
.search-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #fafafa;
}

.search-form .form-group { margin-bottom: 0; }
.search-form .form-group label { font-size: 12px; margin-bottom: 4px; }
/* 検索ボタンの高さをinput欄に揃える（line-heightとborderを合わせる） */
.search-form .btn { line-height: 1.5; border: 1px solid transparent; }

/* ============================================================
   ユーティリティ
   ============================================================ */
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-end   { justify-content: flex-end; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.flex-1        { flex: 1; }
.ml-auto       { margin-left: auto; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mb-0          { margin-bottom: 0; }
.mb-16         { margin-bottom: 16px; }
.mb-24         { margin-bottom: 24px; }
.text-muted    { color: var(--color-text-light); }
.text-danger   { color: var(--color-danger); }
.text-success  { color: var(--color-success); }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.text-small    { font-size: 12px; }
.fw-bold       { font-weight: bold; }
.w-100         { width: 100%; }
.nowrap        { white-space: nowrap; }

/* 区切り線 */
.divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 20px 0;
}

/* ============================================================
   ダッシュボード検索
   ============================================================ */
.dashboard-search-wrap {
    max-width: 600px;
    margin: 80px auto 0;
    text-align: center;
}

.dashboard-search-form {
    display: flex;
    gap: 8px;
}

.dashboard-search-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
}

.dashboard-search-input:focus {
    border-color: var(--color-primary);
}

.dashboard-search-btn {
    padding: 14px 24px;
    font-size: 15px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

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

.dashboard-search-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--color-text-light);
    display: flex;
    justify-content: center;
    gap: 8px;
}

.dashboard-search-hint a {
    color: var(--color-primary);
    text-decoration: none;
}

.dashboard-search-hint a:hover {
    text-decoration: underline;
}

/* ============================================================
   患者詳細 — 2カラム並び（次回予約・回数券）
   ============================================================ */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .two-col { grid-template-columns: 1fr; }
}

/* ============================================================
   イベントメモリスト
   ============================================================ */
.event-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.event-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
}

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

.event-date {
    flex-shrink: 0;
    width: 100px;
    font-size: 13px;
    color: var(--color-text-light);
    padding-top: 2px;
}

.event-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
}

.btn-icon-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-text-light);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.4;
    transition: opacity 0.15s;
}

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

.event-delete-form {
    display: flex;
    align-items: center;
}
