/* ============================================================================
   DPH Kalkulacka - Style System
   Based on Pencil design: clean, modern, purple accent
   ============================================================================ */

/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap');

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

:root {
  --bg-page: #FFFFFF;
  --bg-card: #F4F4F5;
  --bg-elevated: #E4E4E7;
  --bg-input: #FAFAFA;
  --text-primary: #18181B;
  --text-secondary: #71717A;
  --text-tertiary: #A1A1AA;
  --text-subtle: #52525B;
  --border: #E4E4E7;
  --border-input: #D4D4D8;
  --accent: #8B5CF6;
  --accent-soft: #F5F3FF;
  --teal: #14B8A6;
  --teal-soft: #F0FDF4;
  --orange: #EA580C;
  --orange-soft: #FFF7ED;
  --green: #22C55E;
  --green-soft: #F0FDF4;
  --green-text: #16A34A;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   Header
   ============================================================================ */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  height: 72px;
  background: var(--bg-page);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.header-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
}

.header-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}

.header-version {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
}

/* ============================================================================
   Hero
   ============================================================================ */

.hero {
  text-align: center;
  padding: 40px 48px 48px;
  background: linear-gradient(180deg, #F5F3FF 0%, #FFFFFF 100%);
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 36px;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.hero p {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ============================================================================
   Stepper
   ============================================================================ */

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 120px;
  gap: 0;
  margin-bottom: 8px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.step:hover { opacity: 0.8; }

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.step-circle.active {
  background: var(--accent);
  color: #fff;
}

.step-circle.completed {
  background: var(--green);
  color: #fff;
}

.step-circle.inactive {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.step-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.3s;
}

.step-label.active {
  font-weight: 600;
  color: var(--accent);
}

.step-label.completed {
  color: var(--green-text);
}

.step-line {
  width: 80px;
  height: 2px;
  background: var(--bg-elevated);
  transition: background 0.3s;
}

.step-line.completed {
  background: var(--green);
}

/* ============================================================================
   Content & Cards
   ============================================================================ */

.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 48px;
}

.card {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  margin-bottom: 32px;
  transition: opacity 0.3s, transform 0.3s;
}

.card.hidden {
  display: none;
}

.card h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.card .card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* ============================================================================
   Form Fields
   ============================================================================ */

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.field-input:read-only {
  background: var(--bg-card);
  border-color: transparent;
  cursor: default;
}

.field-input.sm {
  height: 44px;
  font-size: 14px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
}

.input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.input-row .field-group { flex: 1; }

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #7c3aed;
  transform: translateY(-1px);
}

.btn-process {
  width: 100%;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 32px;
}

.btn-process:hover:not(:disabled) {
  background: #7c3aed;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

.btn-process.hidden {
  display: none;
}

.btn-download {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.btn-download.purple { background: var(--accent); }
.btn-download.purple:hover { background: #7c3aed; }
.btn-download.teal { background: var(--teal); }
.btn-download.teal:hover { background: #0d9488; }

/* ============================================================================
   Success Banner
   ============================================================================ */

.success-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 44px;
  background: var(--green-soft);
  border: 1px solid var(--green);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.success-banner.visible { display: flex; }

.success-banner svg { color: var(--green); flex-shrink: 0; }

.success-banner span {
  font-size: 13px;
  font-weight: 500;
  color: var(--green-text);
}

/* ============================================================================
   Dropzone
   ============================================================================ */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 160px;
  border: 2px dashed var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.teal:hover, .dropzone.teal.dragover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.dropzone svg { color: var(--accent); }
.dropzone.teal svg { color: var(--teal); }

.dropzone-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.dropzone input[type="file"] {
  display: none;
}

/* ============================================================================
   File List
   ============================================================================ */

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.file-item svg { color: var(--accent); flex-shrink: 0; }
.file-item.teal svg:first-child { color: var(--teal); }

.file-item-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.file-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  display: flex;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

.file-item-remove:hover { color: #ef4444; }

.file-count {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
}

.file-count.purple { color: var(--accent); }
.file-count.teal { color: var(--teal); }

/* ============================================================================
   Summary Cards
   ============================================================================ */

.summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.summary-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-card.purple { background: var(--accent-soft); }
.summary-card.green { background: var(--teal-soft); }
.summary-card.orange { background: var(--orange-soft); }

.summary-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.summary-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
}

.summary-card.purple .summary-value { color: var(--accent); }
.summary-card.green .summary-value { color: var(--teal); }
.summary-card.orange .summary-value { color: var(--orange); }

/* ============================================================================
   Download Files
   ============================================================================ */

.download-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 12px;
}

.download-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.download-item svg { flex-shrink: 0; }

.download-info {
  flex: 1;
}

.download-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.download-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================================================
   Progress Modal Overlay
   ============================================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

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

.modal-card {
  width: 560px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-page);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

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

.modal-spinner {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
  border-color: rgba(139, 92, 246, 0.2);
  border-top-color: var(--accent);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}

.modal-percent {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  color: var(--accent);
}

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

.modal-detail-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-subtle);
}

.modal-detail-eta {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.modal-separator {
  height: 1px;
  background: var(--border);
}

.modal-cancel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.modal-cancel-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ============================================================================
   Step 4: Preview & Edit
   ============================================================================ */

/* ============================================================================
   Progress Bar
   ============================================================================ */

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: var(--bg-elevated);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 6px;
  transition: width 0.4s ease;
}

.progress-log {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
}

.progress-log-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-log-time {
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.progress-log-item .progress-log-time {
  color: var(--green);
}

.edit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.segment-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 20px;
  gap: 4px;
}

.segment-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.segment-tab.active {
  background: var(--bg-page);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.segment-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--bg-elevated);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.segment-tab.active .segment-tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.preview-layout {
  display: flex;
  gap: 20px;
  min-height: 440px;
}

.invoice-sidebar {
  width: 280px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-y: auto;
  max-height: 500px;
}

.invoice-sidebar-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

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

.invoice-sidebar-item:hover {
  background: var(--bg-card);
}

.invoice-sidebar-item.selected {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.invoice-sidebar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.invoice-sidebar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
}

.invoice-sidebar-amount {
  font-weight: 600;
  color: var(--text-subtle);
}

.invoice-detail {
  flex: 1;
  min-width: 0;
}

.invoice-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.invoice-detail-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pdf-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
}

.edit-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-field-row {
  display: flex;
  gap: 12px;
}

.edit-field {
  flex: 1;
}

.edit-field.highlight .field-input {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ============================================================================
   Footer
   ============================================================================ */

.footer {
  text-align: center;
  padding: 24px 48px;
  background: var(--bg-input);
  border-top: 1px solid var(--border);
}

.footer p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.footer .copy {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============================================================================
   Loading spinner
   ============================================================================ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
  .header { padding: 0 20px; }
  .hero { padding: 32px 20px; }
  .hero h1 { font-size: 28px; }
  .stepper { padding: 0 20px; flex-wrap: wrap; gap: 8px; }
  .step-label { display: none; }
  .step-line { width: 24px; }
  .content { padding: 24px 20px; }
  .card { padding: 24px; max-width: 100% !important; }
  .fields-grid { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: 1fr; }
  .input-row { flex-direction: column; }
  .input-row .field-group { width: 100%; }
  .preview-layout { flex-direction: column; }
  .invoice-sidebar { width: 100%; max-height: 200px; }
  .edit-field-row { flex-direction: column; }
  .modal-card { padding: 24px; }
}
