/* PDFToolsHQ Backend Connector - Frontend Styles
 * Version: 1.0.1
 */

/* Reset and base styles */
.pdftoolshq-backend-upload-container,
.pdftoolshq-backend-merge-container {
    max-width: 800px;
    margin: 20px auto;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Header */
.pdftoolshq-backend-header {
    margin-bottom: 25px;
    text-align: center;
}

.pdftoolshq-backend-header h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
}

.pdftoolshq-backend-header p {
    color: #7f8c8d;
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

/* Upload area */
.pdftoolshq-backend-upload-area {
    position: relative;
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed #3498db;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: #2980b9;
    background: #f1f8ff;
}

.drop-zone.is-dragover {
    border-color: #27ae60;
    background: #e8f6ef;
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.2);
}

.drop-zone-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
    color: #3498db;
    line-height: 1;
}

.drop-zone-text {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 5px 0;
    line-height: 1.4;
}

.drop-zone-hint {
    color: #7f8c8d;
    margin: 0 0 10px 0;
    font-size: 14px;
    line-height: 1.4;
}

.drop-zone-limit {
    color: #95a5a6;
    font-size: 12px;
    margin: 10px 0 0 0;
    line-height: 1.4;
}

.drop-zone-input {
    display: none;
}

/* File List */
.file-list {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.file-list h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.file-items {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    animation: slideIn 0.3s ease;
}

.file-item:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.file-name {
    flex: 1;
    color: #2c3e50;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.file-size {
    color: #7f8c8d;
    font-size: 12px;
    margin-right: 10px;
    white-space: nowrap;
    line-height: 1.4;
}

.remove-file {
    color: #e74c3c;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    padding: 0 5px;
    background: none;
    border: none;
    transition: color 0.2s ease;
}

.remove-file:hover {
    color: #c0392b;
}

.remove-file:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Sort buttons */
.sort-buttons {
    margin: 10px 0;
    display: flex;
    gap: 10px;
}

.sort-up,
.sort-down {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
}

.sort-up:hover,
.sort-down:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.sort-up:active,
.sort-down:active {
    transform: translateY(0);
}

.sort-up:focus,
.sort-down:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.merge-order-note {
    color: #95a5a6;
    font-size: 12px;
    margin: 10px 0 0 0;
    line-height: 1.4;
    font-style: italic;
}

/* Submit Button */
.pdftoolshq-backend-submit {
    display: block;
    width: 100%;
    padding: 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    line-height: 1.4;
}

.pdftoolshq-backend-submit:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.pdftoolshq-backend-submit:active {
    transform: translateY(0);
}

.pdftoolshq-backend-submit:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pdftoolshq-backend-submit:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    margin: 20px 0;
    animation: fadeIn 0.3s ease;
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 15px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading span {
    color: #7f8c8d;
    font-size: 16px;
    vertical-align: middle;
    line-height: 1.4;
}

/* Result */
.result {
    margin-top: 25px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
    animation: fadeIn 0.5s ease;
}

.result-content {
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.success-message {
    color: #27ae60;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.4;
}

.error-message {
    color: #e74c3c;
    font-size: 16px;
    padding: 15px;
    background: #fde8e8;
    border-radius: 6px;
    border-left: 4px solid #e74c3c;
    line-height: 1.4;
}

/* Download Section */
.download-section {
    text-align: center;
    margin: 20px 0;
}

.download-button {
    display: inline-block;
    padding: 12px 30px;
    background: #27ae60;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    line-height: 1.4;
}

.download-button:hover {
    background: #219653;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.download-button:focus {
    outline: 2px solid #27ae60;
    outline-offset: 2px;
}

/* PDF Info */
.pdf-info {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
}

.pdf-info h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.pdf-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pdf-info li {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
    color: #34495e;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.pdf-info li:last-child {
    border-bottom: none;
}

.pdf-info li strong {
    display: inline-block;
    width: 120px;
    color: #2c3e50;
    font-weight: 600;
    flex-shrink: 0;
}

/* Debug Info */
.debug-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #ddd;
}

.debug-info summary {
    cursor: pointer;
    color: #7f8c8d;
    font-size: 14px;
    user-select: none;
    padding: 5px 0;
    line-height: 1.4;
}

.debug-info summary:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.debug-info pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 6px;
    font-size: 12px;
    overflow: auto;
    max-height: 300px;
    margin-top: 10px;
    line-height: 1.5;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .drop-zone,
    .file-item,
    .pdftoolshq-backend-submit,
    .download-button,
    .result,
    .result-content {
        transition: none;
        animation: none;
    }
    
    .spinner {
        animation-duration: 2s;
    }
}

/* Focus styles for keyboard navigation */
:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .pdftoolshq-backend-upload-container,
    .pdftoolshq-backend-merge-container {
        padding: 20px;
        margin: 10px;
    }
    
    .pdftoolshq-backend-header h3 {
        font-size: 20px;
    }
    
    .pdftoolshq-backend-header p {
        font-size: 14px;
    }
    
    .drop-zone {
        padding: 30px 15px;
    }
    
    .drop-zone-icon {
        font-size: 36px;
    }
    
    .drop-zone-text {
        font-size: 16px;
    }
    
    .file-name {
        font-size: 13px;
    }
    
    .pdf-info li strong {
        width: 100px;
    }
    
    .pdftoolshq-backend-submit {
        padding: 12px;
        font-size: 16px;
    }
    
    .download-button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .pdftoolshq-backend-upload-container,
    .pdftoolshq-backend-merge-container {
        padding: 15px;
    }
    
    .file-item {
        flex-wrap: wrap;
    }
    
    .file-name {
        flex-basis: 100%;
        margin-bottom: 5px;
    }
    
    .pdf-info li {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .pdf-info li strong {
        width: auto;
        margin-bottom: 2px;
    }
}

/* Print styles */
@media print {
    .pdftoolshq-backend-submit,
    .drop-zone,
    .sort-up,
    .sort-down,
    .remove-file,
    .loading,
    .debug-info {
        display: none !important;
    }
    
    .pdftoolshq-backend-upload-container,
    .pdftoolshq-backend-merge-container {
        border: 1px solid #ccc;
        box-shadow: none;
        background: white;
    }
}