/* ============================================
   ChatGPT CDK Redeem - Dark Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #131a24;
  --bg-secondary: #1a2332;
  --bg-card: rgba(26, 35, 50, 0.95);
  --bg-input: rgba(19, 26, 36, 0.9);
  --border-color: rgba(48, 54, 61, 0.8);
  --text-primary: #e6edf3;
  --text-secondary: rgba(230, 237, 243, 0.7);
  --text-muted: rgba(230, 237, 243, 0.5);
  --accent-blue: #2f81f7;
  --accent-green: #3fb950;
  --accent-orange: #d29922;
  --accent-red: #f85149;
  --btn-primary: #3b82f6;
  --btn-primary-hover: #2563eb;
  --btn-disabled: #3d4450;
  --btn-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 20px;
}

[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.98);
  --bg-input: #ffffff;
  --border-color: #e1e5ea;
  --text-primary: #1f2328;
  --text-secondary: #4b5563;
  --text-muted: #8c959f;
  --btn-primary: #3b82f6;
  --btn-primary-hover: #2563eb;
  --btn-disabled: #d1d5db;
  --btn-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  --accent-orange: #f59e0b;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  max-width: 1024px;
  margin: 0 auto;
}

/* ============================================
   Header
   ============================================ */
.header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  margin-bottom: 20px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.lang-btn, .theme-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-btn {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-btn:hover, .theme-btn:hover {
  background: var(--border-color);
}

/* ============================================
   Main Card - Single container
   ============================================ */
.main-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.main-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100%;
}

/* ============================================
   Left Panel - How to redeem
   ============================================ */
.left-panel {
  border-right: 1px solid var(--border-color);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header i {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.panel-header h2, .panel-header span {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-body {
  padding: 16px 20px;
}

.step-guide {
  position: relative;
  padding: 12px 14px 12px 16px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.15);
}

.step-guide:last-child {
  margin-bottom: 0;
}

.step-guide::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}

.step-guide.step-green::before { background: var(--accent-green); }
.step-guide.step-blue::before { background: var(--accent-blue); }
.step-guide.step-orange::before { background: var(--accent-orange); }
.step-guide.step-warning::before { background: var(--accent-orange); }

.step-guide h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.step-guide p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.step-guide p:last-child {
  margin-bottom: 0;
}

.step-btn {
  display: inline-block;
  padding: 8px 16px;
  background: var(--btn-primary);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: var(--btn-shadow);
}

.step-btn:hover {
  background: var(--btn-primary-hover);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.step-btn-green {
  background: var(--btn-primary);
}

.step-btn-green:hover {
  background: var(--btn-primary-hover);
}

/* Light mode specific styles */
[data-theme="light"] .step-guide {
  background: rgba(240, 244, 248, 0.8);
}

[data-theme="light"] .step-btn-green:hover {
  background: var(--btn-primary-hover);
}

[data-theme="light"] .input-group {
  background: #ffffff;
  border-color: #e1e5ea;
}

[data-theme="light"] .input-group:focus-within {
  border-color: var(--btn-primary);
  box-shadow: 0 0 0 2px rgba(91, 155, 213, 0.15);
}

[data-theme="light"] .check-btn {
  color: #3b82f6;
}

[data-theme="light"] .check-btn:hover {
  color: #2563eb;
}

[data-theme="light"] .recharge-btn:disabled {
  background: #d1d5db;
  color: #6b7280;
}

[data-theme="light"] .recharge-btn.secondary {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #374151;
}

[data-theme="light"] .recharge-btn.secondary:hover {
  background: #e5e7eb;
  color: #1f2937;
}

/* ============================================
   Right Panel - CDK redeem + Query Task
   ============================================ */
.right-panel {
  display: flex;
  flex-direction: column;
}

.cdk-section {
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.cdk-section .panel-body {
  padding: 20px 24px;
}

.redeem-step {
  display: flex;
     gap: 14px;
  margin-bottom: 24px;
}

.redeem-step:last-of-type {
  margin-bottom: 20px;
}

.step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--btn-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--btn-shadow);
}

.step-content {
  flex: 1;
}

.step-content h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

/* Input Group */
.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 6px;
}

.form-input {
  flex: 1;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  outline: none;
}

.input-group:focus-within {
  border-color: var(--btn-primary);
  box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.15);
}

.check-btn {
  padding: 12px 18px;
  background: transparent;
  border: none;
  color: var(--btn-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.check-btn:hover {
  color: var(--btn-primary-hover);
}

.check-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.input-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Step Result */
.step-result {
  margin-top: 10px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background: rgba(63, 185, 80, 0.15);
  color: var(--accent-green);
}

.alert-error {
  background: rgba(248, 81, 73, 0.15);
  color: var(--accent-red);
}

.alert-info {
  background: rgba(47, 129, 247, 0.15);
  color: var(--btn-primary);
}

/* Confirmation Info */
.confirm-info {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.confirm-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}

.confirm-item:last-child {
  border-bottom: none;
}

.confirm-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.confirm-label i {
  color: var(--btn-primary);
  font-size: 0.75rem;
}

.confirm-value {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Warning Box */
.warning-box {
  background: rgba(210, 153, 34, 0.15);
  color: var(--accent-orange);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

/* Recharge Button */
.recharge-btn {
  width: 100%;
  padding: 16px 20px;
  background: var(--btn-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--btn-shadow);
}

.recharge-btn.align-step {
  width: calc(100% - 42px);
  margin-left: 42px;
}

.recharge-btn:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-2px);
}

.recharge-btn:disabled {
  background: rgba(59, 130, 246, 0.4);
  color: rgba(255, 255, 255, 0.6);
  cursor: not-allowed;
  box-shadow: none;
}

.recharge-btn.secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  margin-top: 12px;
}

.recharge-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Result Panel */
.result-panel {
  text-align: center;
  padding: 20px 0;
}

.result-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.result-icon.success { color: var(--accent-green); }
.result-icon.error { color: var(--accent-red); }

.result-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.result-message {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ============================================
   Query Section - Inside right panel
   ============================================ */
.query-section {
  /* No border-bottom since it's the last section */
}

.query-body {
  padding: 14px 24px;
}

.query-body .input-group {
  margin-bottom: 0;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  text-align: center;
}

.footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9375rem;
  font-weight: 600;
}

.modal-header i {
  margin-right: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content {
  padding: 18px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.modal-btn {
  padding: 8px 18px;
  background: var(--btn-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-btn:hover {
  background: var(--btn-primary-hover);
}

/* History List */
.history-header {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-header-item {
  text-align: center;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
}

.history-item:last-child {
  border-bottom: none;
}

.history-value {
  text-align: center;
  color: var(--text-secondary);
  word-break: break-all;
}

.history-result {
  text-align: center;
  color: var(--accent-green);
  font-weight: 500;
}

.history-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .left-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .header-title {
    font-size: 1.125rem;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 12px;
  }

  .header {
    padding: 14px 18px;
  }

  .header-title {
    font-size: 1rem;
  }

  .header-subtitle {
    font-size: 0.75rem;
  }

  .panel-body {
    padding: 14px 16px;
  }

  .cdk-section .panel-body {
    padding: 16px 18px;
  }

  .query-body {
    padding: 12px 18px;
  }

  .input-group {
    flex-direction: row;
    background: transparent;
    border: none;
    border-radius: 0;
  }

  .form-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    width: 100%;
  }

  .check-btn {
    width: 100%;
    padding: 12px;
    background: var(--btn-primary);
    color: #fff;
    border-radius: var(--radius-md);
  }

  .check-btn:hover {
    color: #fff;
    background: var(--btn-primary-hover);
  }

  [data-theme="light"] .check-btn {
    color: #fff;
  }

  [data-theme="light"] .check-btn:hover {
    color: #fff;
  }

  .history-header,
  .history-item {
    grid-template-columns: 1fr 1fr;
    font-size: 0.6875rem;
  }

  .history-header-item:nth-child(3),
  .history-header-item:nth-child(4),
  .history-value:nth-child(3),
  .history-value:nth-child(4) {
    display: none;
  }

  .redeem-step {
    flex-direction: column;
    gap: 10px;
  }

  .step-number {
    align-self: flex-start;
  }

  .recharge-btn.align-step {
    width: 100%;
    margin-left: 0;
  }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.main-card {
  animation: fadeIn 0.25s ease;
}

.fa-spin {
  animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.redeem-step {
   display: grid !important;
   grid-template-columns: auto 1fr;
   column-gap: 14px;
   align-items: start;
}

.step-number {
   grid-column: 1;
}

.step-content {
   grid-column: 2;
   width: 100%;
}

.input-group {
   display: flex;
   flex-direction: row;
   align-items: center;
   width: 100%;
   gap: 16px;
}

.form-input {
   flex: 1;
   width: 100%;
   min-width: 0;
}

.check-btn {
   flex: 0 0 auto;
   width: auto;
}

.input-group .form-input {
   flex: 1;
   min-width: 0;
}

.input-group .check-btn {
   flex-shrink: 0;
}

/* 입력칸 + 버튼 세로 정렬 맞추기 + 왼쪽부터 꽉 */
.input-group{
    display: flex;
    align-items: stretch;   /* 높이를 서로 맞춤 */
    width: 100%;
    gap: 16px;
}

.input-group .form-input{
    flex: 1;
    width: 100%;
    min-width: 0;
    margin: 0 !important;   /* 기본 여백 제거 */
}

.input-group .check-btn{
    flex: 0 0 auto;
    height: auto;
    margin: 0 !important;   /* 기본 여백 제거 */
    display: flex;
    align-items: center;
    justify-content: center;
}
