/* portal/styles.css */
/*
Layer0: Design Tokens
Layer1: Base / Reset / Form base   ← 消すな
Layer2: Components (card, filter, modal)
Layer3: App Layout (sidebar, topbar)
Layer4: View-specific (login, location)
LayerX: Legacy (TODO付きで残す)
*/

/* =========================
   Design Tokens
   ========================= */
:root {
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-active: #1d293b;
  --bg-bottom-nav: #ffffff;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-sub: #6b7280;
  --text-invert: #f9fafb;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.1);
  --danger: #ef4444;
  --radius-card: 14px;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-bottom-nav: 0 -4px 20px rgba(15, 23, 42, 0.12);
}


/* =========================
   Base / Reset / Form base 
   ========================= */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans JP", sans-serif;
  color: var(--text-main);
  background: var(--bg-body);
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

.muted {
  font-size: 13px;
  color: #6b7280
}

.hidden {
    display: none !important;
}

.pre-wrap {
  white-space: pre-wrap;
  word-break: break-word;
}

.is-loading {
  opacity: 0.5;
  pointer-events: none;
}


/* =========================
   Components (card, filter, modal)
   ========================= */
/* Card */
/*
.card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 12px 14px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(148, 163, 184, 0.18);
}
*/
.card {
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.06);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.card-actions {
  display: flex;
  gap: 6px;
}

.card-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  opacity: 0.7;
}

.card-icon-btn:hover {
  opacity: 1;
}

.card-icon-btn.danger:hover {
  color: #dc2626;
}

.card-contents {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;

  display: flex;
  flex-direction: column;
  gap: 4px; /* ← ここが効く */
}

/* Filter UI */
.filter-bar {
  position: sticky;
  top: 64px; /* 講師ポータルヘッダの高さに合わせる */
  z-index: 10;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  padding: 12px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 6px 12px;
  border-radius: 999px;

  background: #e5e7eb;
  color: #374151;
  font-size: 13px;
  font-weight: 500;

  border: none;
  cursor: pointer;
}

.filter-pill[data-active="true"] {
  background: var(--accent-soft);
}

.filter-pill .count {
  font-size: 12px;
  opacity: 0.7;
}

.filter-search {
  width: 260px;
  padding: 8px 10px;
  font-size: 13px;

  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
}

/* Form */
.form-label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--text-sub);
  gap: 4px;
  margin-bottom: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 4px;
  align-items: start;
}

.field-label {
  white-space: nowrap;
  color: #6b7280;
}

/* Buttones */
.btn-secondary {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid var(--border-subtle);
    background: #fff;
    color: var(--text-sub);
    gap: 6px;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
}

.badge-plan {
    border-color: rgba(59, 130, 246, 0.35);
    background: var(--accent-soft);
    color: #1d4ed8;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.5);
}

.modal-card {
  position: relative;
  margin: 6vh auto;
  max-width: 480px;
  max-height: 88vh;

  display: flex;
  flex-direction: column;

  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(15,23,42,0.3);
}

.modal-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;   /* ★ここが命 */
}

.modal-row {
  display: flex;
  gap: 10px;
}

.modal-footer {
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

/* Option */
.option-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;

  font-size: 13px;
  cursor: pointer;
}

.option-card input[type="radio"] {
  margin: 0;
}

.option-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
}

.badge-open { background: rgba(34,197,94,.15); }
.badge-draft { background: rgba(234,179,8,.15); }
.badge-closed { background: rgba(100,116,139,.15); }
.badge-canceled { background: rgba(239,68,68,.15); }


/* =========================
   App Layout (sidebar, topbar)
   ========================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-invert);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transform: translateX(0);
    transition: transform 0.2s ease-out;
}


.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}

.sidebar-title {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    line-height: 1.3;
}

.sidebar-title-main { font-weight: 600; }
.sidebar-title-sub { font-size: 11px; opacity: 0.75; }

.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
    margin: 12px 6px 4px;
}

.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-nav-item {
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    opacity: 0.9;
    margin-bottom: 2px;
}

.sidebar-nav-item:hover { background: rgba(15, 23, 42, 0.5); }
.sidebar-nav-item.active { background: var(--bg-sidebar-active); opacity: 1; }

.sidebar-nav-icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    font-size: 11px;
    opacity: 0.7;
    padding: 10px 6px 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.4);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(243, 244, 246, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left { display: flex; flex-direction: column; gap: 2px; }

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-subtitle { font-size: 11px; color: var(--text-sub); }

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

.main-area {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content {
    padding: 18px;
    max-width: 1080px;
    width: 100%;
    margin: 0 auto 90px;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    background: var(--bg-bottom-nav);
    display: flex;
    border-top: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-bottom-nav);
    z-index: 80;
}

.view { display: none; }

.view-active { display: block; }

.section { margin-bottom: 18px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

input,
select,
textarea {
  font-size: 14px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  width: 100%;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* hanging / block は“意味的に”残す */
.field-row.block .field-label {
  margin-bottom: 4px;
}

.field-row.block {
  grid-template-columns: 1fr;
}

.location-filters {
  display: flex;
  gap: 8px;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.sidebar.is-open {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 90;
}

.sidebar-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}


/* =========================
   Responsive (Mobile)
   ========================= */
@media (max-width: 768px) {

  /* Sidebarを消す */
  .sidebar {
    transform: translateX(-100%);
  }

  /* メインを全幅に */
  .main-area {
    margin-left: 0;
  }

  /* Bottom Navを出す */
  .bottom-nav {
    display: flex;
  }

  /* PC前提の余白を調整 */
  .content {
    margin-bottom: 72px; /* bottom-nav分 */
    padding: 14px;
  }
}


/* =========================
   View-specific (login, location)
   ========================= */
/* Login View */
#login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-card {
    max-width: 420px;
    width: 100%;
    background: #fff;
    border-radius: 16px;
    padding: 24px 20px 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.login-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }

.login-subtitle { font-size: 13px; color: var(--text-sub); margin-bottom: 18px; }

.login-tenant {
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px dashed #e5e7eb;
    margin-bottom: 16px;
}

.login-status { font-size: 11px; color: var(--text-sub); margin-top: 10px; }

.login-footer { margin-top: 16px; font-size: 11px; color: var(--text-sub); }






.tenant-id-label { font-size: 11px; color: var(--text-sub); }
.tenant-id-value { font-size: 12px; font-weight: 500; }

.topbar-tenant { text-align: right; font-size: 11px; }

.section-title { font-size: 14px; font-weight: 600; }
.section-sub { font-size: 11px; color: var(--text-sub); }






/* =========================
   Cards
   ========================= */
.btn-secondary {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.card-detail-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: #3b82f6;
  margin-top: 8px;
  padding: 0;
}

.location-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #f9fafb;
  cursor: pointer;
}

.filter-btn:hover {
  background: #e5e7eb;
}

.load-more-btn {
  margin: 12px auto;
  display: block;
}

/* =========================
   Modal Layout
   ========================= */
.modal.hidden {
  display: none;
}




/* =========================
   Modal Components
   ========================= */
.modal-section {
  padding: 14px;
  margin-bottom: 12px;
  background: #f9fafb;
}

.modal-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.conditional-field {
  margin-left: 16px;
  padding-left: 12px;
  border-left: 2px solid #e5e7eb;
}

.conditional-field input {
  font-size: 14px;
  color: var(--text-main);
}

.conditional-field.hidden {
  display: none !important;
}

/* 曜日チェックをグリッドに */
.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 6px;
  margin-bottom: 6px;
}

.weekday-grid label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin: 0;
}

/* ラジオ専用：labelの縦レイアウトを解除 */
.radio-inline,
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.4;
  margin: 0;
}

.radio-inline input,
.checkbox-inline input {
  margin: 0;
}

/* フォームプレビュー表示 */
.form-preview {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  color: #374151;
}

.form-preview.hidden {
  display: none;
}

.form-preview .title {
  font-weight: 600;
  margin-bottom: 4px;
}

.form-preview .row {
  display: flex;
  gap: 6px;
  line-height: 1.5;
}


/* calendar view */
.calendar-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calendar-day {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.calendar-day-header {
  padding: 8px 12px;
  font-weight: 600;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}

.calendar-day-body {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendar-item .time {
  font-size: 0.9rem;
}

.calendar-item .edit {
  background: none;
  border: none;
  cursor: pointer;
}