/* ============================================
   SYSTEM THEME VARIABLES
   ============================================ */
   :root {
    --bg-primary:    #ffffff;
    --bg-secondary:  #f8f9fa;
    --bg-card:       #ffffff;
    --text-primary:  #1a1a2e;
    --text-secondary:#6c757d;
    --border-color:  #dee2e6;
    --shadow:        0 4px 20px rgba(0,0,0,0.08);
    --accent:        #4361ee;
    --accent-hover:  #3a56d4;
    --success:       #2ecc71;
    --danger:        #e74c3c;
    --warning:       #f39c12;
    --info:          #3498db;
    --transition:    all 0.3s ease;
  }
  
  @media (prefers-color-scheme: dark) {
    :root {
      --bg-primary:    #0f0f13;
      --bg-secondary:  #1a1a24;
      --bg-card:       #1e1e2e;
      --text-primary:  #e2e8f0;
      --text-secondary:#94a3b8;
      --border-color:  #2d2d3d;
      --shadow:        0 4px 20px rgba(0,0,0,0.4);
    }
  }
  
  /* ============================================
     BASE RESET
     ============================================ */
  *, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    transition: var(--transition);
    min-height: 100vh;
  }
  
  /* ============================================
     NAVBAR
     ============================================ */
  .navbar {
    background-color: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    padding: 12px 24px;
  }
  
  .navbar-brand {
    color: var(--text-primary) !important;
    font-size: 1.4rem !important;
  }
  
  .theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 50px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
  }
  
  .theme-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  
  /* ============================================
     HERO
     ============================================ */
  .hero {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border-bottom: 1px solid var(--border-color);
    padding: 50px 20px;
    text-align: center;
  }
  
  .hero h1 {
    color: var(--text-primary);
    font-size: 2.2rem;
    font-weight: 700;
  }
  
  .hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 8px;
  }
  
  /* ============================================
     FEATURE TABS
     ============================================ */
     .tabs-scroll {
      flex-wrap: wrap;
      overflow-x: visible;
      padding-bottom: 4px;
      scrollbar-width: none;
      justify-content: center;
      gap: 4px;
    }
    
    .tabs-scroll::-webkit-scrollbar { display: none; }
    
    .nav-pills .nav-link {
      color: var(--text-secondary);
      border-radius: 50px;
      padding: 7px 14px;
      margin: 0;
      transition: var(--transition);
      border: 1px solid transparent;
      font-weight: 500;
      white-space: nowrap;
      font-size: 0.82rem;
    }
  
  .nav-pills .nav-link:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
  }
  
  .nav-pills .nav-link.active {
    background-color: var(--accent);
    color: white !important;
    border-color: var(--accent);
  }
  
  /* ============================================
     MAIN LAYOUT — 2-column grid
     ============================================ */
  .main-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
  }
  
  .main-layout > .card       { min-width: 0; width: 100%; }
  .main-layout > .preview-panel { min-width: 0; width: 100%; }
  
  @media (max-width: 900px) {
    .main-layout { grid-template-columns: 1fr; }
  }
  
  /* ============================================
     CARDS
     ============================================ */
  .card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow);
    transition: var(--transition);
  }
  
  /* ============================================
     DRAG & DROP ZONE
     ============================================ */
  .drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background-color: var(--bg-secondary);
    position: relative;
  }
  
  .drop-zone:hover,
  .drop-zone.dragover {
    border-color: var(--accent);
    background-color: rgba(67, 97, 238, 0.05);
  }
  
  .drop-zone.dragover { transform: scale(1.01); }
  
  .drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
  }
  
  .drop-zone-icon {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 12px;
  }
  
  .drop-zone-text { color: var(--text-secondary); font-size: 0.95rem; }
  .drop-zone-text strong { color: var(--accent); }
  
  /* ============================================
     FILE LIST
     ============================================ */
  .file-list { margin-top: 16px; }
  
  .file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
  }
  
  .file-item-icon { font-size: 1.4rem; color: var(--danger); }
  .file-item-info { flex: 1; min-width: 0; }
  
  .file-item-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .file-item-size { font-size: 0.75rem; color: var(--text-secondary); }
  
  .file-item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    padding: 2px 6px;
    border-radius: 6px;
    flex-shrink: 0;
  }
  
  .file-item-remove:hover {
    color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
  }
  
  /* ============================================
     PROGRESS BAR
     ============================================ */
  .progress-container { display: none; margin-top: 16px; }
  
  .progress-container.show {
    display: block;
    animation: fadeIn 0.3s ease;
  }
  
  .progress {
    height: 8px;
    border-radius: 50px;
    background-color: var(--bg-secondary);
    overflow: hidden;
  }
  
  .progress-bar {
    background: linear-gradient(90deg, var(--accent), #7209b7);
    border-radius: 50px;
    transition: width 0.4s ease;
    animation: progressPulse 1.5s infinite;
  }
  
  @keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
  }
  
  .progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
    text-align: center;
  }
  
  /* ============================================
     BUTTONS
     ============================================ */
  .btn-action {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-weight: 600;
    font-size: 1rem;
    width: 100%;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 16px;
    display: block;
    text-align: center;
  }
  
  .btn-action:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3);
    color: white;
    text-decoration: none;
  }
  
  .btn-action:active  { transform: translateY(0); }
  .btn-action:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
  
  /* ============================================
     OUTPUT TYPE BUTTONS
     ============================================ */
  .output-type-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary);
    transition: all 0.2s ease;
  }
  
  .output-type-btn.active {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
  }
  
  /* ============================================
     PREVIEW PANEL (right column)
     ============================================ */
  .preview-panel {
    position: sticky;
    top: 20px;
  }
  
  .preview-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
  }
  
  .preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
  }
  
  .preview-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
  }
  
  .preview-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.3;
  }
  
  .preview-file-info { animation: fadeIn 0.3s ease; }
  
  .preview-thumbnail {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 180px;
  }
  
  .preview-thumbnail canvas { max-width: 100%; height: auto; display: block; }
  .preview-thumbnail-icon { font-size: 4rem; color: var(--danger); opacity: 0.7; }
  
  .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    gap: 8px;
  }
  
  .info-row:last-child { border-bottom: none; }
  .info-label  { color: var(--text-secondary); font-weight: 500; flex-shrink: 0; }
  .info-value  { color: var(--text-primary); font-weight: 600; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  
  /* ============================================
     RESULT SECTION
     ============================================ */
  .result-section { display: none; margin-top: 20px; animation: fadeIn 0.4s ease; }
  .result-section.show { display: block; }
  
  .result-card { border-radius: 12px; padding: 20px; border: none; }
  
  .result-card.success {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.3) !important;
  }
  
  .result-card.error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3) !important;
  }
  
  .download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    margin-top: 12px;
    margin-right: 8px;
  }
  
  .download-btn:hover { background: #27ae60; transform: translateY(-2px); color: white; }
  
  /* ============================================
     MERGE FILE ITEMS
     ============================================ */
  .merge-file-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
    cursor: pointer;
    transition: border-color 0.2s;
  }
  
  .merge-file-item.dragging  { opacity: 0.5; border: 2px dashed var(--accent); }
  .merge-file-item.drag-over { border-color: var(--accent); background: rgba(67, 97, 238, 0.05); }
  
  .merge-file-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  
  .merge-file-order {
    background: var(--accent);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
  }
  
  .merge-file-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  
  .merge-file-size { font-size: 0.75rem; color: var(--text-secondary); flex-shrink: 0; }
  .merge-file-controls { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
  
  .reorder-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
  }
  
  .reorder-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
  
  .page-range-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    transition: all 0.2s;
  }
  
  .page-range-input:focus { outline: none; border-color: var(--accent); }
  .page-range-input::placeholder { color: var(--text-secondary); }
  
  /* ============================================
     COMPRESSION LEVEL CARDS
     ============================================ */
  .compress-level-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .compress-level-card:hover  { border-color: var(--accent); background: rgba(67, 97, 238, 0.05); }
  .compress-level-card.active { border-color: var(--accent); background: rgba(67, 97, 238, 0.08); }
  
  .compress-level-header { display: flex; align-items: center; gap: 10px; }
  
  .compress-level-radio {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
    transition: all 0.2s;
  }
  
  .compress-level-radio.active { border-color: var(--accent); background: var(--accent); }
  
  .compress-level-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .compress-level-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
  .compress-level-desc { font-size: 0.75rem; color: var(--text-secondary); }
  
  .compress-level-badge {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 50px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
  }
  
  /* ============================================
     COMPARE RESULTS
     ============================================ */
  .compare-results { margin-top: 20px; animation: fadeIn 0.3s ease; }
  .compare-results.d-none { display: none; }
  
  .similarity-score {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
  }
  
  .similarity-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
  }
  
  #similarityNumber { font-size: 1.2rem; font-weight: 700; line-height: 1; }
  .similarity-label { font-size: 0.7rem; opacity: 0.8; }
  .similarity-stats { display: flex; gap: 16px; flex-wrap: wrap; }
  .stat-item { display: flex; flex-direction: column; align-items: center; }
  .stat-value { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
  .stat-label { font-size: 0.72rem; color: var(--text-secondary); }
  .stat-item.removed .stat-value { color: var(--danger); }
  .stat-item.added   .stat-value { color: var(--success); }
  
  .diff-header { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
  
  .diff-header-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
  }
  
  .diff-header-item.removed { background: rgba(231,76,60,0.1);  color: var(--danger); }
  .diff-header-item.added   { background: rgba(46,204,113,0.1); color: var(--success); }
  
  .diff-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
  }
  
  .diff-panel { padding: 10px; font-size: 0.78rem; line-height: 1.6; overflow-x: hidden; }
  
  .diff-line {
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    word-break: break-word;
    font-family: monospace;
  }
  
  .diff-line.removed { background: rgba(231,76,60,0.15);  color: var(--danger);  border-left: 3px solid var(--danger); }
  .diff-line.added   { background: rgba(46,204,113,0.15); color: var(--success); border-left: 3px solid var(--success); }
  .diff-line.common  { color: var(--text-secondary); }
  
  /* ============================================
     OFFICE FORMAT BADGES
     ============================================ */
  .supported-formats {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid var(--border-color);
  }
  
  .fmt-badge { padding: 4px 10px; border-radius: 6px; font-size: 0.8rem; font-weight: 500; }
  .fmt-word  { background: rgba(67,97,238,0.15);  color: var(--accent); }
  .fmt-ppt   { background: rgba(231,76,60,0.15);  color: var(--danger); }
  .fmt-excel { background: rgba(46,204,113,0.15); color: var(--success); }
  .fmt-txt   { background: rgba(243,156,18,0.15); color: var(--warning); }
  .fmt-html  { background: rgba(52,152,219,0.15); color: var(--info); }
  
  /* ============================================
     ANNOTATE — fixed full-screen overlay
     Position: fixed, direct body child
     Zero interference from any parent CSS
     ============================================ */
  
  /* Hidden by default */
  #annotate-fullscreen-wrapper {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
  }
  
  /* Shown via JS: annotateWrapper.style.display = 'flex' */
  
  /* Top bar */
  .annotate-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 56px;
    min-height: 56px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
  }
  
  .annotate-topbar h5 {
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  
  .annotate-status {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  
  .annotate-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
  }
  
  /* Main body below topbar */
  .annotate-body {
    display: grid;
    grid-template-columns: 1fr 340px;
    flex: 1;
    min-height: 0;
    height: calc(100vh - 56px);
  }
  
  /* Syncfusion viewer — fills left column */
  #sfPdfViewer {
    width: 100% !important;
    height: 100% !important;
    display: block;
    min-height: 0;
  }
  
  /* Right preview column */
  .annotate-preview-col {
    border-left: 1px solid var(--border-color);
    background: var(--bg-card);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  
  .annotate-preview-col .preview-title {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
  }
  
  .annotate-preview-col #annotatePreviewContent {
    padding: 12px;
    flex: 1;
  }
  
  /* Open PDF button */
  .annotate-open-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
  }
  
  .annotate-open-label:hover { background: var(--accent-hover); }
  
  /* Close button */
  .annotate-close-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
  }
  
  .annotate-close-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
  
  @media (max-width: 900px) {
    .annotate-body { grid-template-columns: 1fr; }
    .annotate-preview-col { display: none; }
  }
  
  /* ============================================
     ANIMATIONS
     ============================================ */
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  
  .feature-panel { animation: fadeIn 0.3s ease; }
  
  /* ============================================
     RESPONSIVE
     ============================================ */
  @media (max-width: 576px) {
    .nav-pills .nav-link { padding: 8px 14px; font-size: 13px; }
    .hero h1             { font-size: 1.6rem; }
    .drop-zone           { padding: 30px 15px; }
    .similarity-score    { flex-direction: column; text-align: center; }
  }
  /* AI Assistant text colour — controlled by colour picker */
#summaryTitle,
#summaryOverview,
#summaryKeyPoints li,
#summaryMeta,
#aiSummaryResult h6,
#aiSummaryResult .card-body {
  color: var(--ai-text-color, #000000) !important;
}

#chatThread .bg-white,
#chatThread .border {
  color: var(--ai-text-color, #000000) !important;
  background: var(--bg-card) !important;
  border-color: var(--border-color) !important;
}

#aiSummaryResult .card,
#aiSummaryResult .bg-light {
  background: var(--bg-card) !important;
}

#chatThread {
  background: var(--bg-secondary) !important;
}
/* AI Assistant — always white card background */
#aiSummaryResult .card,
#aiSummaryResult .bg-light,
#aiSummaryResult .card-body {
  background: #ffffff !important;
}

#chatThread {
  background: #ffffff !important;
}

#chatThread .border {
  background: #ffffff !important;
}