/* ============================================================
   Drone Management System — pastel theme
   ============================================================ */
:root {
  --ink: #3b3b52;            /* main readable text */
  --ink-soft: #6b6b85;
  --card: #ffffff;
  --line: #e7e7f3;
  --accent: #7c83fd;
  --accent-2: #a78bfa;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(124, 131, 253, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f4f3ff 0%, #eef4ff 45%, #effaf4 100%) fixed;
  min-height: 100vh;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

.container { color: var(--ink); }
h2, h3, h4 { color: var(--ink); font-weight: 700; }

/* ---------- Top bar (title + actions) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.topbar-title { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.brand { font-size: 1.5rem; font-weight: 800; color: var(--ink); letter-spacing: 0.01em; }
.brand-sub { font-size: 0.9rem; color: var(--ink-soft); margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.role-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; color: #5b62e0;
  background: rgba(124, 131, 253, 0.14); border: 1px solid rgba(124, 131, 253, 0.3);
  padding: 1px 9px; border-radius: 999px;
}

/* ---------- Buttons ---------- */
.btn { border-radius: 999px; font-weight: 600; border: none; }
.btn-primary { background: linear-gradient(135deg, #8b9cff, #a78bfa); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #7c8cff, #9a78f7); color: #fff; }
.btn-success { background: linear-gradient(135deg, #5eead4, #34d399); color: #07514a; }
.btn-success:hover { filter: brightness(0.97); color: #07514a; }
.btn-warning { background: linear-gradient(135deg, #fde68a, #fbbf24); color: #6b4e00; }
.btn-danger { background: linear-gradient(135deg, #fda4af, #fb7185); color: #fff; }
.btn-secondary { background: #e9e9f5; color: var(--ink); }

/* soft / outline-ish button for nav links */
.btn-soft {
  background: rgba(124, 131, 253, 0.12);
  color: #5b62e0;
  border: 1px solid rgba(124, 131, 253, 0.25);
}
.btn-soft:hover { background: rgba(124, 131, 253, 0.2); color: #4b52d0; }

/* cool logout pill */
.btn-logout {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  color: #fff;
  padding: 8px 20px;
  box-shadow: 0 6px 16px rgba(244, 63, 94, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-logout:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(244, 63, 94, 0.45);
}

/* ---------- Cards / tables ---------- */
.table {
  color: var(--ink);
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table > :not(caption) > * > * { background-color: transparent; color: var(--ink); }
.table thead th {
  background: #f0f1ff;
  color: #51568f;
  border-bottom: 2px solid var(--line);
  font-weight: 700;
}
.table tbody tr:hover > * { background: #f8f9ff; }
.text-muted { color: var(--ink-soft) !important; }

/* ---------- Tabs ---------- */
.nav-tabs { border-bottom: 2px solid var(--line); }
.nav-tabs .nav-link {
  color: var(--ink-soft);
  border: none;
  font-weight: 600;
  border-radius: 12px 12px 0 0;
}
.nav-tabs .nav-link:hover { color: var(--accent); background: rgba(124,131,253,0.08); }
.nav-tabs .nav-link.active {
  color: var(--accent);
  background: var(--card);
  border-bottom: 3px solid var(--accent);
}

/* ---------- Forms ---------- */
.form-control, .form-select {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 10px;
}
.form-control:focus, .form-select:focus {
  background: #fff;
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(124, 131, 253, 0.2);
}
.form-label { color: var(--ink); font-weight: 600; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-content {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  border: none;
  box-shadow: 0 20px 60px rgba(59, 59, 82, 0.25);
}

/* hide the 持出部品 column unless the toggle is on */
.hide-parts .parts-col { display: none; }

/* appointment cards (pickup / return lists — phone friendly) */
.appt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.appt-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 13px; box-shadow: var(--shadow);
}
.appt-card .no { font-size: 0.74rem; font-weight: 700; color: var(--accent); }
.appt-card .machine { font-weight: 700; font-size: 0.98rem; margin: 1px 0 7px; line-height: 1.25; }
.appt-card .row { display: flex; font-size: 0.88rem; margin-bottom: 2px; color: var(--ink); line-height: 1.35; }
.appt-card .row .lbl { flex: 0 0 5em; color: var(--ink-soft); font-weight: 600; }
.appt-card .actions { margin-top: 9px; display: flex; gap: 8px; }
.appt-card .actions .btn { flex: 1; }
@media (max-width: 576px) { .appt-cards { grid-template-columns: 1fr; } }

/* drag handle for 機種一覧 reordering */
.drag-handle { cursor: grab; color: var(--ink-soft); font-size: 1.1rem; user-select: none; }
.drag-handle:active { cursor: grabbing; }

/* 機種一覧 group tables — fixed widths so all 3 category tables align */
.drone-table { table-layout: fixed; width: 100%; }
.drone-table td, .drone-table th { overflow-wrap: break-word; vertical-align: middle; }
/* keep photos inside their fixed-width cell (no overlap with 機種 name) */
.drone-table img.drone-image-preview { max-width: 100%; height: auto; }
/* user page: 画像 機種 ステータス 現場名 申請者 開始日 終了日 アクション */
.drone-table.user-cols th:nth-child(1) { width: 15%; }
.drone-table.user-cols th:nth-child(2) { width: 22%; }
.drone-table.user-cols th:nth-child(3) { width: 9%; }
.drone-table.user-cols th:nth-child(4) { width: 17%; }
.drone-table.user-cols th:nth-child(5) { width: 10%; }
.drone-table.user-cols th:nth-child(6) { width: 9%; }
.drone-table.user-cols th:nth-child(7) { width: 9%; }
.drone-table.user-cols th:nth-child(8) { width: 9%; }
/* 確認 tab tables — shared fixed widths so both tables align */
.confirm-table { table-layout: fixed; width: 100%; }
.confirm-table td, .confirm-table th { overflow-wrap: break-word; vertical-align: middle; }
/* 共通: 予約番号 機種 申請者 現場名 者 日時 */
.confirm-table th:nth-child(1) { width: 7%; }
.confirm-table th:nth-child(2) { width: 19%; }
.confirm-table th:nth-child(3) { width: 9%; }
.confirm-table th:nth-child(4) { width: 15%; }
.confirm-table th:nth-child(5) { width: 9%; }
.confirm-table th:nth-child(6) { width: 11%; }
/* 持出確認待ち: 持出部品 アクション */
.confirm-table.pickup-cols th:nth-child(7) { width: 16%; }
.confirm-table.pickup-cols th:nth-child(8) { width: 14%; }
/* 返却確認待ち: 持出部品 備考 アクション */
.confirm-table.return-cols th:nth-child(7) { width: 8%; }
.confirm-table.return-cols th:nth-child(8) { width: 8%; }
.confirm-table.return-cols th:nth-child(9) { width: 14%; }

/* admin page: ⠿ ID 画像 機種名 購入日 点検日 保険日 ステータス アクション */
.drone-table.admin-cols th:nth-child(1) { width: 3%; }
.drone-table.admin-cols th:nth-child(2) { width: 4%; }
.drone-table.admin-cols th:nth-child(3) { width: 10%; }
.drone-table.admin-cols th:nth-child(4) { width: 34%; }
.drone-table.admin-cols th:nth-child(5) { width: 9%; }
.drone-table.admin-cols th:nth-child(6) { width: 9%; }
.drone-table.admin-cols th:nth-child(7) { width: 9%; }
.drone-table.admin-cols th:nth-child(8) { width: 9%; }
.drone-table.admin-cols th:nth-child(9) { width: 13%; }

/* ---------- Mobile / responsive ---------- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 576px) {
  .container { margin-top: 1.25rem !important; padding-left: 12px; padding-right: 12px; }
  .topbar-title { font-size: 1.4rem; }
  .topbar-actions { width: 100%; }
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .nav-tabs .nav-link { white-space: nowrap; }
  .table { font-size: 0.9rem; }
  .topbar-actions .btn { padding: 5px 11px; font-size: 0.8rem; }
  .brand { font-size: 1.2rem; }
  .brand-sub { font-size: 0.78rem; }
}

/* ---------- Images ---------- */
.drone-image-preview {
  max-width: 100px; max-height: 100px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: #fff;
}
.drone-image-preview.lg { max-width: 200px; max-height: 250px; }

/* ---------- Alerts ---------- */
.alert { border-radius: 12px; border: none; }
.alert-success { background: #e3fbf1; color: #0b7a5e; }
.alert-danger { background: #ffe6ea; color: #c0344b; }

/* ============================================================
   Login page — cool frosted card on animated pastel gradient
   ============================================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #c2c8ff, #d7c2ff 45%, #c2f3e0);
  background-size: 200% 200%;
  animation: drift 16s ease infinite;
}
@keyframes drift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
/* soft floating blobs */
.login-container::before,
.login-container::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.5;
}
.login-container::before { width: 320px; height: 320px; background: #a5b4fc; top: -80px; left: -60px; }
.login-container::after { width: 360px; height: 360px; background: #99f6e4; bottom: -100px; right: -80px; }

.login-box {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 48px 44px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(80, 70, 160, 0.25);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.login-title {
  font-size: 1.7rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: #3b3b6b;
  letter-spacing: 0.02em;
}
.login-sub { text-align: center; color: #6b6b95; margin-bottom: 28px; font-size: 0.9rem; }

.login-box .form-floating { margin-bottom: 16px; }
.login-box .form-control {
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(124, 131, 253, 0.3);
  color: var(--ink);
  height: calc(3.4rem + 2px);
  border-radius: 12px;
}
.login-box .form-floating > label { color: #7a7aa5; }
.login-box .form-control:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(124, 131, 253, 0.25);
}
.btn-login {
  width: 100%;
  padding: 13px;
  font-size: 1.05rem;
  margin-top: 8px;
  background: linear-gradient(135deg, #8b9cff, #a78bfa);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(124, 131, 253, 0.4);
  transition: transform 0.15s ease;
}
.btn-login:hover { transform: translateY(-2px); color: #fff; }
