:root {
  --primary: #6c63ff;
  --primary-hover: #5a52d5;
  --bg-app: #f8f9fc;
  --bg-panel: #ffffff;
  --text-main: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  height: 64px;
  padding: 0 32px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
}

.logo i {
  color: #ff4757;
  font-size: 24px;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
}

.text-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* App Layout */
.app {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 24px;
}

.upload-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.upload-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: #eff6ff;
    color: var(--primary);
    border: 1px dashed var(--primary);
    padding: 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.upload-btn:hover {
    background: #e0e7ff;
}

.stats h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: var(--text-main);
}

.progress-container {
  height: 6px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.count-text {
  margin: 0;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  text-align: right;
}

.selected-list-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.selected-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-list li {
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.selected-list li .remove {
    cursor: pointer;
    color: #94a3b8;
}
.selected-list li .remove:hover {
    color: #ef4444;
}

/* Controls (Copies & Download) */
.controls {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.copies-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.copies-control label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.number-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.number-input button {
    border: none;
    background: #f8fafc;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-secondary);
}

.number-input input {
    width: 40px;
    text-align: center;
    border: none;
    outline: none;
    font-weight: 600;
    font-size: 14px;
    -moz-appearance: textfield;
    appearance: textfield;
}

.number-input input::-webkit-outer-spin-button,
.number-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.download-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.download-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(108, 99, 255, 0.4);
}

.download-btn:active {
  transform: translateY(0);
}

.helper-text {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 12px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 48px;
  overflow: hidden;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}

.title-section h2 {
    margin: 0 0 4px 0;
    font-size: 24px;
}
.title-section p {
    margin: 0;
    color: var(--text-secondary);
}

.selection-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.action-btn.outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.action-btn.outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-main);
}

/* Pages Grid */
/* Page Card (Icon View) */
/* Page Card (Icon View) */
.pages-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); /* Smaller width for icon cards */
  gap: 20px;
  overflow-y: auto;
  padding: 20px;
  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.page {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 24px 20px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  justify-content: center;
}

.page:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.page.selected {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 2px var(--primary);
}

.page.required {
  border-color: #f59e0b;
  background: #fffbeb;
}
.page.required.selected {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px #f59e0b;
}

/* Icon Container */
.page-icon-box {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: #f1f5f9;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.2s;
}

.page.selected .page-icon-box {
    background: var(--primary);
    color: white;
}

.page.required .page-icon-box {
    background: #fef3c7;
    color: #d97706;
}

/* Typography */
.page-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.page-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.page-sublabel {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Controls & Footer */
.page-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 8px;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.page-controls .number-input {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-controls .number-input button {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0;
    font-size: 10px;
    background: #f1f5f9;
    color: var(--text-secondary);
    transition: all 0.1s;
}

.page-controls .number-input button:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.page-controls .number-input input {
    width: 24px;
    height: 24px;
    font-size: 13px;
    font-weight: 600;
    background: transparent;
}

/* Badges */
.badge {
  position: absolute;
  top: -8px;
  left: 12px;
  background: #f59e0b;
  color: #fff;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  z-index: 2;
}

/* Toast Notification */
.notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border-left: 5px solid #10b981;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.icon-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #d1fae5;
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.message h4 {
  margin: 0;
  font-size: 14px;
  color: var(--text-main);
}

.message p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}
/* Responsive Design (Mobile & Tablet) */
@media (max-width: 1024px) {
    body {
        height: auto;
        overflow: auto;
    }

    .app {
        display: block; /* Stack layout */
        height: auto;
        overflow: visible;
    }

    /* Transform Sidebar into Fixed Bottom Bar */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: none;
        z-index: 1000;
        background: #ffffff;
        border-right: none;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        padding: 12px 24px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }

    /* Hide sidebar elements we don't need on mobile */
    .sidebar .stats,
    .sidebar .selected-list-container,
    .sidebar .upload-section {
        display: none !important;
    }

    /* Adjust Controls Layout */
    .sidebar .controls {
        width: 100%;
        padding: 0;
        border: none;
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .copies-control {
        margin: 0;
        flex-direction: row;
        gap: 12px;
    }
    
    .copies-control label {
        display: none; /* Save space */
    }

    .helper-text {
        display: none;
    }

    .download-btn {
        flex: 1;
        margin: 0;
        padding: 14px;
        font-size: 15px;
    }

    /* Main Content Adjustments */
    .main-content {
        height: auto;
        overflow: visible;
        padding: 24px;
        padding-bottom: 100px; /* Space for bottom bar */
    }

    /* Sticky Toolbar */
    .toolbar {
        position: sticky;
        top: 0;
        z-index: 500;
        background: var(--bg-app); /* Match body bg */
        padding: 16px 0;
        margin-bottom: 24px;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        backdrop-filter: blur(8px); /* Nice effect if supported */
        flex-wrap: wrap; 
        gap: 10px;
    }

    .pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Smaller cards on tablet */
        padding-bottom: 0;
        overflow: visible;
    }
}

@media (max-width: 600px) {
    .topbar {
        padding: 0 16px;
    }
    
    .main-content {
        padding: 16px;
        padding-bottom: 90px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .selection-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr; /* Equal width buttons */
    }
    
    .pages-grid {
        grid-template-columns: 1fr; /* Full width cards on mobile */
    }
    
    .download-btn {
        font-size: 14px;
    }

    .notification {
  position: fixed;
  bottom: 80px;
  right: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border-left: 5px solid #10b981;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
}

}


