/* 
    PDFR - PDF Merging. For Real.
    Bold, confident design reflecting "for real" attitude
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Bold and Confident */
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --accent-primary: #00d4ff;
    --accent-secondary: #ff006e;
    --accent-hover: #00b8d9;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #707070;
    --border-color: #2a2a2a;
    --success: #00ff88;
    --error: #ff3366;
    --warning: #ffaa00;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Branding */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 2rem;
}

.logo {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.logo-pdf {
    color: var(--text-primary);
}

.logo-r {
    color: var(--accent-primary);
    position: relative;
}

.logo-r::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
}

.tagline {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 1rem;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--bg-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.1), transparent);
    transition: left 0.5s;
}

.upload-area:hover::before {
    left: 100%;
}

.upload-area:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.1);
}

.upload-area.drag-over {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1);
}

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

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--accent-primary);
    stroke-width: 2.5;
}

.upload-area h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-area p {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Files Section */
.files-section h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.file-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.file-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.file-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.file-item.drag-over {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
}

.file-item.loading {
    opacity: 0.8;
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.file-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.file-status {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.875rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.file-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 0.5rem;
    transition: color 0.2s;
}

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

.file-handle:hover {
    color: var(--accent-primary);
}

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

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

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

.file-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.125rem;
}

.btn-icon:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: scale(1.1);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-remove {
    color: var(--error);
}

.btn-remove:hover:not(:disabled) {
    border-color: var(--error);
    color: var(--error);
}

/* Pages Section */
.pages-section {
    margin-top: 2rem;
}

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

.pages-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.pages-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.pages-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 769px) {
    .page-item:active {
        cursor: grabbing;
    }
}

@media (max-width: 768px) {
    .page-item {
        cursor: default;
        touch-action: auto;
    }
}

.page-item.dragging {
    opacity: 0.6;
    transform: scale(1.05);
    z-index: 1000;
}

.page-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 212, 255, 0.2);
}

.page-item:hover .page-hover-actions {
    opacity: 1;
    visibility: visible;
}


.page-item.drag-over {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
}

.page-item.deleted {
    opacity: 0.3;
    text-decoration: line-through;
}

.page-number {
    position: absolute;
    top: -10px;
    left: -10px;
    background: var(--accent-primary);
    color: var(--bg-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.875rem;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.4);
    z-index: 2;
}

.page-preview {
    width: 100%;
    height: 260px;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.page-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: white;
    transition: transform 0.3s ease;
}

.page-item.deleted .page-preview-img {
    opacity: 0.3;
    filter: grayscale(100%);
}

.page-info {
    width: 100%;
    text-align: center;
}

.page-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-mobile-actions {
    display: none;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.page-mobile-btn {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.page-mobile-btn:hover:not(:disabled) {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: var(--bg-primary);
    transform: scale(1.05);
}

.page-mobile-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-hover-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 3;
}

/* Show actions on mobile on tap/long-press */
@media (hover: none) and (pointer: coarse) {
    .page-item:active .page-hover-actions,
    .page-item.touched .page-hover-actions {
        opacity: 1;
        visibility: visible;
    }
}

/* Show mobile actions on mobile/tablet, hide on desktop */
@media (max-width: 768px) {
    .page-mobile-actions {
        display: flex;
    }
    
    .page-item {
        cursor: default;
    }
}

.page-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.page-action-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.page-action-rotate {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.page-action-rotate:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.page-action-delete {
    color: var(--error);
    border-color: var(--error);
}

.page-action-delete:hover {
    background: var(--error);
    color: var(--bg-primary);
}

/* Buttons */
.actions {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.btn {
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 700;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-merge {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
    min-width: 200px;
}

.btn-merge:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 212, 255, 0.4);
}

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

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

.btn-download {
    background: linear-gradient(135deg, var(--success), #00cc70);
    color: var(--bg-primary);
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
    font-weight: 800;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 255, 136, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Progress Section */
.progress-section {
    text-align: center;
    padding: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.progress-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Download Section */
.download-section {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 2px solid var(--border-color);
}

.download-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.success-icon {
    width: 64px;
    height: 64px;
    color: var(--success);
    stroke-width: 3;
}

.download-content h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.download-content p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 500px;
}

.download-content .btn {
    margin: 0.5rem;
}

/* Error Message */
.error-message {
    background: rgba(255, 51, 102, 0.1);
    border: 2px solid var(--error);
    border-radius: 12px;
    padding: 1.25rem;
    color: var(--error);
    font-weight: 600;
    text-align: center;
    margin-top: 1rem;
    animation: slideIn 0.3s ease;
}

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

/* Footer */
#footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.footer-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 0.875rem;
}

.footer-links a:hover {
    color: var(--text-primary, #333);
    text-decoration: underline;
}

.footer-separator {
    color: var(--text-muted);
    opacity: 0.5;
}

.footer-copyright {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.8;
}

@media (max-width: 768px) {
    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .footer-separator {
        display: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .logo {
        font-size: 2.5rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .upload-area {
        padding: 2.5rem 1.5rem;
    }

    .upload-area h2 {
        font-size: 1.25rem;
    }

    .upload-area p {
        font-size: 0.875rem;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
    }

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

    .file-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .pages-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }

    .page-item {
        padding: 0.75rem;
    }

    .page-preview {
        height: 180px;
    }

    .page-number {
        width: 30px;
        height: 30px;
        font-size: 0.8125rem;
        top: -8px;
        left: -8px;
    }

    .page-action-btn {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .page-mobile-btn {
        width: 60px;
        height: 60px;
        font-size: 1.625rem;
    }

    .page-hover-actions {
        top: 0.25rem;
        right: 0.25rem;
        gap: 0.5rem;
    }

    .btn {
        width: 100%;
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    .download-content h2 {
        font-size: 1.5rem;
    }

    .pages-header h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .header {
        padding-top: 1rem;
        margin-bottom: 2rem;
    }

    .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 0.75rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-area h2 {
        font-size: 1.125rem;
    }

    .upload-icon {
        width: 40px;
        height: 40px;
    }

    .file-item {
        padding: 0.75rem;
        gap: 0.5rem;
    }

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

    .file-meta {
        font-size: 0.75rem;
    }

    .file-icon {
        width: 32px;
        height: 32px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }

    .pages-header h3 {
        font-size: 1.125rem;
    }

    .pages-subtitle {
        font-size: 0.8125rem;
    }

    .pages-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }

    .page-item {
        padding: 0.625rem;
        gap: 0.5rem;
    }

    .page-preview {
        height: 150px;
    }

    .page-number {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
        top: -6px;
        left: -6px;
    }

    .page-title {
        font-size: 0.8125rem;
    }

    .page-source {
        font-size: 0.6875rem;
    }

    .page-action-btn {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }

    .page-mobile-btn {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .page-hover-actions {
        top: 0.25rem;
        right: 0.25rem;
    }

    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
    }

    .download-content h2 {
        font-size: 1.25rem;
    }

    .download-content p {
        font-size: 1rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

