/* Base Styles */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4895ef;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --warning-color: #f8961e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background-color: #fff;
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 25px;
    margin: 0;
    padding: 0;
}

nav a {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 600;
    font-size: 1.1rem;
    transition: color 0.3s;
}

nav a:hover {
    color: var(--primary-color);
}

/* Upload Section */
.upload-section {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.08);
}

.converter-header {
    text-align: center;
    margin-bottom: 30px;
}

.converter-header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2.2rem;
}

.subtitle {
    color: #6c757d;
    font-size: 1.1rem;
    margin-top: 0;
}

/* File Upload */
.upload-container {
    margin: 30px auto;
    max-width: 500px;
}

.file-input {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: #f8f9fa;
    border: 2px dashed var(--primary-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 180px;
}

.file-label:hover {
    background: #e9f2ff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.1);
}

.file-label i {
    font-size: 48px;
    color: var(--danger-color);
    margin-bottom: 15px;
}

.file-label span {
    font-size: 1.1rem;
    color: var(--dark-color);
    font-weight: 500;
}

.file-info {
    margin-top: 15px;
    font-size: 0.95rem;
    color: #6c757d;
    text-align: center;
}

/* Preview Area */
.preview-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.preview-container {
    width: 100%;
    max-width: 900px;
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.selection-instruction {
    font-weight: 600;
    padding: 15px;
    margin-bottom: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.05rem;
}

.select-all {
    margin-bottom: 20px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    border: 1px solid #dee2e6;
}

.large-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.page-preview {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
    background: white;
}

.page-preview:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.page-checkbox {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.page-img {
    width: 100%;
    height: 280px;
    object-fit: contain;
    display: block;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.page-number {
    padding: 12px;
    background: #fff;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--dark-color);
}

/* Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

.secondary-buttons {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 500;
}

.btn i {
    font-size: 1rem;
}

.convert-download-btn {
    background: var(--primary-color);
    color: white;
    font-size: 1.1rem;
}

.convert-download-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

.convert-download-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.new-btn {
    background: #6c757d;
    color: white;
    flex: 1;
}

.new-btn:hover {
    background: #5a6268;
}

.home-btn {
    background: var(--dark-color);
    color: white;
    flex: 1;
}

.home-btn:hover {
    background: #343a40;
}

/* Advertisement */
.ad-space {
    margin: 30px 0 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    text-align: center;
    border: 1px dashed #ced4da;
}

.ad-content {
    padding: 15px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.ad-content p {
    margin: 0;
    font-weight: 600;
    color: var(--primary-color);
}

.ad-content small {
    color: #6c757d;
    font-size: 0.85rem;
}

/* Loading */
.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
    padding: 30px;
    background: rgba(255,255,255,0.9);
    border-radius: 8px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.footer {
    background: var(--dark-color);
    color: #f8f9fa;
    padding: 40px 0 0;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-section h3 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.3rem;
}

.footer-section p, .footer-section a {
    color: #adb5bd;
    line-height: 1.8;
}

.footer-section a {
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: #fff;
}

.footer-bottom {
    text-align: center;
    padding: 20px 0;
    background: #1a1a1a;
    margin-top: 40px;
    font-size: 0.9rem;
    color: #6c757d;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        padding: 15px;
    }
    
    nav ul {
        margin-top: 15px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .page-img {
        height: 200px;
    }
    
    .secondary-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .file-label {
        padding: 20px;
        height: 150px;
    }
    
    .file-label i {
        font-size: 36px;
    }
}

/* Fullscreen Loading Overlay */
.fullscreen-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #4361ee;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 15px;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 15px;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4361ee, #4895ef);
    transition: width 0.3s ease;
    border-radius: 4px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}