/* ================================================================
   シフト作成ツール - 共通デザインシステム (Premium UI)
   ================================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Color Palette - HSL based for modern harmony */
  /* Background / Surface */
  --color-bg: #f8fafc; /* slate-50 */
  --color-surface: #ffffff;
  --color-surface-2: #f1f5f9; /* slate-100 */
  --color-surface-hover: #e2e8f0; /* slate-200 */
  
  /* Borders */
  --color-border: #e2e8f0; /* slate-200 */
  --color-border-focus: #c7d2fe; /* indigo-200 */

  /* Text */
  --color-text: #0f172a; /* slate-900 */
  --color-text-secondary: #475569; /* slate-600 */
  --color-text-muted: #94a3b8; /* slate-400 */

  /* Primary (Indigo) */
  --color-primary: #4f46e5; /* indigo-600 */
  --color-primary-hover: #4338ca; /* indigo-700 */
  --color-primary-bg: #e0e7ff; /* indigo-100 */
  --color-primary-text: #3730a3; /* indigo-800 */

  /* Status Colors */
  --color-success: #10b981; /* emerald-500 */
  --color-success-bg: #d1fae5; /* emerald-100 */
  --color-success-text: #065f46; /* emerald-800 */

  --color-danger: #ef4444; /* red-500 */
  --color-danger-hover: #dc2626; /* red-600 */
  --color-danger-bg: #fee2e2; /* red-100 */
  --color-danger-text: #991b1b; /* red-800 */

  --color-warning: #f59e0b; /* amber-500 */
  --color-warning-bg: #fef3c7; /* amber-100 */
  --color-warning-text: #92400e; /* amber-800 */

  --color-info: #3b82f6; /* blue-500 */

  /* Shifts Tags */
  --color-off: #f43f5e; /* rose-500 */
  --color-off-bg: #ffe4e6; /* rose-100 */
  --color-am: #10b981; /* emerald */
  --color-am-bg: #d1fae5; /* emerald-100 */
  --color-pm: #0ea5e9; /* sky */
  --color-pm-bg: #e0f2fe; /* sky-100 */
  --color-other: #8b5cf6; /* violet-500 */
  --color-other-bg: #ede9fe; /* violet-100 */

  /* Shadow & Radius */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;

  /* Layout */
  --header-height: 64px;

  /* Animation */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  /* Subdued radial gradient for premium depth */
  background-image: 
    radial-gradient(circle at top right, rgba(79,70,229,0.03) 0%, transparent 40%),
    radial-gradient(circle at bottom left, rgba(16,185,129,0.02) 0%, transparent 40%);
}
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-hover); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------- Layout Constrains ---------- */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- Common Components ---------- */

/* App Header (Glassmorphism) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.app-header__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.app-header__title-icon { color: var(--color-primary); }
.app-header__nav { display: flex; gap: 16px; align-items: center; }
.app-header__link {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-header__link:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}
.app-header__link--active {
  color: var(--color-primary-text);
  background: var(--color-primary-bg);
}

/* ヘッダー内セパレーター */
.header-divider {
  width: 1px;
  height: 24px;
  background-color: var(--color-text-muted);
  margin: 0;
}

/* Card Surface */
.card-surface {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0,0,0,0.02);
  padding: 20px;
  transition: box-shadow var(--transition-normal);
}
.card-surface:hover {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(0,0,0,0.02);
}

/* Toolbar Surface */
.toolbar-surface {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0,0,0,0.03);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all var(--transition-fast);
}
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--color-primary-bg); outline-offset: 2px; }

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #4338ca 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
}
.btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-primary-hover) 0%, #3730a3 100%);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}
.btn--primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.btn--danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--danger:hover {
  background: var(--color-danger-hover);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
}

.btn--outline {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}
.btn--outline:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-surface-2);
}
.btn--outline:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--sm { padding: 6px 14px; font-size: var(--font-size-xs); }

/* Month Navigator (Pill style) */
.month-nav {
  display: flex;
  align-items: center;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  padding: 4px 6px;
  gap: 8px;
  border: 1px solid var(--color-border);
}
.month-nav__btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.month-nav__btn:hover {
  background: var(--color-primary);
  color: #fff;
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}
.month-nav__label {
  font-size: var(--font-size-base);
  font-weight: 700;
  min-width: 140px;
  text-align: center;
  letter-spacing: 0.02em;
}
.month-nav__today-btn {
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-bg);
  color: var(--color-primary-text);
  border: 1px solid var(--color-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.month-nav__today-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* Legend Chips */
.legend--chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.legend--chips .legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}
.legend--chips .legend__item:hover {
  border-color: var(--color-primary-bg);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.legend__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
/* dot colors */
.legend__dot--employee-ebisu  { background: #2D4FBF; }
.legend__dot--employee-shibuya { background: #E879A8; }
.legend__dot--dev             { background: #ffeaa7; }
.legend__dot--part-ebisu      { background: #2D4FBF; }
.legend__dot--part-shibuya    { background: #E879A8; }
.legend__dot--pharmacist      { background: #2D4FBF; }
.legend__dot--office          { background: #E879A8; }
.legend__dot--off             { background: var(--color-surface-2); border: 1px solid var(--color-border); box-sizing: border-box; }
.legend__dot--am              { background: var(--color-am); }
.legend__dot--pm              { background: var(--color-pm); }
.legend__dot--other           { background: var(--color-warning); }
.legend__dot--ringo           { background: #E73B3B; }
/* stripe legend dots */
.legend__dot--stripe-off      { background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(244,63,94,0.35) 2px, rgba(244,63,94,0.35) 4px); }
.legend__dot--stripe-am       { background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(16,185,129,0.35) 2px, rgba(16,185,129,0.35) 4px); }
.legend__dot--stripe-pm       { background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(14,165,233,0.35) 2px, rgba(14,165,233,0.35) 4px); }
.legend__dot--stripe-dispense { background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(230,126,34,0.40) 2px, rgba(230,126,34,0.40) 4px); }
.legend__dot--stripe-ringo    { background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(231,59,59,0.40) 2px, rgba(231,59,59,0.40) 4px); }
.legend__dot--manual          { background: var(--color-surface); border: 2px solid var(--color-warning); }
/* 半日出勤パターン凡例ドット（店舗フルカラー＋内側ダッシュ枠でフルタイムと区別）*/
.legend__dot--am-part-ebisu   { background: #2D4FBF; outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -3px; }
.legend__dot--pm-part-ebisu   { background: #2D4FBF; outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -3px; }
.legend__dot--am-part-shibuya { background: #E879A8; outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -3px; }
.legend__dot--pm-part-shibuya { background: #E879A8; outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -3px; }

/* Forms (Inputs, Selects) */
.input-field,
select.input-field,
.staff-selector select {
  width: 100%;
  font-family: inherit;
  font-size: var(--font-size-sm);
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: all var(--transition-fast);
  outline: none;
}
.input-field:focus,
.staff-selector select:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.staff-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}
.staff-selector label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.staff-selector select {
  padding: 8px 12px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.4); /* slate-900 / 40% */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 20px 25px -5px rgba(0,0,0,0.1);
  padding: 32px;
  width: min(440px, 90vw);
  transform: translateY(16px) scale(0.98);
  transition: all var(--transition-normal);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal__title { font-size: var(--font-size-lg); font-weight: 700; margin-bottom: 24px; color: var(--color-text); }
.modal__field { margin-bottom: 20px; }
.modal__label { display: block; font-size: var(--font-size-xs); font-weight: 600; color: var(--color-text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Modal Custom Radio */
.modal__radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.modal__radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.modal__radio-label input[type="radio"] { display: none; }
.modal__radio-label:has(input:checked) {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}
.radio-dot { width: 10px; height: 10px; border-radius: 50%; }
.radio-dot--off { background: var(--color-off); }
.radio-dot--am { background: var(--color-am); }
.radio-dot--pm { background: var(--color-pm); }
.radio-dot--other { background: var(--color-other); }
.radio-dot--ringo { background: #E73B3B; }

.modal__actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 32px; }

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toast {
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast--success { box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); border-left: 4px solid var(--color-success); }
.toast--error { box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); border-left: 4px solid var(--color-danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Spinner */
.loader {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile */
@media (max-width: 768px) {
  .app-header { 
    padding: 12px 16px; 
    height: auto; 
    flex-wrap: wrap; 
    gap: 12px;
  }
  .app-header__title { font-size: var(--font-size-base); }
  .app-header .month-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .header-divider { display: none; }
  .month-nav__label { min-width: 110px; font-size: var(--font-size-sm); }
  .toast-container { bottom: 20px; right: 20px; left: 20px; }
  .toast { width: 100%; justify-content: center; }
}

/* Utility */
.badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge--danger { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge--success { background: var(--color-success-bg); color: var(--color-success-text); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* ============================================================
 * カスタム月選択モーダル（全ページ共通）
 * ============================================================ */
.month-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.month-picker-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.month-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.month-picker__year {
  font-size: var(--font-size-lg, 1.1rem);
  font-weight: 700;
  flex: 1;
  text-align: center;
}
.month-picker__year-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-surface-2);
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  color: var(--color-text-secondary);
}
.month-picker__year-btn:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}
.month-picker__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.month-picker__month-btn {
  padding: 10px 4px;
  border-radius: var(--radius-md, 8px);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  text-align: center;
}
.month-picker__month-btn:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}
.month-picker__month-btn.is-current {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.month-picker__footer {
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
 * 条件付き・その他希望リスト（全ページ共通）
 * ============================================================ */
.other-list__items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.other-list__item {
  display: flex;
  align-items: center;
  flex: 0 1 auto; /* 1件でも横幅いっぱいにならず、文字量に合わせる。画面幅を超える場合はガード */
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: var(--color-surface);
  border-left: 4px solid var(--color-border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: all var(--transition-fast);
  max-width: 100%;
}
.other-list__item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.other-list__item--clickable { cursor: pointer; }
.other-list__item--clickable:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.other-list__item--clickable:hover { background: var(--color-surface-hover); border-color: var(--color-primary-bg); }
.other-list__item--off      { border-left-color: var(--color-off); }
.other-list__item--am       { border-left-color: var(--color-am); }
.other-list__item--pm       { border-left-color: var(--color-pm); }
.other-list__item--dispense { border-left-color: #e67e22; }
.other-list__item--ringo    { border-left-color: #E73B3B; }
.other-list__item--other    { border-left-color: var(--color-other); }

.other-list__date {
  font-weight: 700;
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.other-list__staff {
  font-weight: 700;
  white-space: nowrap;
}
.other-list__note {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.other-list__edit-icon { 
  width: 14px; 
  height: 14px; 
  color: var(--color-text-muted); 
  flex-shrink: 0; 
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.other-list__item--clickable:hover .other-list__edit-icon {
  opacity: 1;
}

/* リストからのホバーハイライト（ステータスカラー連動） */
.gantt-table td.day-cell.is-hover-am { background: var(--color-am-bg) !important; box-shadow: inset 0 0 0 2px var(--color-am); z-index: 4; }
.gantt-table td.day-cell.is-hover-pm { background: var(--color-pm-bg) !important; box-shadow: inset 0 0 0 2px var(--color-pm); z-index: 4; }
.gantt-table td.day-cell.is-hover-dispense { background: #fef0e0 !important; box-shadow: inset 0 0 0 2px #e67e22; z-index: 4; }
.gantt-table td.day-cell.is-hover-other { background: var(--color-other-bg) !important; box-shadow: inset 0 0 0 2px var(--color-other); z-index: 4; }
.gantt-table td.day-cell.is-hover-ringo { background: #fee2e2 !important; box-shadow: inset 0 0 0 2px #E73B3B; z-index: 4; }
.gantt-table td.day-cell.is-hover-off { background: var(--color-off-bg) !important; box-shadow: inset 0 0 0 2px var(--color-off, #ef4444); z-index: 4; }
.gantt-table td.day-cell[class*="is-hover-"] .marker { transform: scale(1.1); box-shadow: var(--shadow-sm); }
