/* =========================================================
   MODERN DASHBOARD CSS - INVOICE LAYOUT CONVERTER & MODERNIZER
   ========================================================= */

:root {
  --primary: #c62828;
  --primary-hover: #b71c1c;
  --primary-light: #ffebee;
  --primary-glow: rgba(198, 40, 40, 0.25);
  
  --bg-dark: #0f172a;
  --bg-darker: #090d16;
  --surface-dark: #1e293b;
  --surface-border: #334155;
  
  --bg-light: #f8fafc;
  --surface-light: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(198, 40, 40, 0.35);
  
  --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, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-darker);
  color: #f1f5f9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* NAVBAR / HEADER */
.app-header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #c62828, #e53935);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-version {
  font-size: 0.65rem;
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.5px;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid var(--surface-border);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #64748b;
  color: #ffffff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #e53935);
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(229, 57, 53, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* MAIN LAYOUT */
.dashboard-container {
  display: flex;
  flex: 1;
  padding: 20px 24px;
  gap: 20px;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

/* LEFT CONTROL PANE */
.left-pane {
  flex: 1;
  min-width: 480px;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* UPLOAD CARD */
.control-card {
  background: var(--surface-dark);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-heading h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-heading .step-num {
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

/* DROPZONE */
.dropzone {
  border: 2px dashed #475569;
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  background: rgba(15, 23, 42, 0.4);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(198, 40, 40, 0.08);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin: 0 auto 10px;
  transition: var(--transition);
}

.dropzone:hover .dropzone-icon {
  color: #ef5350;
  transform: scale(1.08);
}

.dropzone-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 4px;
}

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

.sample-buttons-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-sample {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  color: #cbd5e1;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-sample:hover {
  background: rgba(198, 40, 40, 0.15);
  border-color: var(--primary);
  color: #fff;
}

/* STATUS & METADATA BAR */
.status-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.78rem;
}

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

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.tag-badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.tag-badge.warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.tag-badge.info {
  background: rgba(2, 132, 199, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(2, 132, 199, 0.4);
}

/* PROGRESS BAR */
.progress-bar-container {
  height: 4px;
  background: #334155;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
  display: none;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c62828, #ef5350);
  transition: width 0.3s ease;
}

/* JSON EDITOR SECTION */
.editor-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-dark);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--surface-border);
}

.editor-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-toolbar {
  display: flex;
  gap: 6px;
}

.btn-tool {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: #cbd5e1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn-tool:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.json-textarea {
  flex: 1;
  width: 100%;
  min-height: 380px;
  background: #090d16;
  color: #a5f3fc;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 14px;
  border: none;
  outline: none;
  resize: vertical;
}

/* RIGHT PREVIEW PANE */
.right-pane {
  flex: 1.35;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-top-toolbar {
  background: var(--surface-dark);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  width: 34px;
  height: 18px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #475569;
  transition: .3s;
  border-radius: 18px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

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

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

/* TEMPLATE SELECTOR PILL */
.template-selector-pill {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 3px;
  gap: 3px;
}

.btn-template {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-template:hover {
  color: #f1f5f9;
}

.btn-template.active {
  background: linear-gradient(135deg, #b71c1c 0%, #e53935 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(183, 28, 28, 0.4);
}

.btn-template[data-type="customer"].active {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.preview-canvas-wrapper {
  flex: 1;
  background: #1e293b;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  min-height: 700px;
  position: relative;
}

.preview-iframe {
  width: 210mm;
  height: 297mm;
  background: #ffffff;
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  transform-origin: top center;
  transition: transform 0.2s ease;
}

/* SETTINGS MODAL */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-card {
  background: var(--surface-dark);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
}

.close-btn:hover {
  color: #fff;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: #090d16;
  border: 1px solid var(--surface-border);
  color: #fff;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
}

.form-help {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1200px) {
  .dashboard-container {
    flex-direction: column;
  }
  .left-pane {
    max-width: 100%;
    min-width: 100%;
  }
}
