/* public/css/app.css - 純黑底 / 白字 / 工程橘鏡像源主題 + Canvas (NTU COOL) 排版 */
:root {
  --bg: #000000;
  --surface: #0c0c0c;
  --surface-elevated: #141414;
  --text: #ffffff;
  --text-secondary: #a1a1aa;
  --border: #262626;
  --brand: #f97316;
  --brand-hover: #ea580c;
  --brand-soft: rgba(249, 115, 22, 0.14);
  --success: #10b981;
  --danger: #ef4444;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--brand);
}

.hidden {
  display: none !important;
}

/* Canvas 左右結構 */
.canvas-shell {
  min-height: 100dvh;
  display: flex;
  background: var(--bg);
}

/* 最左側固定 Global Navigation (84px) */
.global-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 84px;
  background: #0a0a0a;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 40;
  padding-bottom: 14px;
}

.global-logo {
  width: 100%;
  height: 68px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  background: var(--brand);
  color: #000000;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-radius: 6px;
}

.global-nav-items {
  width: 100%;
  display: flex;
  flex-direction: column;
  padding-top: 8px;
  flex: 1;
}

.global-nav-btn {
  width: 100%;
  padding: 12px 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.global-nav-btn svg {
  width: 24px;
  height: 24px;
}

.global-nav-btn:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

.global-nav-btn.active {
  background: var(--bg);
  color: var(--brand);
  border-left-color: var(--brand);
}

.global-nav-footer {
  margin-top: auto;
}

.mirror-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brand);
  border: 1px solid var(--brand);
  padding: 3px 6px;
  border-radius: 4px;
}

/* 滑出式課程抽屜 */
.courses-tray {
  position: fixed;
  top: 0;
  left: 84px;
  bottom: 0;
  width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 39;
  display: flex;
  flex-direction: column;
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.75);
}

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

.tray-header h2 {
  margin: 0;
  font-size: 20px;
}

.tray-list {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tray-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
}

.tray-item:hover {
  background: var(--surface-elevated);
  border-color: var(--brand);
  color: var(--brand);
}

.tray-item-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 右側主區域 */
.main-wrapper {
  margin-left: 84px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mirror-banner {
  background: var(--brand-soft);
  border-bottom: 1px solid rgba(249, 115, 22, 0.35);
  color: #fed7aa;
  padding: 7px 24px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mirror-banner strong {
  color: var(--brand);
}

.mirror-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-block;
  flex-shrink: 0;
}

.main-content {
  padding: 24px 32px;
  max-width: 1400px;
  width: 100%;
}

.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.search-input {
  width: 260px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #000000;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.btn-lg {
  width: 100%;
  padding: 12px 18px;
  font-size: 15px;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quota-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* Canvas Dashboard Cards */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 24px;
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.course-card-banner {
  height: 112px;
  background: linear-gradient(135deg, #c2410c 0%, #f97316 55%, #fb923c 100%);
  position: relative;
  padding: 12px 14px;
  display: flex;
  align-items: flex-end;
}

.course-card-banner-tag {
  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.course-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.course-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}

.course-code {
  font-size: 13px;
  color: var(--text-secondary);
}

.course-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Canvas Course Layout (麵包屑 + 左側選單 + 右側內容) */
.course-breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  flex-wrap: wrap;
}

.breadcrumb-back {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.breadcrumb-back:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--text-secondary);
}

.breadcrumb-course {
  color: var(--text);
  font-weight: 600;
}

.breadcrumb-current {
  color: var(--text-secondary);
}

.course-shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.course-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 20px;
}

.course-nav-link {
  text-align: left;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  padding: 9px 12px;
  font-size: 15px;
  color: var(--brand);
  cursor: pointer;
  border-radius: 0 6px 6px 0;
}

.course-nav-link:hover {
  background: var(--surface-elevated);
  text-decoration: underline;
}

.course-nav-link.active {
  color: var(--text);
  font-weight: 700;
  border-left-color: var(--brand);
  background: var(--surface);
}

.course-header-meta {
  margin-bottom: 16px;
}

.course-content-area {
  min-width: 0;
}

.subtab-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.subtab-search-bar .input {
  flex: 1;
  min-width: 220px;
}

.subtab-search-bar span {
  white-space: nowrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.item-row.clickable {
  cursor: pointer;
}

.item-row.clickable:hover {
  border-color: var(--brand);
  background: var(--surface-elevated);
}

.module-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--surface);
}

.module-header {
  padding: 12px 16px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}

.module-items .item-row {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.module-items .item-row:last-child {
  border-bottom: none;
}

.rich-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 14px;
  background: var(--surface);
}

.rich-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--brand);
}

.rich-html {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.rich-html * {
  background-color: transparent !important;
  color: inherit !important;
  border-color: var(--border) !important;
}

.rich-html a {
  color: var(--brand) !important;
}

.rich-html table {
  width: 100% !important;
  border-collapse: collapse;
  margin: 10px 0;
  background: var(--bg) !important;
}

.rich-html th,
.rich-html td {
  border: 1px solid var(--border) !important;
  padding: 8px 12px;
  text-align: left;
}

.rich-html thead th {
  background: var(--surface-elevated) !important;
  font-weight: 700;
}

.rich-html tbody tr:nth-child(even) {
  background: #080808 !important;
}

.rich-html img {
  max-width: 100%;
  height: auto;
}

/* 同步中心 */
.sync-layout {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: start;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  font-size: 18px;
}

.muted {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 2px 0 0;
}

.status-banner {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.status-banner.info {
  background: var(--brand-soft);
  color: #fed7aa;
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.status-banner.ok {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-banner.err {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.proxy-frame-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: 540px;
  background: #ffffff;
}

.proxy-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.sync-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background: var(--surface-elevated);
}

.cool-courses-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cool-course-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.cool-course-option:hover {
  background: var(--surface-elevated);
}

.sync-log-wrap {
  margin-top: 14px;
}

.sync-log-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.sync-log {
  margin: 0;
  background: #050505;
  color: #e4e4e7;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  height: 190px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sm {
  max-width: 420px;
}

.modal-lg {
  max-width: 980px;
  height: 85dvh;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.preview-body {
  flex: 1;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.preview-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.preview-body video {
  max-width: 100%;
  max-height: 100%;
}

.preview-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
}

.empty-card {
  text-align: center;
  padding: 48px 24px;
}

.empty-hint {
  text-align: center;
  padding: 20px;
}

@media (max-width: 960px) {
  .sync-layout {
    grid-template-columns: 1fr;
  }
  .course-shell {
    grid-template-columns: 1fr;
  }
  .course-sidebar {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
  }
}

@media (max-width: 640px) {
  .global-nav {
    width: 64px;
  }
  .main-wrapper {
    margin-left: 64px;
  }
  .courses-tray {
    left: 64px;
    width: calc(100vw - 64px);
  }
  .main-content {
    padding: 16px;
  }
}
