/* ==========================================================================
   Meta Ads CSV Generator - Modern Swiss Studio Design System (Full Meta Suite)
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-surface-subtle: #1e293b;
  --bg-surface-glass: rgba(17, 24, 39, 0.75);
  
  --border-subtle: #1f293d;
  --border-medium: #334155;
  --border-active: #38bdf8;
  --border-focus: #1877f2;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-meta: #1877f2;
  --accent-meta-hover: #166fe5;
  --accent-meta-light: rgba(24, 119, 242, 0.15);
  
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(24, 119, 242, 0.25);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-subtle: #e2e8f0;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-active: #0284c7;
  --border-focus: #1877f2;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 15px rgba(24, 119, 242, 0.15);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
}

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

.brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1877f2 0%, #06b6d4 100%);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: var(--shadow-glow);
}

.brand-titles h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.badge-portaldesk {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-titles p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Presets Bar */
.presets-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.presets-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.presets-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.preset-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preset-btn:hover {
  background: var(--accent-meta-light);
  border-color: var(--accent-meta);
  color: var(--accent-meta);
  transform: translateY(-1px);
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: var(--bg-surface);
  padding: 0.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: 180px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tab-btn .tab-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.tab-btn.active {
  background: var(--accent-meta);
  color: white;
  box-shadow: var(--shadow-glow);
}

.tab-btn.active .tab-num {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Card Sections */
.card-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition);
}

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

.form-textarea {
  resize: vertical;
  min-height: 85px;
  line-height: 1.45;
}

.input-with-prefix {
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.input-prefix {
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-right: 1px solid var(--border-subtle);
}

.input-with-prefix .form-input {
  border: none;
  background: transparent;
}

.input-with-prefix:focus-within {
  border-color: var(--accent-meta);
  box-shadow: 0 0 0 3px var(--accent-meta-light);
}

/* Accordions for Advanced Meta Settings */
.accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 1.25rem;
  overflow: hidden;
  background: var(--bg-surface-elevated);
}

.accordion-header {
  padding: 0.9rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.12);
  user-select: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}

.accordion-header:hover {
  background: rgba(24, 119, 242, 0.08);
}

.accordion-header .toggle-icon {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  transition: transform 0.2s ease;
}

.accordion.open .toggle-icon {
  transform: rotate(180deg);
}

.accordion-body {
  display: none;
  padding: 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.accordion.open .accordion-body {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* Checkbox & Switch controls */
.checkbox-group {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-meta);
  width: 16px;
  height: 16px;
}

/* Quick Tags */
.quick-tags {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.tag-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.tag-btn:hover {
  background: var(--accent-meta-light);
  color: var(--accent-meta);
  border-color: var(--accent-meta);
}

/* Dynamic Item Cards (AdSets, Ads) */
.item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: var(--transition);
}

.item-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.item-card-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 1rem;
}

.item-index-badge {
  background: var(--accent-meta);
  color: white;
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.item-card-actions {
  display: flex;
  gap: 0.5rem;
}

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

.btn-primary {
  background: var(--accent-meta);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  background: var(--accent-meta-hover);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.btn-accent {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

/* Validation Alerts */
.validation-container {
  margin-bottom: 1.5rem;
}

.validation-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.validation-alert.error {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.validation-alert.warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.validation-alert.info {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #67e8f9;
}

/* CSV Preview Table */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  max-height: 480px;
}

.csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: 'SF Mono', Consolas, Monaco, monospace;
}

.csv-table th {
  position: sticky;
  top: 0;
  background: #0f172a;
  color: var(--accent-cyan);
  text-align: left;
  padding: 0.7rem 0.95rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  z-index: 2;
}

.csv-table td {
  padding: 0.65rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csv-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}

.guide-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.guide-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-meta);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.guide-step-body h4 {
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}

.guide-step-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Footer */
.app-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 1rem;
}
