/* =========================================
   PDF Merger Tool - Custom Styles
   IMPROVED READABILITY VERSION
   ========================================= */

/* CSS Variables */
:root {
  /* Clean, readable system fonts */
  --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Consolas", "Monaco", monospace;

  /* Brighter background for better contrast */
  --color-bg: #1a1d23;
  --color-bg-card: #252a33;
  --color-bg-elevated: #2d333d;
  --color-bg-hover: #363d4a;

  --color-primary: #4a9eff;
  --color-primary-hover: #3b8ae8;
  --color-primary-glow: rgba(74, 158, 255, 0.3);

  --color-accent: #22c997;
  --color-danger: #ff6b6b;
  --color-warning: #ffc107;

  /* MUCH brighter text colors */
  --color-text: #ffffff;
  --color-text-secondary: #d1d5db;
  --color-text-muted: #9ca3af;

  --color-border: #404754;
  --color-border-highlight: #4a9eff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px var(--color-primary-glow);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

html {
  font-size: 18px; /* Larger base font */
}

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

/* Subtle Background */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: linear-gradient(135deg, #1a1d23 0%, #252a33 100%);
}

/* Logo Icon */
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--color-primary), #6366f1);
  box-shadow: var(--shadow-glow);
  font-size: 3rem;
  color: white;
}

/* Header */
header h1 {
  color: var(--color-text);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

header .lead {
  color: var(--color-text-secondary);
  font-size: 1.25rem;
  font-weight: 400;
}

/* Main Card */
.main-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

/* Upload Zone */
.upload-zone {
  border: 3px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-normal);
  background: var(--color-bg-elevated);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-primary);
  background: rgba(74, 158, 255, 0.08);
}

.upload-zone.drag-over {
  border-style: solid;
  box-shadow: inset 0 0 40px var(--color-primary-glow);
}

.upload-content {
  position: relative;
}

.upload-icon {
  font-size: 5rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  display: block;
}

.upload-zone h4 {
  color: var(--color-text);
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.upload-zone p {
  color: var(--color-text-secondary);
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.upload-hint {
  position: absolute;
  bottom: -2.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Buttons - MUCH larger and clearer */
.btn {
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 1.1rem;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.75rem;
  transition: var(--transition-fast);
  cursor: pointer;
}

.btn-primary {
  background: var(--color-primary);
  border: none;
  color: white;
  box-shadow: 0 4px 14px rgba(74, 158, 255, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 158, 255, 0.5);
  color: white;
}

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

.btn-outline-primary {
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn-outline-secondary {
  color: var(--color-text);
  border: 2px solid var(--color-border);
  background: transparent;
}

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

.btn-outline-danger {
  color: var(--color-danger);
  border: 2px solid var(--color-danger);
  background: transparent;
}

.btn-outline-danger:hover {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.btn-lg {
  padding: 1rem 2.5rem;
  font-size: 1.25rem;
}

/* File List Container */
.file-list-container {
  animation: fadeIn 0.3s ease;
}

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

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
}

.file-list-header h5 {
  color: var(--color-text);
  font-size: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  margin: 0;
}

.file-list-header .badge {
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.4rem 0.75rem;
}

/* Instruction text */
.file-list-container > p {
  color: var(--color-text-secondary) !important;
  font-size: 1.1rem !important;
}

/* File List */
.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 450px;
  overflow-y: auto;
}

.file-list::-webkit-scrollbar {
  width: 8px;
}

.file-list::-webkit-scrollbar-track {
  background: var(--color-bg);
  border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* File Item - Larger and clearer */
.file-item {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--color-bg-elevated);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  transition: var(--transition-fast);
  cursor: grab;
}

.file-item:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-text-muted);
}

.file-item.ui-sortable-helper {
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
  border-color: var(--color-primary);
  z-index: 1000;
}

.file-item.ui-sortable-placeholder {
  visibility: visible !important;
  background: var(--color-primary-glow);
  border: 3px dashed var(--color-primary);
}

/* File Item Components - Bigger */
.file-order {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.file-drag-handle {
  color: var(--color-text-muted);
  cursor: grab;
  padding: 0.5rem;
  font-size: 1.5rem;
  transition: var(--transition-fast);
}

.file-drag-handle:hover {
  color: var(--color-text);
}

.file-icon {
  color: var(--color-danger);
  font-size: 2rem;
  flex-shrink: 0;
}

.file-info {
  flex-grow: 1;
  min-width: 0;
}

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

.file-size {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
}

.file-remove {
  background: none;
  border: none;
  color: var(--color-text-muted);
  padding: 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  flex-shrink: 0;
  font-size: 1.25rem;
}

.file-remove:hover {
  background: rgba(255, 107, 107, 0.2);
  color: var(--color-danger);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--color-border);
  gap: 1rem;
}

/* Footer */
footer p {
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* SweetAlert2 Custom Theme */
.swal2-popup {
  font-family: var(--font-primary) !important;
  font-size: 1.1rem !important;
  background: var(--color-bg-card) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-lg) !important;
}

.swal2-title {
  color: var(--color-text) !important;
  font-size: 1.5rem !important;
}

.swal2-html-container {
  color: var(--color-text-secondary) !important;
  font-size: 1.1rem !important;
}

.swal2-confirm {
  background: var(--color-primary) !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  font-size: 1.1rem !important;
  padding: 0.75rem 1.5rem !important;
}

.swal2-cancel {
  background: var(--color-bg-elevated) !important;
  color: var(--color-text) !important;
  border: 2px solid var(--color-border) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 1.1rem !important;
  padding: 0.75rem 1.5rem !important;
}

/* Toast customization */
.swal2-popup.swal2-toast {
  background: var(--color-bg-card) !important;
  box-shadow: var(--shadow-lg) !important;
  font-size: 1rem !important;
}

/* Loading State */
.merge-loading .file-item {
  pointer-events: none;
  opacity: 0.6;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .main-card {
    padding: 1.5rem;
  }

  .upload-zone {
    padding: 3rem 1.5rem;
  }

  .upload-icon {
    font-size: 4rem;
  }

  .upload-zone h4 {
    font-size: 1.5rem;
  }

  .file-item {
    padding: 1rem;
    gap: 1rem;
  }

  .file-order {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .action-buttons {
    flex-direction: column-reverse;
  }

  .action-buttons .btn {
    width: 100%;
  }

  header h1 {
    font-size: 2rem;
  }
}

/* Progress Animation for Upload */
@keyframes uploadPulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.file-item.uploading {
  animation: uploadPulse 1.5s ease-in-out infinite;
}

.file-item.uploading .file-icon {
  animation: spin 1s linear infinite;
}

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

/* =========================================
   Loading Overlay
   ========================================= */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 29, 35, 0.95);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 2rem;
}

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

.loading-text {
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2rem;
  text-align: center;
}

.loading-subtext {
  color: #9ca3af;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

/* Flower Loader (Blue) */
.loader-flower {
  font-size: 48px;
  color: #4a9eff;
  width: 1em;
  height: 1em;
  box-sizing: border-box;
  background-color: currentcolor;
  position: relative;
  border-radius: 50%;
  transform: rotateX(-60deg) perspective(1000px);
}

.loader-flower:before,
.loader-flower:after {
  content: '';
  display: block;
  position: absolute;
  box-sizing: border-box;
  top: 0;
  left: 0;
  width: inherit;
  height: inherit;
  border-radius: inherit;
  animation: flowerFlow 1s ease-out infinite;
}

.loader-flower:after {
  animation-delay: 0.4s;
}

@keyframes flowerFlow {
  0% {
    opacity: 1;
    transform: rotate(0deg);
    box-shadow: 
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor,
      0 0 0 -0.5em currentcolor;
  }
  100% {
    opacity: 0;
    transform: rotate(180deg);
    box-shadow: 
      -1em -1em 0 -0.35em currentcolor,
      0 -1.5em 0 -0.35em currentcolor,
      1em -1em 0 -0.35em currentcolor,
      -1.5em 0 0 -0.35em currentcolor,
      1.5em 0 0 -0.35em currentcolor,
      -1em 1em 0 -0.35em currentcolor,
      0 1.5em 0 -0.35em currentcolor,
      1em 1em 0 -0.35em currentcolor;
  }
}

/* Spinner Loader (on top) */
.loader-spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-block;
  border-top: 5px solid #ffffff;
  border-right: 5px solid transparent;
  box-sizing: border-box;
  animation: spinnerRotation 1s linear infinite;
  position: relative;
}

.loader-spinner::after {
  content: '';
  box-sizing: border-box;
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border-left: 5px solid #4a9eff;
  border-bottom: 5px solid transparent;
  animation: spinnerRotation 0.5s linear infinite reverse;
}

@keyframes spinnerRotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Loader container to stack them */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
}

/* Extra helper classes for visibility */
.text-white {
  color: #ffffff !important;
}

.text-bright {
  color: var(--color-text-secondary) !important;
}
