/* ============================================================================
   CWTTA Tournament Module - Modern Big Typography Theme
   hansanferry / airping 스타일을 참고한 큼직한 카드/타이포 디자인
   ============================================================================ */

:root {
  --primary: #ea580c;        /* 주황 (탁구공/iPing 계열) */
  --primary-dark: #c2410c;
  --primary-soft: #fff7ed;
  --accent: #0f766e;
  --text: #0f172a;
  --text-muted: #64748b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(15,23,42,0.06);
  --shadow-lg: 0 10px 30px rgba(15,23,42,0.10);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body.cwt {
  margin: 0;
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.cwt a { color: inherit; text-decoration: none; }
.cwt a:hover { color: var(--primary); }

/* ===== Header ===== */
.cwt-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.cwt-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.cwt-brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.cwt-brand .pill {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: middle;
}
.cwt-nav { display: flex; gap: 32px; }
.cwt-nav a {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 3px solid transparent;
}
.cwt-nav a.active, .cwt-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--primary);
}
.cwt-user {
  font-size: 15px;
  color: var(--text-muted);
}

/* ===== Container ===== */
.cwt-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ===== Page Title ===== */
.cwt-page-head {
  margin-bottom: 32px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.cwt-page-title {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  margin: 0;
  line-height: 1.1;
}
.cwt-page-sub {
  color: var(--text-muted);
  font-size: 17px;
  margin: 6px 0 0;
}

/* ===== Tournament Cards Grid ===== */
.cwt-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
}
.cwt-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cwt-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.cwt-card-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  width: fit-content;
}
.cwt-card-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  margin: 0;
  color: var(--text);
}
.cwt-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 15px;
}
.cwt-card-meta .row { display: flex; align-items: center; gap: 8px; }
.cwt-card-meta .row strong { color: var(--text); font-weight: 600; }
.cwt-card-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cwt-card-footer .count {
  font-size: 14px;
  color: var(--text-muted);
}
.cwt-card-footer .count b {
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
}

/* ===== Buttons ===== */
.cwt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
}
.cwt-btn:hover { border-color: var(--primary); color: var(--primary); }
.cwt-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.cwt-btn.primary:hover { background: var(--primary-dark); color: #fff; }
.cwt-btn.ghost { background: transparent; }
.cwt-btn.sm { padding: 6px 12px; font-size: 14px; }
.cwt-btn.danger { color: var(--danger); border-color: #fecaca; }
.cwt-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.cwt-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ===== Form ===== */
.cwt-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}
.cwt-field {
  margin-bottom: 24px;
}
.cwt-field label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.cwt-field input[type=text],
.cwt-field input[type=number],
.cwt-field input[type=date],
.cwt-field input[type=datetime-local],
.cwt-field select,
.cwt-field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
}
.cwt-field textarea { min-height: 120px; resize: vertical; }
.cwt-field input:focus, .cwt-field select:focus, .cwt-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(234,88,12,0.15);
}
.cwt-field .help {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
.cwt-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cwt-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
  background: #fff;
}
.cwt-toggle input { margin: 0; }

/* ===== Pool/Roster (drag-drop) ===== */
.cwt-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .cwt-two-col { grid-template-columns: 1fr; } }
.cwt-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.cwt-panel h3 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 800;
}
.cwt-panel .panel-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 12px; }
.cwt-search {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.cwt-list {
  min-height: 200px;
  max-height: 580px;
  overflow-y: auto;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: #fafbfc;
}
.cwt-list.drag-over { background: var(--primary-soft); border-color: var(--primary); }
.cwt-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 15px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: box-shadow .12s, border-color .12s, transform .12s;
}
.cwt-item:active { cursor: grabbing; }
.cwt-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.cwt-item.dragging { opacity: .4; }
.cwt-item .name { font-weight: 700; font-size: 16px; }
.cwt-item .meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.cwt-item .seed {
  font-weight: 800; color: var(--primary);
  background: var(--primary-soft);
  width: 28px; height: 28px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
}

/* ===== Bracket Tournament Tree ===== */
.cwt-bracket {
  display: flex;
  gap: 32px;
  overflow-x: auto;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-height: 600px;
}
.cwt-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  min-width: 220px;
  gap: 12px;
}
.cwt-round-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  text-align: center;
}
.cwt-match {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.cwt-match.done { border-color: var(--success); }
.cwt-match.ready { border-color: var(--info); }
.cwt-match.bye { background: #f1f5f9; opacity: 0.8; }
.cwt-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 4px;
  cursor: move;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.cwt-slot:last-child { border-bottom: none; }
.cwt-slot.winner {
  background: var(--primary-soft);
  font-weight: 700;
  color: var(--primary-dark);
}
.cwt-slot.empty {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}
.cwt-slot .pname { font-weight: 600; }
.cwt-slot .pclub { font-size: 12px; color: var(--text-muted); margin-left: 4px; }
.cwt-slot .pscore {
  font-weight: 800; font-size: 16px;
  min-width: 28px; text-align: right;
  color: var(--text);
}
.cwt-slot.over { background: #fef3c7; }
.cwt-match-btn {
  position: absolute;
  right: -1px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
}

/* ===== Banner / Hero ===== */
.cwt-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #ff8c42 100%);
  color: #fff;
  padding: 56px 32px;
  border-radius: var(--radius);
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}
.cwt-hero h1 {
  font-size: 44px;
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -1px;
}
.cwt-hero p {
  font-size: 19px;
  margin: 0;
  opacity: 0.95;
}

/* ===== Tabs ===== */
.cwt-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.cwt-tab {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .15s ease;
}
.cwt-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.cwt-tab:hover { color: var(--text); }

/* ===== Empty state ===== */
.cwt-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 17px;
  background: #fff;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.cwt-empty .icon {
  font-size: 60px;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* ===== Toast / Flash ===== */
.cwt-flash {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: cwt-fade-in 0.2s ease;
}
.cwt-flash.success { background: var(--success); }
.cwt-flash.error { background: var(--danger); }
@keyframes cwt-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Footer ===== */
.cwt-footer {
  margin-top: 80px;
  padding: 32px 24px;
  background: #fff;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
}

/* ===== Mobile (구식 — _head.php 인라인 CSS 에서 더 강하게 오버라이드) ===== */
@media (max-width: 768px) {
  .cwt-page-title { font-size: 22px; }
  .cwt-hero h1 { font-size: 24px; }
  .cwt-hero { padding: 18px 14px; }
  .cwt-container { padding: 10px 8px 100px; max-width: 100%; }
  .cwt-field-row { grid-template-columns: 1fr; }
  .cwt-nav { display: none; }
}
