/* CSS Reset & Variables */
:root { 
  --bg: #0b0f14; 
  --fg: #e6eef7; 
  --muted: #8aa3bf; 
  --brand: #5ac8fa;
  --danger: #ff7474;
  --card-bg: #111725;
  --border: #1f2a3a;
  --border-light: #203044;
  --code-bg: #0b1320;
  --code-border: #1e2a41;
  --footer-color: #6e87a6;
  --hint-color: #93acc6;
}

/* Base Styles */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

/* Layout */
.wrap {
  max-width: 920px;
  margin: 40px auto;
  padding: 24px;
}

/* Typography */
h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--fg);
}

.version {
  font-size: 14px;
  font-weight: 500;
  color: var(--brand);
  background: rgba(90, 200, 250, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(90, 200, 250, 0.2);
  margin-left: 12px;
}

/* User Info */
.user-info {
  margin-top: 16px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
}

.user-details {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.plan-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.plan-free {
  background: rgba(142, 142, 147, 0.2);
  color: #8e8e93;
}

.plan-premium {
  background: rgba(90, 200, 250, 0.2);
  color: var(--brand);
}

.plan-enterprise {
  background: rgba(255, 149, 0, 0.2);
  color: #ff9500;
}

.usage-info {
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.expire-notice {
  color: #ff9500;
  font-weight: 500;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.premium-btn {
  background: var(--brand);
  color: #001019;
  text-decoration: none;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.premium-btn:hover {
  background: #4bb3e6;
}

.logout-btn {
  color: var(--danger);
  text-decoration: none;
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: var(--danger);
  color: white;
}

@media (max-width: 768px) {
  .user-details {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .usage-info {
    flex-direction: column;
    gap: 4px;
  }
}

p {
  color: var(--muted);
  margin: 6px 0 18px;
}

.hint {
  font-size: 14px;
  color: var(--hint-color);
  display: block;
  margin-bottom: 8px;
}

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

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
}

/* Grid Layout */
.row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.panel {
  flex: 1 1 360px;
  min-width: 300px;
}

/* Form Elements */
input[type="file"] {
  display: block;
  padding: 12px 0;
  width: 100%;
  color: var(--fg);
  background: transparent;
  border: none;
  cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
  background: var(--brand);
  color: #001019;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 12px;
}

input[type="file"]::-webkit-file-upload-button:hover {
  background: #4bb3e6;
}

/* 파일 입력 스타일 개선 */
input[type="file"] {
  position: relative;
}

input[type="file"]::file-selector-button {
  background: var(--brand);
  color: #001019;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 12px;
}

input[type="file"]::file-selector-button:hover {
  background: #4bb3e6;
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--brand);
  color: #001019;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
  font-size: 14px;
}

.btn:hover {
  background: #4bb3e6;
  transform: translateY(-1px);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn[disabled]:hover {
  background: var(--brand);
  transform: none;
}

.download-btn {
  margin-top: 12px;
  background: #34c759;
  color: white;
}

.download-btn:hover {
  background: #30b350;
}

/* Canvas & Preview */
.preview {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: #0a0e13;
  min-height: 200px;
}

/* 캔버스가 내용이 있을 때만 테두리 표시 */
.preview[width]:not([width="0"]) {
  border-color: var(--brand);
}

.canvas-info {
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
}

/* Details & Code */
details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 8px;
}

details[open] summary {
  margin-bottom: 12px;
}

code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Video Preview Section */
.video-preview-section {
  margin: 20px 0;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.video-preview {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #000;
  margin-top: 8px;
}

.video-placeholder {
  width: 100%;
  min-height: 200px;
  background: var(--code-bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.video-placeholder .hint {
  text-align: center;
  color: var(--muted);
  margin: 0;
}

/* Time Selector inside Video Preview Section */
.video-preview-section .time-selector {
  margin: 16px 0 0 0;
  padding: 12px 0 0 0;
  background: none;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border-light);
}

.video-preview-section .time-selector .hint {
  margin-bottom: 8px;
  font-size: 14px;
}

/* Capture Mode Selection */
.capture-mode-section {
  margin: 20px 0;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 12px;
}

.capture-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.mode-btn {
  position: relative;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.mode-btn:hover {
  border-color: var(--brand);
  color: var(--fg);
}

.mode-btn.active {
  border-color: var(--brand);
  background: rgba(90, 200, 250, 0.1);
  color: var(--brand);
}

.mode-icon {
  font-size: 24px;
}

.mode-label {
  font-size: 12px;
  font-weight: 500;
}

/* Time Selector */
.time-selector {
  margin: 20px 0;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.slider-container {
  margin: 12px 0;
}

.time-slider {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  appearance: none;
  cursor: pointer;
}

.time-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.time-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.time-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--fg);
  font-weight: 500;
}

.time-separator {
  color: var(--muted);
}

.preview-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.btn.small {
  padding: 8px 12px;
  font-size: 12px;
}

.btn.secondary {
  background: var(--muted);
  color: var(--bg);
}

.btn.secondary:hover {
  background: #7a94b0;
}

/* Capture Button */
.capture-button {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 12px 0;
}

/* Hidden Elements */
.hidden {
  display: none !important;
}

/* Footer */
footer {
  margin-top: 40px;
  text-align: center;
}

footer p {
  font-size: 12px;
  color: var(--footer-color);
  margin: 0;
}

/* Status Indicators */
#status {
  font-weight: 500;
  padding: 8px 0;
}

#status.loading {
  color: var(--brand);
}

#status.success {
  color: #34c759;
}

#status.error {
  color: var(--danger);
}

/* Responsive Design */
@media (max-width: 768px) {
  .wrap {
    margin: 20px auto;
    padding: 16px;
  }
  
  h1 {
    font-size: 24px;
  }
  
  .row {
    flex-direction: column;
    gap: 16px;
  }
  
  .panel {
    min-width: auto;
  }
  
  .card {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 12px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  .btn {
    width: 100%;
    text-align: center;
  }
}