/* ===================================================================
   Project Management — Red Hat inspired theme
   Brand cues: Red Hat Display / Red Hat Text, Red Hat Red (#ee0000),
   black masthead, generous whitespace, crisp enterprise surfaces.
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@400;500;700;900&family=Red+Hat+Text:wght@400;500;700&display=swap');

:root {
  --rh-red:        #ee0000;
  --rh-red-dark:   #be0000;
  --rh-red-soft:   #fdecec;
  --ink:           #151515;
  --muted:         #4d4d4d;
  --faint:         #6a6e73;
  --line:          #d2d2d2;
  --line-soft:     #ebebeb;
  --bg:            #f2f2f2;
  --surface:       #ffffff;
  --black:         #151515;
  --radius:        4px;
  --display: 'Red Hat Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text:    'Red Hat Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--text);
       background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
       -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: var(--black);
              background-image: radial-gradient(circle at 20% 20%, #2b2b2b 0, var(--black) 60%); }
.login-box  { background: var(--surface); border-radius: var(--radius); padding: 44px 40px;
              width: 400px; box-shadow: 0 24px 64px rgba(0,0,0,0.45);
              border-top: 4px solid var(--rh-red); }
.login-box h1 { font-size: 26px; margin-bottom: 6px; color: var(--ink); font-weight: 900; }
.login-subtitle { color: var(--faint); margin-bottom: 28px; }

/* ── Navbar (black masthead) ── */
.navbar { display: flex; align-items: center; background: var(--black);
          padding: 0 24px; height: 60px; gap: 16px; position: sticky; top: 0; z-index: 100;
          border-bottom: 3px solid var(--rh-red); }
.nav-brand { color: #fff; font-family: var(--display); font-weight: 900; font-size: 17px;
             margin-right: 16px; white-space: nowrap; display: flex; align-items: center; gap: 9px; }
.nav-brand::before { content: ""; width: 12px; height: 22px; background: var(--rh-red);
                     border-radius: 1px; display: inline-block; }
.nav-tabs  { display: flex; gap: 2px; flex: 1; }
.nav-tab   { background: transparent; border: none; color: #d2d2d2; padding: 9px 18px;
             border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 500;
             font-family: var(--text); transition: all .15s; }
.nav-tab:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-tab.active { background: var(--rh-red); color: #fff; }
.nav-user  { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#nav-username { color: #e6e6e6; font-size: 13px; font-weight: 500; }
/* 黑底導覽列上的按鈕：白字白框，hover 反白 */
.navbar .btn-outline { color: #fff; border-color: rgba(255,255,255,.55); }
.navbar .btn-outline:hover { background: #fff; color: var(--ink); border-color: #fff; }

/* ── Main Content ── */
.main-content { padding: 28px 24px; max-width: 1400px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.search-input { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
                font-size: 13px; min-width: 240px; font-family: var(--text); background: #fff; }
.search-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.filter-bar select { padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius);
                     font-size: 13px; background: #fff; font-family: var(--text); }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface);
              border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden;
              box-shadow: 0 1px 3px rgba(21,21,21,.06); }
.data-table th { background: #fafafa; padding: 13px 16px; text-align: left;
                 font-family: var(--text); font-weight: 700; color: var(--faint); font-size: 11px;
                 text-transform: uppercase; letter-spacing: .6px; border-bottom: 2px solid var(--line); }
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #fbf2f2; }
.data-table tbody tr:last-child td { border-bottom: none; }
.date-cell { font-size: 12px; color: var(--faint); white-space: nowrap; }
.empty { text-align: center; color: var(--faint); padding: 44px !important; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 11px; border-radius: 3px;
         font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.badge-blue   { background: #e7f1fa; color: #0066cc; }
.badge-orange { background: #fdf0e1; color: #c46100; }
.badge-gray   { background: #f0f0f0; color: #4d4d4d; }
.role-badge   { padding: 2px 9px; border-radius: 3px; font-size: 11px; font-weight: 700; }
.role-admin   { background: var(--rh-red-soft); color: var(--rh-red-dark); }
.role-sales   { background: #e8f5e9; color: #1e7d32; }
.role-sa      { background: #e7f1fa; color: #0066cc; }
.role-ssp     { background: #f3e8fb; color: #7b2cbf; }

/* ── Cards ── */
.card    { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
           padding: 26px; box-shadow: 0 1px 3px rgba(21,21,21,.06); }
.card-sm { max-width: 440px; }
.card h2, .card h3 { margin-bottom: 18px; font-size: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; font-weight: 700;
                    color: var(--faint); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line);
                       border-radius: var(--radius); font-size: 14px; font-family: var(--text);
                       transition: border-color .15s, box-shadow .15s; background: #fff; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--ink);
                             box-shadow: 0 0 0 1px var(--ink); }
.form-group textarea { resize: vertical; font-family: inherit; }

/* ── Buttons ── */
.btn { padding: 10px 20px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
       font-size: 13px; font-weight: 700; font-family: var(--text); transition: all .15s; line-height: 1.2; }
.btn-primary { background: var(--rh-red); color: #fff; border-color: var(--rh-red); }
.btn-primary:hover { background: var(--rh-red-dark); border-color: var(--rh-red-dark); }
.btn-outline { background: transparent; border: 1px solid var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: #fff; }
.btn-danger  { background: transparent; color: var(--rh-red-dark); border: 1px solid var(--rh-red); }
.btn-danger:hover { background: var(--rh-red); color: #fff; border-color: var(--rh-red); }
.btn-warning { background: #c46100; color: #fff; border-color: #c46100; }
.btn-sm  { padding: 7px 15px; font-size: 12px; }
.btn-xs  { padding: 4px 11px; font-size: 11px; border-radius: 3px; }
.btn-full { width: 100%; padding: 12px; }

/* ── Alerts ── */
.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px;
         border-left: 3px solid transparent; }
.alert-success { background: #e8f5e9; color: #1e7d32; border-left-color: #1e7d32; }
.alert-error   { background: var(--rh-red-soft); color: var(--rh-red-dark); border-left-color: var(--rh-red); }
.hidden { display: none !important; }

/* ── Modals ── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex;
         align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(21,21,21,.55); }
.modal-box { position: relative; background: var(--surface); border-radius: var(--radius);
             width: 90%; max-width: 540px; max-height: 90vh;
             display: flex; flex-direction: column; box-shadow: 0 28px 80px rgba(0,0,0,.4);
             border-top: 4px solid var(--rh-red); }
.modal-large { max-width: 880px; }
.modal-sm    { max-width: 420px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start;
                padding: 22px 26px 16px; border-bottom: 1px solid var(--line-soft); }
.modal-header h2 { font-size: 20px; }
.modal-client-name { font-size: 11px; color: var(--faint); text-transform: uppercase;
                     letter-spacing: .6px; margin-bottom: 3px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer;
               color: var(--faint); padding: 4px 9px; border-radius: var(--radius); line-height: 1; }
.modal-close:hover { background: #f0f0f0; color: var(--ink); }
.modal-body   { padding: 22px 26px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 26px; border-top: 1px solid var(--line-soft);
                display: flex; justify-content: flex-end; gap: 10px; }

/* ── Project Fields (detail modal) ── */
.project-fields { background: #fafafa; border: 1px solid var(--line-soft);
                  border-radius: var(--radius); padding: 18px; margin-bottom: 22px; }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field-row .form-group { flex: 1; min-width: 130px; margin-bottom: 0; }

/* ── Records ── */
.records-header { display: flex; justify-content: space-between; align-items: center;
                  margin-bottom: 16px; }
.records-header h3 { font-size: 16px; }
.record-card { border: 1px solid var(--line-soft); border-left: 3px solid var(--line);
               border-radius: var(--radius); padding: 15px 16px;
               margin-bottom: 12px; background: var(--surface); transition: border-color .15s; }
.record-card:hover { border-left-color: var(--rh-red); }
.record-meta { font-size: 12px; color: var(--faint); margin-bottom: 12px;
               font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; }
.record-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.record-field { min-width: 0; }
.record-field p { margin-top: 5px; font-size: 13px; color: var(--ink); line-height: 1.55;
                  overflow-wrap: anywhere; word-break: break-word; }
.record-person { font-size: 11px; color: var(--faint); margin-left: 6px; }
.empty-text { color: #c4c4c4; font-style: normal; }
.empty-records { text-align: center; color: var(--faint); padding: 32px; }
.record-timestamp { font-size: 12px; color: var(--faint); margin-top: 12px; }

/* ── Role Labels ── */
.role-label { display: inline-block; padding: 2px 9px; border-radius: 3px;
              font-size: 11px; font-weight: 700; }
.role-label.role-sales { background: #e8f5e9; color: #1e7d32; }
.role-label.role-sa    { background: #e7f1fa; color: #0066cc; }
.role-label.role-ssp   { background: #f3e8fb; color: #7b2cbf; }
.active-label { outline: 2px solid currentColor; outline-offset: 1px; }
.role-partner { background: #fdf0e1; color: #c46100; }
.poc-record-body { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── Sub Tabs ── */
.tab-bar  { display: flex; gap: 2px; margin-bottom: 22px;
            border-bottom: 1px solid var(--line); padding-bottom: 0; }
.sub-tab  { background: none; border: none; padding: 11px 18px; cursor: pointer;
            font-size: 13px; font-weight: 500; color: var(--faint); border-bottom: 3px solid transparent;
            margin-bottom: -1px; font-family: var(--text); }
.sub-tab:hover { color: var(--ink); }
.sub-tab.active { color: var(--ink); border-bottom-color: var(--rh-red); font-weight: 700; }
.subtab { display: none; }
.subtab.active { display: block; }

/* ── People List ── */
.add-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.add-row input,
.add-row select { height: 40px; padding: 0 12px; border: 1px solid var(--line);
                  border-radius: var(--radius); font-size: 14px; font-family: var(--text);
                  background: #fff; color: var(--ink); }
.add-row input:focus,
.add-row select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
/* 同列的按鈕與欄位等高、對齊 */
.add-row .btn { height: 40px; display: inline-flex; align-items: center; justify-content: center;
                padding: 0 22px; white-space: nowrap; }
.people-list { list-style: none; }
.people-list li { display: flex; justify-content: space-between; align-items: center;
                  gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.people-list li .person-name { flex: 1; }
.people-list li.inactive .person-name { color: #b4b4b4; text-decoration: line-through; }
.team-checks { display: inline-flex; gap: 12px; }
.team-chk { font-weight: 400; font-size: 12px; color: var(--muted);
            display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.team-chk input { accent-color: var(--rh-red); width: 14px; height: 14px; }

/* ── People 拖放版面 ── */
.people-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 880px) { .people-layout { grid-template-columns: 1fr; } }
.people-left { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 76px; }
.team-box { background: var(--surface); border: 1px solid var(--line-soft);
  border-top: 3px solid var(--rh-red); border-radius: var(--radius); padding: 16px; }
.team-box h3 { margin-bottom: 12px; font-size: 16px; }
.team-roster { display: flex; flex-wrap: wrap; gap: 8px; min-height: 70px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 10px; }
.roster-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.roster-chip small { color: var(--faint); font-weight: 700; font-size: 10px; }
.chip-x { border: 0; background: none; cursor: pointer; color: var(--faint);
  font-size: 16px; line-height: 1; padding: 0 3px; }
.chip-x:hover { color: var(--rh-red); }
.people-right { display: flex; flex-direction: column; gap: 18px; }
.role-box h3 { font-size: 16px; margin-bottom: 12px; }
.people-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.person-card { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line-soft); border-left: 3px solid var(--rh-red);
  border-radius: var(--radius); padding: 10px 12px; background: var(--surface); cursor: grab; }
.person-card:active { cursor: grabbing; }
.person-card.inactive { opacity: .5; }
.person-card .pc-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.pc-name { font-weight: 700; }
.acct { font-size: 12px; color: var(--accent); }
.acct.none { color: var(--faint); }
.pc-teams { display: inline-flex; gap: 4px; }
.teamtag { font-size: 10px; font-weight: 700; background: var(--rh-red-soft);
  color: var(--rh-red-dark); border-radius: 3px; padding: 1px 6px; }
.pc-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ── Responsive (手機 / 平板直式) ── */
@media (max-width: 768px) {
  .two-col    { grid-template-columns: 1fr; }
  .record-body, .poc-record-body { grid-template-columns: 1fr; }
  .field-row  { flex-direction: column; align-items: stretch; }
  .field-row .form-group { min-width: 0; }
  .main-content { padding: 16px 12px; }
  .card { padding: 18px 16px; }

  /* 導覽列：改為可換行，分頁佔整列、仍可切換 */
  .navbar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 10px 14px; row-gap: 10px; }
  .nav-brand { margin-right: 0; font-size: 16px; }
  .nav-tabs { display: flex; order: 3; width: 100%; gap: 4px; }
  .nav-tab { flex: 1; text-align: center; padding: 9px 6px; font-size: 13px; }
  .nav-user { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .nav-user .btn { padding: 7px 11px; }

  /* 篩選列：每個元件佔整列、不再橫向排列 */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar > * { width: 100%; }
  .filter-bar > div[style*="margin-left"] { margin-left: 0 !important; display: flex; gap: 8px; }
  .filter-bar > div[style*="margin-left"] .btn { flex: 1; }
  .multi-dropdown, .multi-dropdown-btn { width: 100%; }
  .search-input { min-width: 0; }

  /* 資料表 → 每筆一張卡片（消除左右捲動） */
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .data-table { border: none; box-shadow: none; background: transparent; }
  .data-table thead { display: none; }
  .data-table tbody tr {
    background: var(--surface); border: 1px solid var(--line-soft);
    border-left: 3px solid var(--rh-red); border-radius: var(--radius);
    margin-bottom: 12px; padding: 6px 2px 8px;
    box-shadow: 0 1px 3px rgba(21,21,21,.06);
  }
  .data-table tbody tr:hover { background: var(--surface); }
  /* 卡片標題：用該列的客戶名稱 */
  .data-table tbody tr[data-client]::before {
    content: attr(data-client);
    display: block; font-family: var(--display); font-weight: 700; font-size: 15px;
    color: var(--ink); padding: 8px 14px 6px;
  }
  .data-table td.col-client { display: none; }      /* 客戶已在卡片標題顯示 */
  .data-table td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 7px 14px; border: none; text-align: right;
  }
  .data-table td::before {
    content: attr(data-label); flex: 0 0 42%; text-align: left;
    font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
    color: var(--faint);
  }
  .data-table td.date-cell { color: var(--faint); }
  .data-table td.empty { text-align: center; padding: 28px 14px !important; }
  .data-table td.empty::before { content: ""; display: none; }

  /* 彈窗：更貼合小螢幕 */
  .modal-box { width: 94%; }
  .modal-header, .modal-body, .modal-footer { padding-left: 18px; padding-right: 18px; }
  .modal-footer { flex-wrap: wrap; }
}

/* ── Multi-select Dropdown ── */
.multi-dropdown { position: relative; display: inline-block; }
.multi-dropdown-btn {
  height: 38px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; cursor: pointer;
  font-size: 14px; font-family: var(--text); white-space: nowrap; min-width: 150px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.multi-dropdown-btn:hover { border-color: var(--ink); }
.multi-dropdown-btn.active { border-color: var(--rh-red); background: var(--rh-red-soft); color: var(--rh-red-dark); }
.multi-dropdown-list {
  display: none; position: absolute; top: calc(100% + 4px); left: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(21,21,21,.14); z-index: 999;
  min-width: 170px; padding: 6px 0;
}
.multi-dropdown-list.open { display: block; }
.multi-dropdown-list label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.multi-dropdown-list label:hover { background: #f7f7f7; }
.multi-dropdown-list input[type=checkbox] { accent-color: var(--rh-red); width: 15px; height: 15px; }
