/* BNI Education Content Generator - BNI Brand Style */

:root {
  --bni-red: #CC0000;
  --bni-red-dark: #A30000;
  --bni-red-light: #FF3333;
  --bni-gray-dark: #333333;
  --bni-gray-mid: #666666;
  --bni-gray-light: #F5F5F5;
  --bni-gray-border: #E0E0E0;
  --bni-white: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bni-gray-light);
  color: var(--bni-gray-dark);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--bni-white);
  border-bottom: 3px solid var(--bni-red);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  height: 40px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--bni-gray-dark);
  letter-spacing: 0.5px;
}

.header-badge {
  background: var(--bni-red);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

/* ── Main Container ── */
.container.container-wide {
  max-width: 1200px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Step Indicator ── */
.steps {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 36px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bni-gray-mid);
  position: relative;
}

.step.active {
  color: var(--bni-red);
}

.step.done {
  color: var(--bni-gray-mid);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border: 2px solid var(--bni-gray-border);
  background: var(--bni-white);
  flex-shrink: 0;
}

.step.active .step-num {
  background: var(--bni-red);
  color: var(--bni-white);
  border-color: var(--bni-red);
}

.step.done .step-num {
  background: var(--bni-gray-mid);
  color: var(--bni-white);
  border-color: var(--bni-gray-mid);
}

.step-connector {
  width: 40px;
  height: 2px;
  background: var(--bni-gray-border);
  align-self: center;
}

.step-connector.done {
  background: var(--bni-gray-mid);
}

/* ── Cards ── */
.card {
  background: var(--bni-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  margin-bottom: 24px;
}

.card-accent {
  border-left: 4px solid var(--bni-red);
}

/* ── Section 1: Keyword Input ── */
.search-section h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--bni-gray-dark);
  margin-bottom: 6px;
}

.search-section .subtitle {
  font-size: 14px;
  color: var(--bni-gray-mid);
  margin-bottom: 24px;
}

.search-box {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.search-input {
  flex: 1;
  padding: 14px 18px;
  font-size: 16px;
  border: 2px solid var(--bni-gray-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.search-input:focus {
  border-color: var(--bni-red);
}

.search-input::placeholder {
  color: #BBB;
}

.btn {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--bni-red);
  color: var(--bni-white);
}

.btn-primary:hover {
  background: var(--bni-red-dark);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  background: #CCC;
  cursor: not-allowed;
}

.btn-outline {
  background: var(--bni-white);
  color: var(--bni-red);
  border: 2px solid var(--bni-red);
}

.btn-outline:hover {
  background: #FFF5F5;
}

.btn-ghost {
  background: transparent;
  color: var(--bni-gray-mid);
  padding: 10px 16px;
}

.btn-ghost:hover {
  color: var(--bni-gray-dark);
  background: var(--bni-gray-light);
}

/* ── Loading ── */
.loading {
  text-align: center;
  padding: 48px 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bni-gray-border);
  border-top: 4px solid var(--bni-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 15px;
  color: var(--bni-gray-mid);
}

.loading-sub {
  font-size: 13px;
  color: #AAA;
  margin-top: 6px;
}

/* ── Topic Cards ── */
.topics-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topic-card {
  background: var(--bni-white);
  border: 2px solid var(--bni-gray-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.topic-card:hover {
  border-color: var(--bni-red);
  box-shadow: var(--shadow-md);
}

.topic-card.selected {
  border-color: var(--bni-red);
  background: #FFF8F8;
  box-shadow: 0 0 0 1px var(--bni-red);
}

.topic-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bni-red);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.topic-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--bni-gray-dark);
  margin-bottom: 4px;
}

.topic-title-en {
  font-size: 13px;
  color: var(--bni-gray-mid);
  margin-bottom: 12px;
  font-style: italic;
}

.topic-summary {
  font-size: 14px;
  line-height: 1.7;
  color: var(--bni-gray-mid);
  margin-bottom: 12px;
}

.topic-sources {
  font-size: 12px;
  color: #AAA;
}

.topic-sources a {
  color: var(--bni-red);
  text-decoration: none;
}

.topic-sources a:hover {
  text-decoration: underline;
}

.topic-check {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--bni-gray-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.topic-card.selected .topic-check {
  background: var(--bni-red);
  border-color: var(--bni-red);
  color: white;
}

/* ── Actions Bar ── */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}

/* ── Result Section ── */
.result-card {
  background: var(--bni-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.result-header {
  background: linear-gradient(135deg, var(--bni-red) 0%, var(--bni-red-dark) 100%);
  color: white;
  padding: 28px 32px;
  text-align: center;
}

.result-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-header p {
  font-size: 14px;
  opacity: 0.85;
}

.result-files {
  padding: 28px 32px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border: 1px solid var(--bni-gray-border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  transition: background 0.15s;
}

.file-item:hover {
  background: var(--bni-gray-light);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.file-icon.pptx {
  background: #FFF0E6;
  color: #D04A02;
}

.file-icon.md {
  background: #E8F5E9;
  color: #2E7D32;
}

.file-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--bni-gray-dark);
}

.file-meta {
  font-size: 12px;
  color: var(--bni-gray-mid);
  margin-top: 2px;
}

.btn-download {
  padding: 8px 18px;
  font-size: 13px;
}

.drive-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: #F0FFF0;
  border-radius: var(--radius);
  font-size: 13px;
  color: #2E7D32;
  font-weight: 500;
  margin-top: 8px;
}

.drive-status.pending {
  background: #FFF8E1;
  color: #F57F17;
}

/* ── Script Preview ── */
.script-preview {
  margin-top: 24px;
  padding: 24px;
  background: var(--bni-gray-light);
  border-radius: var(--radius);
  border-left: 4px solid var(--bni-red);
}

.script-preview h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--bni-gray-dark);
}

.script-slide {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bni-gray-border);
}

.script-slide:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.script-slide-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--bni-red);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.script-slide-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.script-slide-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--bni-gray-mid);
}

/* ── Editor Layout ── */
.editor-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: var(--bni-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.preview-panel {
  padding: 20px;
  background: var(--bni-gray-light);
  border-right: 1px solid var(--bni-gray-border);
}

.preview-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--bni-red);
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.edit-panel {
  padding: 20px;
}

.edit-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bni-gray-dark);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--bni-red);
}

.edit-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--bni-gray-mid);
  margin-bottom: 4px;
  margin-top: 12px;
}

.edit-label:first-of-type { margin-top: 0; }

.edit-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--bni-gray-border);
  border-radius: 6px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.edit-input:focus { border-color: var(--bni-red); }

.edit-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--bni-gray-border);
  border-radius: 6px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
}

.edit-textarea:focus { border-color: var(--bni-red); }

/* ── Slide Preview (mini) ── */
.slide-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  position: relative;
  overflow: hidden;
  padding: 14px 18px;
  font-size: 9px;
}

.sp-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--bni-red);
}

.sp-accent-bar {
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 4px;
  background: var(--bni-red);
}

.sp-logo-bottom {
  position: absolute;
  bottom: 6px; left: 10px;
  font-size: 8px;
  font-weight: 900;
  color: var(--bni-red);
}

.sp-logo-bottom::after {
  content: 'BNI';
}

.sp-title {
  margin-top: 20%;
  font-size: 16px;
  font-weight: 900;
  color: var(--bni-gray-dark);
  padding-left: 8px;
}

.sp-subtitle {
  font-size: 9px;
  color: var(--bni-gray-mid);
  margin-top: 4px;
  padding-left: 8px;
}

.sp-author-title {
  position: absolute;
  bottom: 26%;
  left: 18px;
  font-size: 7px;
  font-weight: 600;
  color: var(--bni-gray-mid);
}
.sp-author {
  position: absolute;
  bottom: 18%;
  left: 18px;
  background: var(--bni-gray-light);
  padding: 3px 12px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 700;
  color: var(--bni-gray-dark);
}

.sp-slide-title {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--bni-gray-dark);
}

.sp-stat-number {
  font-size: 28px;
  font-weight: 900;
  color: var(--bni-red);
  text-align: center;
  margin-top: 8%;
  width: 50%;
}

.sp-stat-desc {
  font-size: 8px;
  color: var(--bni-gray-mid);
  text-align: center;
  margin-top: 2px;
  width: 50%;
}

.sp-detail-box {
  position: absolute;
  right: 10px; top: 30%; bottom: 15%;
  width: 42%;
  background: var(--bni-gray-light);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 7px;
  color: var(--bni-gray-dark);
  line-height: 1.4;
  overflow: hidden;
}

.sp-key-message {
  background: var(--bni-red);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  margin-top: 10%;
}

.sp-points {
  font-size: 8px;
  color: var(--bni-gray-dark);
  line-height: 1.6;
  margin-top: 6%;
  padding-left: 4px;
}

.sp-points-large {
  font-size: 9px;
  margin-top: 8%;
}

.sp-modules {
  display: flex;
  gap: 4px;
  margin-top: 8%;
}

.sp-module {
  flex: 1;
}

.sp-module-header {
  background: var(--bni-red);
  color: white;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
  padding: 3px;
  border-radius: 3px 3px 0 0;
}

.sp-module-body {
  background: var(--bni-gray-light);
  font-size: 6px;
  padding: 4px;
  border-radius: 0 0 3px 3px;
  line-height: 1.5;
  color: var(--bni-gray-dark);
  min-height: 50px;
}

.sp-actions {
  margin-top: 8%;
  padding-left: 4px;
  width: 50%;
}

.sp-action {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 8px;
  font-weight: 600;
  color: var(--bni-gray-dark);
}

.sp-action-num {
  width: 14px;
  height: 14px;
  background: var(--bni-red);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  flex-shrink: 0;
}

.sp-quote-box {
  position: absolute;
  right: 8px; top: 25%; bottom: 12%;
  width: 42%;
  background: var(--bni-red);
  border-radius: 4px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.sp-quote {
  font-size: 8px;
  font-weight: 700;
  color: white;
  text-align: center;
  line-height: 1.5;
}

.sp-quote-src {
  font-size: 6px;
  color: #FFCCCC;
  margin-top: 4px;
}

/* ── Header Right (user menu) ── */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}
.user-stats {
  font-size: 12px;
  color: #888;
  background: #f5f5f5;
  padding: 3px 10px;
  border-radius: 4px;
}
.header-link {
  font-size: 13px;
  color: #CC0000;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid #CC0000;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}
.header-link:hover {
  background: #CC0000;
  color: #fff;
}

/* ── Flash Messages ── */
.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}
.flash-success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}
.flash-error {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

/* ── Auth Card ── */
.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: #fff;
  border-radius: 12px;
  padding: 40px 32px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.auth-title {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 28px;
}
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.form-input:focus {
  border-color: #CC0000;
}
.btn-primary {
  background: #CC0000;
  color: #fff;
  border: none;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover {
  background: #a00;
}
.btn-block {
  display: block;
  width: 100%;
  margin-top: 8px;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #666;
}
.auth-footer a {
  color: #CC0000;
  text-decoration: none;
  font-weight: 600;
}
.auth-footer a:hover {
  text-decoration: underline;
}

/* ── Admin Dashboard ���─ */
.admin-container {
  max-width: 1000px;
  margin: 0 auto;
}
.admin-title {
  font-size: 24px;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 24px;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-number {
  font-size: 36px;
  font-weight: 900;
  color: #CC0000;
}
.stat-label {
  font-size: 14px;
  color: #666;
  margin-top: 4px;
}
.admin-section-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 12px;
  margin-top: 8px;
}
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 32px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.admin-table thead {
  background: #CC0000;
  color: #fff;
}
.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}
.admin-table td {
  padding: 10px 16px;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.admin-table tbody tr:hover {
  background: #fafafa;
}
.badge-admin {
  background: #CC0000;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.badge-search {
  background: #e3f2fd;
  color: #1565c0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.badge-generate {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .header { padding: 12px 16px; }
  .container { padding: 20px 16px; }
  .card { padding: 20px; }
  .search-box { flex-direction: column; }
  .steps { gap: 0; }
  .step { padding: 8px 10px; font-size: 12px; }
  .step-connector { width: 20px; }
  .admin-stats { grid-template-columns: 1fr; }
  .auth-card { margin: 30px 16px; padding: 28px 20px; }
}
