/* ===================================
   PDF Merge — Design System & Styles
   =================================== */

/* === CSS Variables === */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(20, 20, 32, 0.7);
    --bg-card-hover: rgba(30, 30, 48, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;

    --accent-violet: #8B5CF6;
    --accent-pink: #EC4899;
    --accent-blue: #3B82F6;
    --accent-green: #34D399;
    --accent-red: #EF4444;

    --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    --gradient-secondary: linear-gradient(135deg, #8B5CF6 0%, #3B82F6 100%);
    --gradient-success: linear-gradient(135deg, #34D399 0%, #059669 100%);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(139, 92, 246, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

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

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* === Background Particles === */
.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-10vh) scale(1);
    }
}

/* === App Container === */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Header === */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glow);
    transition: transform var(--transition-normal);
}

.logo-icon:hover {
    transform: rotate(-5deg) scale(1.05);
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--accent-green);
    font-weight: 500;
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.5); }
}

/* === Main Content === */
.main-content {
    flex: 1;
    position: relative;
}

/* === Drop Zone === */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border-accent);
    border-radius: var(--radius-xl);
    padding: 3.5rem 2rem;
    text-align: center;
    cursor: pointer;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    transition: all var(--transition-normal);
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.06), transparent 70%);
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-violet);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow), inset 0 0 60px rgba(139, 92, 246, 0.05);
    transform: translateY(-2px);
}

.drop-zone.drag-over {
    border-style: solid;
    animation: dropZonePulse 1s ease-in-out infinite;
}

@keyframes dropZonePulse {
    0%, 100% { box-shadow: var(--shadow-glow); }
    50% { box-shadow: 0 0 60px rgba(139, 92, 246, 0.3); }
}

.drop-zone-content {
    position: relative;
    z-index: 1;
}

.drop-icon {
    margin-bottom: 1.25rem;
    transition: transform var(--transition-normal);
}

.drop-zone:hover .drop-icon {
    transform: translateY(-4px);
}

.drop-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.drop-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.browse-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 100px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.browse-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.45);
}

.browse-btn:active {
    transform: translateY(0);
}

/* === File Section === */
.file-section {
    margin-top: 1.5rem;
    animation: fadeInUp 0.5s ease;
}

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

.file-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.file-count {
    padding: 0.2rem 0.7rem;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--accent-violet);
    font-weight: 600;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.12);
}

.clear-btn:hover {
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
}

.reorder-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

/* === File List === */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    min-height: 60px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition-fast);
    user-select: none;
    animation: fileSlideIn 0.3s ease;
}

@keyframes fileSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.file-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-sm);
}

.file-item.dragging {
    opacity: 0.4;
    border-color: var(--accent-violet);
    transform: scale(0.98);
}

.file-item.drag-target {
    border-color: var(--accent-violet);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.file-item:active {
    cursor: grabbing;
}

.file-drag-handle {
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0.3;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.file-item:hover .file-drag-handle {
    opacity: 0.7;
}

.file-drag-handle span {
    display: block;
    width: 14px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
}

.file-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    background: var(--gradient-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.file-icon svg {
    color: #EF4444;
}

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

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

.file-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.15rem;
}

.file-size,
.file-pages {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.file-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
}

/* === Merge Button === */
.merge-btn {
    position: relative;
    width: 100%;
    padding: 1rem 2rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-normal);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.25);
}

.merge-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.4);
}

.merge-btn:active {
    transform: translateY(0);
}

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

.merge-btn-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
}

.merge-btn-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* === Progress Overlay === */
.progress-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.progress-card {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    max-width: 380px;
    width: 90%;
}

.progress-spinner {
    margin-bottom: 1.5rem;
}

.spinner-circle {
    transform-origin: center;
    animation: spin 1.2s linear infinite;
}

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

.progress-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.progress-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 100px;
    transition: width 0.3s ease;
}

/* === Success Overlay === */
.success-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.success-card {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(52, 211, 153, 0.1);
    max-width: 400px;
    width: 90%;
}

.success-icon {
    margin-bottom: 1.5rem;
}

.check-path {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: drawCheck 0.6s ease 0.3s forwards;
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

.success-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 0.5rem;
}

.success-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--gradient-success);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 20px rgba(52, 211, 153, 0.3);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(52, 211, 153, 0.45);
}

.reset-btn {
    padding: 0.75rem 2rem;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.reset-btn:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

/* === Footer === */
.app-footer {
    margin-top: 3rem;
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

.app-footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* === Responsive === */
@media (max-width: 640px) {
    .app-container {
        padding: 1.25rem 1rem;
    }

    .app-header {
        margin-bottom: 1.5rem;
    }

    .logo-text h1 {
        font-size: 1.25rem;
    }

    .header-badge {
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
    }

    .drop-zone {
        padding: 2.5rem 1.25rem;
    }

    .drop-title {
        font-size: 1.15rem;
    }

    .file-section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
    }

    .file-item {
        padding: 0.75rem;
    }

    .file-name {
        font-size: 0.8rem;
    }

    .merge-btn {
        font-size: 0.95rem;
    }
}
