/* =====================================================
   calendar.css  – 案件カレンダー スタイル
   ===================================================== */

:root {
  --bg:        #0f0f0f;
  --bg2:       #1a1a1a;
  --bg3:       #242424;
  --bg4:       #2e2e2e;
  --border:    #333;
  --border2:   #444;
  --text:      #e8e8e8;
  --text2:     #aaa;
  --text3:     #777;
  --red:       #ff4444;
  --primary:   #6366f1;
  --primary-d: #4f46e5;
  --success:   #10b981;
  --warn:      #f59e0b;
  --radius:    8px;
  --radius-sm: 4px;
  --shadow:    0 4px 20px rgba(0,0,0,0.5);
  --font:      'Noto Sans JP', sans-serif;

  /* イベント色 */
  --ev-ordered:   #6366f1;
  --ev-material:  #f59e0b;
  --ev-draft:     #3b82f6;
  --ev-revision:  #8b5cf6;
  --ev-published: #10b981;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =====================================================
   HEADER
   ===================================================== */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: rgba(15,15,15,0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

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

.header-left h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-left h1 i { color: var(--primary); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.35);
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s;
}
.back-link:hover {
  background: rgba(99,102,241,0.25);
  border-color: rgba(99,102,241,0.6);
  color: #c7d2fe;
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =====================================================
   LAYOUT
   ===================================================== */
#app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 52px);
}

/* =====================================================
   SIDEBAR
   ===================================================== */
#sidebar {
  width: 260px;
  min-width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding-bottom: 24px;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

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

.section-header h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  font-size: 13px;
}
.item-list li:hover { background: var(--bg3); }

.item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-count {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg4);
  padding: 1px 6px;
  border-radius: 10px;
}

.item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.item-list li:hover .item-actions { opacity: 1; }

.item-actions button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
  transition: color .15s;
}
.item-actions button:hover { color: var(--text); }
.item-actions .btn-del:hover { color: var(--red); }

/* プロジェクトリスト */
.project-filter { margin-bottom: 8px; }
.project-filter select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font);
}

.project-list li {
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 8px 10px;
}

.project-list .proj-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-list .proj-title {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-list .proj-client {
  font-size: 11px;
  color: var(--text3);
}

.project-list .proj-dates {
  font-size: 11px;
  color: var(--text3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.proj-date-tag {
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

/* =====================================================
   YT Status
   ===================================================== */
.yt-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 8px;
}
.yt-status.disconnected { background: var(--bg3); color: var(--text3); }
.yt-status.connected { background: rgba(255,68,68,.15); color: #ff8888; }
.yt-status i { font-size: 14px; }

.yt-channel-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.yt-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.yt-channel-name { font-size: 13px; font-weight: 600; }
.yt-channel-id { font-size: 11px; color: var(--text3); }

/* =====================================================
   CALENDAR AREA
   ===================================================== */
#calendar-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

#cal-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

#calTitle {
  font-size: 18px;
  font-weight: 700;
  min-width: 160px;
  text-align: center;
}

#cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

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

#cal-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
}

.cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}

.cal-dow {
  padding: 8px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
}
.cal-dow-sat { color: #60a5fa; }
.cal-dow:first-child { color: #f87171; }

/* セルグリッド */
#cal-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
}

.cal-cell {
  min-height: 100px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px;
  cursor: pointer;
  transition: background .1s;
  overflow: hidden;
  position: relative;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--bg3); }

.cal-cell.other-month { opacity: .35; }
.cal-cell.today .cal-day {
  background: var(--primary);
  color: white;
  border-radius: 50%;
}

.cal-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.cal-cell.sunday .cal-day { color: #f87171; }
.cal-cell.saturday .cal-day { color: #60a5fa; }

/* イベントバー */
.cal-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-event-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: filter .15s;
}
.cal-event-bar:hover { filter: brightness(1.2); }

.cal-event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-event-more {
  font-size: 10px;
  color: var(--text3);
  padding: 1px 4px;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn-icon {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

.btn-sm {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  font-family: var(--font);
}
.btn-sm:active { transform: scale(.95); }

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  font-family: var(--font);
}
.btn-outline:hover { background: var(--bg3); }

.btn-block {
  display: block;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  text-align: center;
  transition: background .15s, transform .1s;
  margin-bottom: 6px;
}
.btn-block:active { transform: scale(.98); }

.btn-yt { background: #cc0000; color: white; }
.btn-yt:hover { background: #aa0000; }

.btn-danger {
  background: rgba(255,68,68,.15);
  border: 1px solid rgba(255,68,68,.3);
  color: #ff8888;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  font-family: var(--font);
}
.btn-danger:hover { background: rgba(255,68,68,.3); }

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}

.modal-wide { max-width: 560px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}

.modal-body input[type="text"],
.modal-body input[type="password"],
.modal-body input[type="date"],
.modal-body textarea,
.modal-body select {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color .15s;
  width: 100%;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--primary);
}
.modal-body textarea { resize: vertical; }

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

.required { color: var(--red); margin-left: 2px; }

.modal-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  font-weight: 400 !important;
  color: var(--text) !important;
  cursor: pointer;
}
.checkbox-label input { width: auto !important; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* =====================================================
   COLOR PICKER
   ===================================================== */
.color-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .15s, border-color .15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: white; transform: scale(1.15); }

/* =====================================================
   DAY MODAL CONTENT
   ===================================================== */
.day-event-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--border2);
  align-items: flex-start;
}

.day-event-icon {
  font-size: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

.day-event-info { flex: 1; }

.day-event-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 3px;
}

.day-event-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.day-event-client {
  font-size: 11px;
  color: var(--text3);
}

.day-event-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.day-event-actions button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
  transition: color .15s;
}
.day-event-actions button:hover { color: var(--text); }
.day-event-actions .btn-del:hover { color: var(--red); }

.no-events {
  text-align: center;
  color: var(--text3);
  padding: 24px;
  font-size: 14px;
}

/* =====================================================
   PROJECT DETAIL MODAL
   ===================================================== */
.detail-section { margin-bottom: 16px; }
.detail-section h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  background: var(--bg3);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.detail-item-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 3px;
}

.detail-item-value {
  font-size: 13px;
  font-weight: 500;
}

.detail-item-value.empty { color: var(--text3); }

.timeline-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.timeline-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}
.timeline-step.done { opacity: 1; }
.timeline-step.pending { opacity: .35; }

/* =====================================================
   HELP
   ===================================================== */
.help-body h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  margin-top: 4px;
  color: var(--primary);
}
.help-body ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.help-body p { font-size: 13px; margin-bottom: 6px; }
.help-body code {
  display: block;
  background: var(--bg3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin: 4px 0;
  color: #a5f3fc;
}

/* =====================================================
   TOAST
   ===================================================== */
#toastContainer {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  animation: toastIn .3s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  max-width: 320px;
  text-align: center;
}

.toast-info    { background: var(--primary); color: white; }
.toast-success { background: var(--success);  color: white; }
.toast-error   { background: var(--red);      color: white; }
.toast-warn    { background: var(--warn);      color: #1a1a1a; }

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

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  #app-body { flex-direction: column; height: auto; overflow: visible; }
  #sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  #calendar-area { padding: 10px; }
  .cal-cell { min-height: 70px; }
  .cal-event-bar span:last-child { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
