 :root {
     --primary-red: #e5322d;
     --primary-red-dark: #c42a25;
     --text-dark: #383e45;
     --text-light: #878d95;
     --border-color: #e8e8f0;
     --background-light: #f8fafc;
     --background-white: #ffffff;
     /* --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; */
     --header-height: 60px;
     --navy: #1e293b;
     --cream: #f1f5f9;
     --gold: #f59e0b;
     --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
 }

 /* Modal Styles */
 .modal {
     display: none;
     position: fixed;
     z-index: 1000;
     left: 0;
     top: 0;
     width: 100%;
     height: 100%;
     overflow: auto;
     background-color: rgba(0, 0, 0, 0.6);
     align-items: center;
     justify-content: center;
     backdrop-filter: blur(4px);
 }

 .modal.active {
     display: flex;
 }

 .modal-content-merge {
     background-color: var(--background-white);
     margin: auto;
     padding: 0;
     border-radius: 16px;
     width: 95%;
     max-width: 900px;
     max-height: 90vh;
     position: relative;
     animation: modalSlideIn 0.3s ease;
     display: flex;
     flex-direction: column;
     box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
 }

 @keyframes modalSlideIn {
     from {
         opacity: 0;
         transform: translateY(-50px) scale(0.95);
     }

     to {
         opacity: 1;
         transform: translateY(0) scale(1);
     }
 }

 .modal-header-merge {
     padding: 24px 30px;
     border-bottom: 1px solid var(--border-color);
     display: flex;
     justify-content: space-between;
     align-items: center;
 }

 .modal-header-merge h2 {
     font-size: 1.5rem;
     font-weight: 600;
     color: var(--text-dark);
 }

 .close-button {
     color: #aaa;
     font-size: 28px;
     font-weight: bold;
     cursor: pointer;
     transition: color 0.2s ease;
     background: none;
     border: none;
     padding: 4px;
     border-radius: 44px;
 }

 .close-button:hover {
     color: var(--text-dark);
     background-color: #f3f4f6;
 }

 .modal-body-merge {
     padding: 30px;
     overflow-y: auto;
     flex: 1;
 }

 /* File Upload Styles */
 .tool-card-body-merge{
    width: 100%;
    height: auto;
 }
 #merge-pdf-interface{
    width: 100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
 }
 .drop-zone-merge {
    flex-direction: column;
    align-items: center;
    height: 70%;
    width: 60%;
    border: 2px dashed #3b82f6;
    border-radius: 12px;
    padding: 60px 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
 }

 .drop-zone-merge:hover {
     border-color: #3b82f6;
     background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
     transform: scale(1.02);
 }

 .drop-zone-merge.dragover {
     border-color: #3b82f6;
     background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
     transform: scale(1.02);
 }

 .upload-icon-merge {
     width: 64px;
     height: 64px;
     margin: 0 auto 20px auto;
     background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
     border-radius: 16px;
     display: flex;
     align-items: center;
     justify-content: center;
     transition: transform 0.3s ease;
     box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
 }

 .drop-zone-merge:hover .upload-icon-merge {
     transform: scale(1.1);
 }

 .upload-icon-merge svg {
     width: 32px;
     height: 32px;
     color: white;
 }

 .drop-zone-merge p {
     font-size: 1.1rem;
     color: var(--text-light);
     margin-bottom: 7px;
 }

 /* Error message styling */
 .error-message {
     color: var(--primary-red);
     font-size: 0.9rem;
     margin-top: 10px;
     font-weight: 500;
     text-align: center;
 }

 .select-file-btn-merge {
     background: linear-gradient(135deg, var(--primary-red) 0%, #dc2626 100%);
     color: white;
     padding: 12px 24px;
     border: none;
     border-radius: 8px;
     font-size: 1rem;
     font-weight: 600;
     cursor: pointer;
     transition: all 0.3s ease;
     box-shadow: 0 4px 12px rgba(229, 50, 45, 0.3);
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
 }

 .select-file-btn-merge:hover {
     transform: translateY(-2px);
     box-shadow: 0 8px 20px rgba(229, 50, 45, 0.4);
 }

 .select-file-btn-merge:disabled {
     background: #d1d5db;
     cursor: not-allowed;
     transform: none;
     box-shadow: none;
 }

 #merge-pdf-input {
     display: none;
 }

 /* Tool Options */
 .tool-options-merge {
     margin: 24px 0;
     padding: 20px;
     background: #f8fafc;
     border-radius: 12px;
     border: 1px solid var(--border-color);
 }

 .tool-options-merge h3 {
     font-size: 1.1rem;
     font-weight: 600;
     color: var(--text-dark);
     margin-bottom: 16px;
 }

 .tool-options-merge label {
     display: block;
     margin-bottom: 8px;
     font-weight: 500;
     color: var(--text-dark);
 }

 .tool-options-merge input[type="text"],
 .tool-options-merge input[type="number"],
 .tool-options-merge select,
 .tool-options-merge input[type="range"] {
     width: 100%;
     padding: 12px;
     border: 1px solid var(--border-color);
     border-radius: 8px;
     margin-bottom: 16px;
     font-size: 0.9rem;
     transition: border-color 0.2s ease;
 }

 .tool-options-merge input[type="text"]:focus,
 .tool-options-merge input[type="number"]:focus,
 .tool-options-merge select:focus,
 .tool-options-merge input[type="range"]:focus {
     outline: none;
     border-color: #3b82f6;
     box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
 }

 /* Specific styles for radio buttons to align them right */
 .tool-options-merge .radio-group-merge {
     display: flex;
     align-items: center;
     justify-content: space-between;
     margin-bottom: 15px;
     flex-wrap: wrap;
 }

 .tool-options-merge .radio-group-merge label {
     margin-bottom: 0;
     margin-right: 10px;
     white-space: nowrap;
 }

 .tool-options-merge .radio-group-merge input[type="radio"] {
     width: auto;
     margin-bottom: 0;
     flex-shrink: 0;
     margin-left: 5px;
 }

 .tool-options-merge .radio-group-merge .radio-options {
     display: flex;
     gap: 15px;
     flex-wrap: wrap;
 }


 .disclaimer {
     font-size: 0.85rem;
     color: var(--text-light);
     background: #fffbeb;
     border: 1px solid #fbbf24;
     padding: 12px;
     border-radius: 8px;
     margin-top: 8px;
 }

 /* Process Button */
 .process-btn-merge {
     display: flex;
     flex-direction: row;
     justify-content: center;
     align-items: center;
     gap: 10px;
     width: 327px;
    background: #e5322d;
     color: white;
     padding: 13px;
     border: none;
     border-radius: 12px;
     font-size: 1.2rem;
     font-weight: 600;
     cursor: pointer;
     margin-top: 20px;
     transition: all 0.3s ease;
 }

 .process-btn-merge:hover:not(:disabled) {
     /* transform: translateY(-2px); */
    box-shadow: 0 8px 20px rgba(46, 37, 37, 0.4);

 }

 .process-btn-merge:disabled {
     background: #d1d5db;
     cursor: not-allowed;
     transform: none;
     box-shadow: none;
 }

 /* Loading Overlay */
 .loader-container-merge {
     display: none;
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: rgba(255, 255, 255, 0.95);
     z-index: 1001;
     align-items: center;
     justify-content: center;
     flex-direction: column;
     border-radius: 16px;
     backdrop-filter: blur(4px);
 }

 .loader-container-merge.active {
     display: flex;
 }

 .loader-merge {
     border: 4px solid #f3f4f6;
     border-top: 4px solid var(--primary-red);
     border-radius: 50%;
     width: 60px;
     height: 60px;
     animation: spin 1s linear infinite;
 }

 .loader-text-merge {
     margin-top: 20px;
     font-weight: 600;
     color: var(--text-dark);
     font-size: 1.1rem;
 }

 @keyframes spin {
     0% {
         transform: rotate(0deg);
     }

     100% {
         transform: rotate(360deg);
     }
 }

 /* Output Area */
 .output-area-merge {
    flex-direction: column;
    align-items: center;
     
 }

 .output-area-merge.active {
     display: block;
 }

 .output-area-merge h3 {
     font-size: 1.1rem;
     font-weight: 600;
     color: #065f46;
     margin-bottom: 16px;
     display: flex;
     align-items: center;
 }

 .output-area-merge h3::before {
     content: '';
     width: 24px;
     height: 24px;
     background: linear-gradient(135deg, #10b981 0%, #059669 100%);
     border-radius: 6px;
     margin-right: 8px;
     display: flex;
     align-items: center;
     justify-content: center;
 }

 /* Styles for PDF Input/Output Preview and Image Input Preview */
 .pdf-input-preview-grid-merge,
 .image-input-preview-grid-merge,
 .pdf-output-preview-grid-merge {
     display: grid;
     justify-items: center;
     grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
     gap: 15px;
     /* margin-top: 20px; */
     height: 285px;
     overflow-y: auto;
     padding: 10px;
     border: 1px solid var(--border-color);
     border-radius: 8px;
     background-color: var(--background-light);
     display: none;
 }

 .pdf-input-preview-grid-merge.active,
 .image-input-preview-grid-merge.active,
 .pdf-output-preview-grid-merge.active {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    align-content: flex-start;
     gap: 15px;
    /* margin-top: 15px; */
    height: 385px;
    width: 60%;
    overflow-y: auto;
    padding: 10px;
    border: 10px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--background-light);
    justify-content: center;
    /* align-items: center; */
 }

 .pdf-input-preview-item-merge,
 .image-input-preview-item-merge,
 .pdf-output-item-merge {
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 5px;
     background-color: var(--background-white);
     border: 1px solid #ddd;
     border-radius: 5px;
     padding: 10px;
     box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
     position: relative;
     transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
     height: 335px;
     width: 180px;
     justify-content: space-between;
     overflow: hidden;
 }

 .pdf-input-preview-item-merge .image-wrapper-merge,
 .image-input-preview-item-merge .image-wrapper-merge,
 .pdf-output-item-merge .pdf-page-wrapper-merge {
     position: relative;
     width: 100%;
     height: 180px;
     display: flex;
     align-items: center;
     justify-content: center;
     margin-bottom: 8px;
     overflow: hidden;
 }

 .image-wrapper-merge canvas,
 .image-wrapper-merge img,
 .pdf-page-wrapper-merge canvas {
     width: 180px;
     height: 230px;
     border: 1px solid #eee;
     object-fit: contain;
     transform-origin: center center;
     transition: transform 0.2s ease-out;
 }

 .pdf-input-preview-item-merge p,
 .image-input-preview-item-merge p {
     font-size: 0.65rem;
     color: var(--text-dark);
     text-align: center;
     /* margin-bottom: 10px; */
     width: 100%;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
 }

 .pdf-input-preview-item-merge .action-buttons-container-merge,
 .image-input-preview-item-merge .action-buttons-container-merge,
 .pdf-output-item-merge .action-buttons-container-merge {
     display: flex;
     gap: 5px;
     justify-content: center;
     width: 100%;
     flex-wrap: wrap;
 }

 .pdf-input-preview-item-merge .action-buttons-container-merge button,
 .pdf-input-preview-item-merge .action-buttons-container-merge .download-link-small-merge,
 .image-input-preview-item-merge .action-buttons-container-merge button,
 .image-input-preview-item-merge .action-buttons-container-merge .download-link-small-merge,
 .pdf-output-item-merge .action-buttons-container-merge button,
 .pdf-output-item-merge .action-buttons-container-merge .download-link-small-merge {
     background-color: #007bff;
     color: white;
     padding: 5px;
     border-radius: 4px;
     text-decoration: none;
     font-size: 0.8rem;
     transition: background-color 0.2s ease;
     border: none;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     flex-grow: 1;
     min-width: 30px;
     height: 30px;
 }

 .pdf-input-preview-item-merge .action-buttons-container-merge button.remove-btn-merge,
 .image-input-preview-item-merge .action-buttons-container-merge button.remove-btn-merge,
 .pdf-input-preview-item-merge .action-buttons-container-merge button.remove-pdf-btn-merge {
     /* Added for PDF remove */
     background-color: #f44336;
 }

 .pdf-input-preview-item-merge .action-buttons-container-merge button.rotate-pdf-btn-merge,
 .image-input-preview-item-merge .action-buttons-container-merge button.rotate-image-btn-merge {
     background-color: #4CAF50;
 }

 -merge .pdf-input-preview-item-merge .action-buttons-container-merge button.download-page-btn-merge,
 .image-input-preview-item-merge .action-buttons-container-merge button.download-original-image-btn-merge {
     background-color: #f59e0b;
 }


 .pdf-input-preview-item-merge .action-buttons-container-merge button:hover,
 .pdf-input-preview-item-merge .action-buttons-container-merge .download-link-small-merge:hover,
 .image-input-preview-item-merge .action-buttons-container-merge button:hover,
 .image-input-preview-item-merge .action-buttons-container-merge .download-link-small-merge:hover,
 .pdf-output-item-merge .action-buttons-container-merge button:hover,
 .pdf-output-item-merge .action-buttons-container-merge .download-link-small-merge:hover {
     opacity: 0.9;
 }


 .add-more-btn-merge {
     color: white;
     padding: 12px 24px;
     border: none;
     transition: all 0.3s ease;
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     margin-top: 20px;
     width: 100%;
     padding: 16px;
     border: none;
     border-radius: 12px;
     font-size: 1.2rem;
     font-weight: 600;
     cursor: pointer;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    margin-top: 20px;
    width: 330px;
 }

 .add-more-btn-merge:hover {
    box-shadow: 0 8px 20px rgba(46, 37, 37, 0.4);
 }

 .remove-pdf-btn-merge {
    background-color: #EF4444;
    border: none;
    border-radius: 4px;
    color: white;
    padding: 5px 10px;
    cursor: pointer;
    width: 100%;
}

 .clear-all-btn-merge {
    background: #e5322d;
     /* Red color for clear all */
     color: white;
     padding: 13px 24px;
     border: none;
     border-radius: 8px;
     font-size: 1.2rem;
     font-weight: 600;
     cursor: pointer;
     transition: all 0.3s ease;
     box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     margin-top: 20px;
     width: 100%;
 }

 .clear-all-btn-merge:hover {
     /* transform: translateY(-2px); */
         box-shadow: 0 8px 20px rgba(46, 37, 37, 0.4);

 }

 .back-to-upload-btn-merge {
     background: #454b51;
     color: white;
     color: white;
     padding: 16px;
     border: none;
     border-radius: 12px;
     font-size: 1rem;
     font-weight: 600;
     cursor: pointer;
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     margin-top: 30px;
     /* width: 100%; */
 }

 .back-to-upload-btn-merge:hover {
     /* transform: translateY(-2px); */
     box-shadow: 0 8px 20px rgba(108, 117, 125, 0.4);
 }

 .download-main-output-btn-merge {
      display: flex;
      align-items: center;
      background-color: #0cab77;
      color: white;
      padding: 24px 48px;
      font-weight: 600;
      font-size: 24px;
      border: none;
      border-radius: 8px;
      cursor: pointer;
      box-shadow: 0 3px 6px 0 rgba(0, 0, 0, .14);
      transition: background 0.3s ease;
      text-decoration: none; /* for <a> */
      font-family: Arial, Helvetica, sans-serif;
      gap: 15px;
 }

 .download-main-output-btn-merge:hover:not(:disabled) {
     /* transform: translateY(-2px); */
     background-color: #158f67f6;
 }

 /* Drag and Drop styles for reordering */
 .pdf-input-preview-item-merge .dragging {
     opacity: 0.5;
     border: 2px dashed #3b82f6;
 }

 .pdf-input-preview-item-merge .drag-over {
     border: 2px solid #3b82f6;
     box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
 }

 @media (max-width: 768px) {
    .title-header h2 {
        font-size: 1.5rem;
    }
    .download-main-output-btn-merge{
        font-size: 20px;
        padding: 18px 30px;
    }
    .title-header #output-heading {
        font-size: 1.3rem;
    }
    .modal-content-merge {
        width: 100%;
    }
    .pdf-input-preview-grid-merge.active, .image-input-preview-grid-merge.active, .pdf-output-preview-grid-merge.active{
        width: 90%;
    }
    .modal-body {
        padding: 10px;
        overflow-y: auto;
        flex: 1;
    }
    
 }

 @media (max-width: 580px) {
    .drop-zone-merge p {
        font-size: 1rem;
    }
    .select-file-btn-merge {
        font-size: 0.8rem;
    }

    .drop-zone-merge {
        flex-direction: column;
        align-items: center;
        height: 70%;
        width: 100%;
        border: 2px dashed #3b82f6;
        border-radius: 12px;
        padding: 20px 20px;
        cursor: pointer;
        transition: all 0.3s ease;
        text-align: center;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    }
}

@media screen and (max-width: 490px) {
    .add-more-btn-merge,.process-btn-merge{
        width: 240px;
        font-size: 1rem;
    }
}
@media screen and (max-width: 305px) {
        .pdf-input-preview-grid-merge.active, .image-input-preview-grid-merge.active, .pdf-output-preview-grid-merge.active {
        width: 250px;
    }
}