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

:root {
  --primary: #f97316;
  --primary-hover: #ea580c;
  --primary-light: #ffedd5;
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --border: #e2e8f0;
  --border-focus: #f97316;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius: 12px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.hidden {
    display: none !important;
}

.popup-container {
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 600px;
  background: var(--bg-app);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Components */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
  background: var(--primary-light);
  color: var(--primary-hover);
  font-weight: 600;
}

/* Forms */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background-color: var(--bg-surface);
  color: var(--text-main);
  transition: var(--transition);
  font-family: inherit;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.input,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg-surface);
  color: var(--text-main);
  transition: var(--transition);
  font-family: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.btn.full-width {
  width: 100%;
}

.btn.primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 2px 4px rgba(249, 115, 22, 0.3);
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(249, 115, 22, 0.4);
}

.btn.secondary {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--bg-app);
  border-color: var(--text-muted);
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

.icon-btn.small {
  padding: 6px;
}

/* Layout Utilities */
.mt-4 {
  margin-top: 16px;
}

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

/* Settings Items */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg-app);
}

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

.setting-label {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

input:checked+.slider {
  background-color: var(--primary);
}

input:focus+.slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

/* Results Area */
.result-area {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

.result-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 250px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.result-header {
  padding: 12px 16px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.result-actions {
  display: flex;
  gap: 4px;
}

#result-content {
  padding: 16px;
  flex-grow: 1;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Markdown Styles inside Result */
#result-content h1, #result-content h2, #result-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 700;
    color: var(--text-main);
}
#result-content p { margin-bottom: 1em; }
#result-content ul, #result-content ol { padding-left: 1.5em; margin-bottom: 1em; }
#result-content code { background: var(--bg-app); padding: 0.2em 0.4em; border-radius: 4px; font-family: monospace; }
#result-content pre { background: var(--bg-app); padding: 1em; border-radius: var(--radius-sm); overflow-x: auto; margin-bottom: 1em; }
