/* ============================================================
   PDF Splitter — style.css
   Clean, professional, desktop-first with mobile support
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --color-primary:       #4f6ef7;
  --color-primary-dark:  #3a56d4;
  --color-primary-light: #eef1fe;
  --color-success:       #2e7d32;
  --color-success-bg:    #e8f5e9;
  --color-success-btn:   #388e3c;
  --color-success-btn-h: #2e7d32;
  --color-danger:        #c62828;
  --color-danger-bg:     #ffebee;
  --color-warning-bg:    #fff8e1;
  --color-warning-border:#ffe082;
  --color-warning-text:  #5d4037;
  --color-text:          #1a1a2e;
  --color-text-muted:    #6b7280;
  --color-border:        #e2e6f0;
  --color-surface:       #ffffff;
  --color-bg:            #f4f6fb;
  --color-header-bg:     #1e2a5e;
  --color-header-text:   #ffffff;
  --radius-sm:           6px;
  --radius-md:           10px;
  --radius-lg:           14px;
  --shadow-card:         0 2px 12px rgba(30, 42, 94, 0.08);
  --shadow-card-hover:   0 4px 24px rgba(30, 42, 94, 0.13);
  --font-sans:           'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-mono:           'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --transition:          0.18s ease;
}

/* ---------- Hidden attribute override ---------- */
[hidden] { display: none !important; }

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

.header-tagline {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.72);
  margin-left: 52px;
}

/* ---------- Main Container ---------- */
.main-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Notices ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.55;
}

.notice--privacy {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning-text);
}

.notice-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  color: #f59e0b;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-card);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Upload Zone ---------- */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  background: var(--color-bg);
}

.upload-zone:hover,
.upload-zone:focus {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  outline: none;
}

.upload-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: block;
}

.upload-primary {
  font-size: 0.97rem;
  color: var(--color-text);
  font-weight: 500;
}

.upload-link {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.upload-secondary {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  margin-top: 5px;
}

/* ---------- File Info Bar ---------- */
.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--color-primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-md);
}

.file-info-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--color-primary);
}

.file-info-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.file-name {
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ---------- Helper Box ---------- */
.helper-box {
  background: #f8f9ff;
  border: 1px solid #dde3ff;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.87rem;
  color: var(--color-text-muted);
  margin-bottom: 18px;
  line-height: 1.6;
}

.helper-examples {
  display: inline-block;
  margin-top: 4px;
}

.helper-examples code {
  font-family: var(--font-mono);
  background: #e8ecff;
  color: var(--color-primary-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.84rem;
}

/* ---------- Rows Table Header ---------- */
.rows-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 44px;
  gap: 10px;
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

/* ---------- Row Item ---------- */
.row-item {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 44px;
  gap: 10px;
  align-items: start;
  padding: 10px 4px;
  border-bottom: 1px solid var(--color-border);
  animation: fadeIn 0.18s ease;
}

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

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

/* Mobile label (hidden on desktop) */
.row-label {
  display: none;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 3px;
}

/* ---------- Inputs ---------- */
.input-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.input-field {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.4;
}

.input-field:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.15);
}

.input-field.input--error {
  border-color: var(--color-danger);
  background: #fff5f5;
}

.input-field.input--error:focus {
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

.input-field-mono {
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.field-error {
  font-size: 0.78rem;
  color: var(--color-danger);
  display: none;
}

.field-error.visible {
  display: block;
}

/* ---------- Remove Row Button ---------- */
.btn-remove-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  flex-shrink: 0;
  margin-top: 2px;
}

.btn-remove-row:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.btn-remove-row svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* ---------- Rows Actions ---------- */
.rows-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: 0 2px 10px rgba(79, 110, 247, 0.35);
}
.btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--secondary {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-color: #c7d2fe;
}
.btn--secondary:hover {
  background: #dde4ff;
  border-color: var(--color-primary);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn--ghost:hover {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: #c0c9d8;
}

.btn--success {
  background: var(--color-success-btn);
  color: #fff;
  border-color: var(--color-success-btn);
}
.btn--success:hover {
  background: var(--color-success-btn-h);
  border-color: var(--color-success-btn-h);
  box-shadow: 0 2px 10px rgba(46, 125, 50, 0.3);
  text-decoration: none;
}

.btn--sm {
  padding: 5px 11px;
  font-size: 0.82rem;
}

.btn--lg {
  padding: 12px 26px;
  font-size: 1rem;
}

/* ---------- Generate Actions ---------- */
.generate-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Error Box ---------- */
.error-box {
  background: var(--color-danger-bg);
  border: 1px solid #ef9a9a;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.88rem;
  color: var(--color-danger);
  margin-bottom: 18px;
  line-height: 1.6;
}

.error-box ul {
  margin: 6px 0 0 18px;
}

.error-box li {
  margin-bottom: 3px;
}

/* ---------- Progress ---------- */
.progress-area {
  margin-top: 20px;
}

.progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #818cf8);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ---------- Download Result ---------- */
.download-result {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  background: var(--color-success-bg);
  border: 1px solid #a5d6a7;
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.download-result-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.download-result-text {
  flex: 1;
  min-width: 180px;
}

.download-result-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-success);
}

.download-result-sub {
  font-size: 0.86rem;
  color: #4caf50;
  margin-top: 2px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-header-bg);
  color: rgba(255,255,255,0.55);
  text-align: center;
  padding: 16px 24px;
  font-size: 0.82rem;
}

.site-footer a {
  color: rgba(255,255,255,0.75);
  text-decoration: underline;
}
.site-footer a:hover {
  color: #fff;
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 640px) {
  .header-tagline {
    margin-left: 0;
  }

  .main-container {
    padding: 16px 14px 40px;
    gap: 14px;
  }

  .card {
    padding: 20px 16px 18px;
  }

  /* Stack rows vertically on mobile */
  .rows-header {
    display: none;
  }

  .row-item {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 0;
    position: relative;
  }

  .row-label {
    display: block;
  }

  .btn-remove-row {
    position: absolute;
    top: 14px;
    right: 0;
    margin-top: 0;
  }

  .row-item > .input-wrap:first-child {
    padding-right: 48px;
  }

  .generate-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn--lg {
    width: 100%;
    justify-content: center;
  }

  .download-result {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 1.3rem;
  }
}
