* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fda50259;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    color: black;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 15px;
    font-weight: 700;
}

.header p {
    font-size: clamp(1rem, 3vw, 1.2rem);
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

.upload-section {
    background: white;
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #f8f9ff;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 20px;
}

.upload-text {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 20px;
}

.upload-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

#fileInput {
    display: none;
}

.control-section {
    display: none !important;
}

.control-section h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 1.8rem;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e0e6ff;
}

.control-group h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.rotation-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.rotate-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-width: 100px;
}

.rotate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.3);
}

.rotate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.preview-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: none;
}

.preview-section h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 1.8rem;
}

.pdf-container {
    margin-bottom: 40px;
    border: 2px solid #e0e6ff;
    border-radius: 15px;
    padding: 20px;
    background: #f8f9ff;
}

.pdf-header {
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px solid #e0e6ff;
    padding-bottom: 10px;
}

.pdf-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    word-break: break-word;
    font-size: 1.1rem;
}

.pdf-info {
    color: #666;
    font-size: 0.9rem;
}

.pdf-pages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e0e6ff;
}

.page-thumbnail {
    position: relative;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    transition: all 0.3s ease;
    cursor: pointer;
}

.page-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    border-color: #667eea;
}

.page-thumbnail.selected {
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

.page-canvas {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.page-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    font-size: 0.8rem;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.page-rotation-indicator {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    display: none;
}

.page-rotation-indicator.show {
    display: block;
}

.loading-thumbnail {
    width: 120px;
    height: 150px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #666;
    font-size: 0.8rem;
}

.action-section {
    text-align: center;
}

.action-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    margin: 10px;
    min-width: 200px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(40, 167, 69, 0.3);
}

.action-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.download-btn {
    background: linear-gradient(135deg, #dc3545, #fd7e14);
}

.download-btn:hover {
    box-shadow: 0 10px 20px rgba(220, 53, 69, 0.3);
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border: 1px solid #f5c6cb;
    display: none;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    border: 1px solid #c3e6cb;
    display: none;
}

.page-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    gap: 5px;
}

.page-thumbnail:hover .page-controls {
    display: flex;
}

.page-rotate-btn {
    background: rgba(102, 126, 234, 0.9);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-rotate-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .preview-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .preview-controls .rotation-controls {
        justify-content: center;
    }

    .container {
        padding: 15px;
    }

    .upload-section {
        padding: 25px 15px;
    }

    .upload-area {
        padding: 40px 15px;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .rotation-controls {
        flex-direction: column;
        align-items: center;
    }

    .rotate-btn {
        width: 100%;
        max-width: 150px;
    }

    .action-btn {
        width: 100%;
        max-width: 300px;
    }

    .pdf-pages {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

@media (max-width: 480px) {
    .preview-controls .rotation-controls {
        flex-direction: column;
        width: 100%;
    }
    .upload-area {
        padding: 30px 10px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .upload-text {
        font-size: 1rem;
    }

    .pdf-pages {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.preview-header h2 {
    color: #333;
    font-size: 1.8rem;
    margin: 0;
}

.preview-controls {
    display: none;
    align-items: center;
    gap: 15px;
}

.preview-controls .rotation-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}