/* ============================================================
   Design System — CSS Variables
   ダーク＆クールテーマ
   ============================================================ */
:root {
  --bg-primary: #0a0a0f;
  --bg-surface: #14141e;
  --bg-elevated: #1e1e2e;
  --bg-cell-hover: #282840;

  --accent: #7c6aef;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 106, 239, 0.2);

  --text-primary: #e8e6f0;
  --text-secondary: #8b87a0;
  --text-muted: #4e4a60;

  --today-ring: #7c6aef;
  --today-bg: rgba(124, 106, 239, 0.1);

  /* ユーザー識別カラー */
  --color-mine: #27ae60;
  --color-mine-bg: rgba(39, 174, 96, 0.1);
  --color-partner: #38bdf8;
  --color-partner-bg: rgba(56, 189, 248, 0.1);

  /* カテゴリカラー */
  --shift-early: #3b82f6;
  --shift-late: #f97316;
  --shift-dayoff: #6b7280;
  --shift-half: #eab308;
  --shift-other: #a855f7;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 32px rgba(0, 0, 0, 0.5);

  --font-sans: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ============================================================
   Loading
   ============================================================ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============================================================
   Error
   ============================================================ */
.error-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.error-content { text-align: center; }
.error-icon { font-size: 48px; margin-bottom: 16px; }

.error-message {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.btn-retry {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-retry:active { opacity: 0.7; transform: scale(0.97); }

/* ============================================================
   App Container
   ============================================================ */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 12px 32px;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Header
   ============================================================ */
.header {
  text-align: center;
  padding: 20px 0 8px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================================
   Month Navigation
   ============================================================ */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
  margin-bottom: 8px;
}

.nav-btn {
  background: var(--bg-elevated);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.nav-btn:active {
  background: var(--bg-cell-hover);
  transform: scale(0.92);
}

.month-label {
  font-size: 18px;
  font-weight: 600;
}

/* ============================================================
   Calendar Container
   ============================================================ */
.calendar-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 12px 4px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.04);
}

.weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
  padding: 0 2px;
}

.weekday {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
}

.weekday.sun { color: #ef4444; }
.weekday.sat { color: #3b82f6; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  transition: opacity 0.2s ease, transform 0.2s ease;
  padding: 0 2px;
}

/* ============================================================
   Day Cell
   ============================================================ */
.day-cell {
  aspect-ratio: 1 / 1.35;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 1px 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  min-height: 56px;
}

.day-cell.has-shift:active {
  background: var(--bg-cell-hover);
}

.day-cell.other-month {
  opacity: 0.12;
  pointer-events: none;
}

.day-cell.today {
  background: var(--today-bg);
  box-shadow: inset 0 0 0 1.5px var(--today-ring);
}

.day-cell.sat .day-number { color: #60a5fa; }
.day-cell.sun .day-number { color: #f87171; }

.day-number {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 2px;
  color: var(--text-primary);
}

/* ============================================================
   Shift Labels（テキスト表示）
   ============================================================ */
.shift-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 0 1px;
  flex: 1;
  justify-content: center;
  align-items: center;
}

.shift-tag {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  padding: 2px 2px;
  border-radius: 3px;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 自分 = 緑背景 */
.shift-tag.mine {
  color: #fff;
  background: #27ae60;
}

/* パートナー = 明るいブルー背景 */
.shift-tag.partner {
  color: #fff;
  background: #3498db;
}

/* 公休 = 赤背景（自分・パートナー共通） */
.shift-tag.dayoff {
  color: #fff !important;
  background: #c0392b !important;
}

/* 有給 = 赤背景（自分・パートナー共通） */
.shift-tag.paid-leave {
  color: #fff !important;
  background: #e74c3c !important;
}

/* 半休 = イエロー背景（自分・パートナー共通） */
.shift-tag.half-day {
  color: #222 !important;
  background: #f1c40f !important;
}


/* ============================================================
   Legend
   ============================================================ */
.legend {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.04);
}

.legend-group {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-elevated);
}

.legend-label {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.mine-label { color: var(--color-mine); }
.partner-label { color: var(--color-partner); }

.legend-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 12px;
  height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ============================================================
   Modal (Bottom Sheet)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: backdropIn 0.2s ease;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  padding: 20px 24px 36px;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.4);
  border-top: 1px solid rgba(255,255,255,0.06);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-date {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: var(--bg-elevated);
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close:active { background: var(--bg-cell-hover); }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-person {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.modal-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.modal-avatar.mine { background: var(--color-mine-bg); }
.modal-avatar.partner { background: var(--color-partner-bg); }

.modal-info h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.modal-info h3.mine-name { color: var(--color-mine); }
.modal-info h3.partner-name { color: var(--color-partner); }

.modal-shift-name {
  font-size: 15px;
  font-weight: 600;
}

.modal-shift-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.modal-no-shift {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.modal-divider {
  height: 1px;
  background: var(--bg-elevated);
}
