.itp-hidden {
    display: none !important;
}

.itp-drop-zone.dragover {
    border-color: #2980b9;
    background-color: rgba(52, 152, 219, 0.1);
}

.itp-tool-container {
    position: relative;
    max-width: 1000px;
    margin: 0 auto 40px;
    padding: 20px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.itp-progress-view {
    padding: 20px 0;
}

.itp-tool-container>h2 {
    text-align: center;
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.8rem;
    font-weight: 500;
}

.itp-start-area {
    max-width: 600px;
    margin: 0 auto 15px;
    border: 2px dashed #3498db;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.itp-tool-container .itp-start-area:hover {
    border-color: #2980b9;
    background: rgba(52, 152, 219, 0.05);
}

.itp-file-input {
    display: none;
}

.itp-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-grow: 1;
    padding: 40px 20px;
}

.itp-drop-zone .itp-btn {
    pointer-events: none;
}

.itp-drop-zone h3 {
    color: #2c3e50;
    font-size: 1.3rem;
    margin: 20px 0 0;
}

.itp-drop-zone p {
    margin: 10px 0 0;
    color: #535A5B;
    margin-bottom: 15px;
}

/* Loading Overlay for initial load */
.itp-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    /* High z-index */
    border-radius: 10px;
}

.itp-loading-overlay .itp-spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #2c3e50;
}

.itp-spinner-container span {
    font-size: 18px;
    margin-top: 15px;
    font-weight: 500;
}

.itp-progress-header {
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.itp-thumbnail-loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: itp-spinner-anim 1s linear infinite;
    margin-right: 15px;
}

.itp-progress-container {
    flex-grow: 1;
    height: 20px;
    background-color: #ecf0f1;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.itp-progress-bar-inner {
    height: 100%;
    width: 0%;
    background-color: #3498db;
    transition: width 0.1s linear;
    border-radius: 10px;
}

.itp-progress-percentage-text {
    color: #2c3e50;
    font-size: 16px;
    font-weight: 500;
    margin-left: 10px;
    min-width: 40px;
    text-align: left;
}

.itp-animated-loading-text {
    text-align: center;
    margin-top: 10px;
    font-size: 17px;
    color: #555;
    height: 20px;
}

.itp-spinner {
    animation: itp-spinner-anim 1.5s linear infinite;
    width: 32px;
    height: 32px;
}

.itp-spinner {
    animation: itp-spinner-anim 1.5s linear infinite;
    width: 32px;
    height: 32px;
}

.itp-spinner .path {
    stroke: #2c3e50;
    stroke-linecap: round;
    animation: itp-dash-anim 1.5s ease-in-out infinite;
}

@keyframes itp-spinner-anim {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes itp-dash-anim {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }

    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Editor Section */
.itp-editor {
    margin-top: 30px;
}

.itp-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    position: relative;
    /* For loading overlay */
}

.itp-thumbnail {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    cursor: move;
    transition: all 0.2s;
    width: 150px;
    height: 200px;
    margin: 0 auto;
}

.itp-tool-container .itp-thumbnail:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.itp-thumbnail.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.itp-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.itp-tool-container .itp-page-number-input {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    width: 34px;
    text-align: center;
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.itp-page-number-input::-webkit-outer-spin-button,
.itp-page-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.itp-page-number-input {
    -webkit-user-select: none;
    /* Safari */
    -moz-user-select: none;
    /* Firefox */
    -ms-user-select: none;
    /* IE10+/Edge */
    user-select: none;
    /* Standard */
}

.itp-tool-container .itp-page-number-input:focus {
    background-color: #fff;
    color: #000;
    border: 1px solid #3498db;
    outline: none;
    cursor: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Thumbnail Controls */
.itp-thumbnail-controls {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
    pointer-events: none;
}

.itp-thumbnail:hover .itp-thumbnail-controls,
.itp-thumbnail-controls.mobile-visible {
    opacity: 1;
    pointer-events: auto;
}

.itp-thumbnail-btn {
    pointer-events: auto;
    position: relative;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease;
    background-color: rgba(44, 62, 80, 0.7);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
}

.itp-thumbnail-btn svg {
    width: 18px;
    height: 18px;
}

.itp-thumbnail-btn.clicked-zoom {
    transform: scale(1.2);
}

/* Prevent theme hover/focus effects */
.itp-tool-container .itp-thumbnail-btn:hover,
.itp-tool-container .itp-thumbnail-btn:active,
.itp-tool-container .itp-thumbnail-btn:focus {
    background-color: rgba(44, 62, 80, 0.7);
    color: white;
    box-shadow: none;
    outline: none;
}

/* Buttons */
.itp-tool-container .itp-thumbnail-btn:active {
    transform: scale(0.95);
}

.itp-actions {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    background: #fff;
    scroll-margin-top: 20px;
    z-index: 11;
    padding: 5px 10px;
}

.itp-main-buttons {
    display: flex;
    gap: 10px;
}

.itp-btn {
    padding: 8px 13px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.itp-view-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.itp-sort-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.itp-view-switcher {
    display: flex;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    overflow: hidden;
}

.itp-tool-container .itp-view-btn {
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.itp-view-btn.active {
    background-color: #e0e0e0;
    color: #2c3e50;
}

.itp-view-btn svg {
    width: 20px;
    height: 20px;
}

.itp-sort-label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 16px;
}

.itp-icon-btn {
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ecf0f1;
    color: #2c3e50;
    line-height: 1;
}

/* Prevent theme hover/focus effects on icon button */
.itp-tool-container .itp-icon-btn:hover,
.itp-tool-container .itp-icon-btn:active,
.itp-tool-container .itp-icon-btn:focus {
    background: #ecf0f1;
    color: #2c3e50;
    box-shadow: none;
    outline: none;
}

.itp-tool-container .itp-icon-btn:active {
    transform: scale(0.95);
}

.itp-tool-container .itp-sort-select {
    padding: 7px 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: #2c3e50;
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='22' height='22' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 3px center;
    padding-right: 40px;
}

/* Prevent theme hover/focus effects and highlight border */
.itp-tool-container .itp-sort-select:hover,
.itp-tool-container .itp-sort-select:active,
.itp-tool-container .itp-sort-select:focus {
    border-color: #bdc3c7;
    background-color: #fff;
    box-shadow: none;
    outline: none;
    color: #2c3e50;
}

.itp-sort-select:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.itp-sorting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 4px;
    font-size: 24px;
    color: #2c3e50;
}

.itp-sorting-overlay span {
    font-size: 16px;
    margin-top: 10px;
}

.itp-clear-btn {
    background: #ecf0f1;
    color: #2c3e50;
}

/* Prevent theme hover/focus effects */
.itp-tool-container .itp-clear-btn:hover,
.itp-tool-container .itp-clear-btn:active,
.itp-tool-container .itp-clear-btn:focus {
    background: #ecf0f1;
    color: #2c3e50;
    box-shadow: none;
    outline: none;
}

.itp-tool-container .itp-clear-btn:active {
    transform: scale(0.95);
}

.itp-primary-btn {
    background: #1f6a9c;
    /* Darker blue for better contrast */
    color: white;
}

/* Prevent theme hover/focus effects */
.itp-tool-container .itp-primary-btn:hover,
.itp-tool-container .itp-primary-btn:active,
.itp-tool-container .itp-primary-btn:focus {
    background: #1f6a9c;
    color: white;
    box-shadow: none;
    outline: none;
}

.itp-tool-container .itp-primary-btn:active {
    transform: scale(0.95);
}

/* Result Section */
.itp-result {
    margin-top: 30px;
    text-align: center;
}

.itp-success-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.itp-success-icon {
    width: 50px;
    height: 50px;
    color: #27ae60;
    margin-bottom: 15px;
}

.itp-result-title {
    margin: 0;
    color: #2c3e50;
}

.itp-result-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.itp-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: itp-spinner-anim 0.8s linear infinite;
    margin-left: 8px;
}

#itp-download.itp-is-downloading .itp-btn-spinner {
    display: inline-block;
}

#itp-download.itp-is-downloading .itp-btn-text {
    margin-right: 8px;
}

#itp-download:disabled {
    cursor: not-allowed;
    background-color: #5a8fb3;
    /* A slightly muted version of the primary color */
}


/* Fullscreen Modal */
.itp-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.itp-close-fullscreen {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1001;
    /* Ensure button is on top of the image */
}

/* Prevent theme hover/focus effects */
.itp-tool-container .itp-close-fullscreen:hover,
.itp-tool-container .itp-close-fullscreen:active,
.itp-tool-container .itp-close-fullscreen:focus {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    box-shadow: none;
    outline: none;
}

.itp-tool-container .itp-close-fullscreen:active {
    transform: scale(0.95);
}

#itp-fullscreen-image {
    max-width: 90%;
    max-height: 90%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* List View Styles */
.itp-thumbnails.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-view .itp-thumbnail {
    box-sizing: border-box;
    /* Ensure padding is included in the width */
    width: 100%;
}

.list-view .itp-thumbnail {
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 15px;
    background: #f8f9fa;
    -webkit-user-select: none;
    /* Safari */
    -moz-user-select: none;
    /* Firefox */
    -ms-user-select: none;
    /* IE10+/Edge */
    user-select: none;
    /* Standard */
}

.list-view .itp-thumbnail img {
    width: 60px;
    height: 80px;
    object-fit: contain;
    border: 1px solid #eee;
    border-radius: 4px;
    background: #fff;
}

.list-view .itp-thumbnail-info {
    flex-grow: 1;
    text-align: left;
}

.list-view .itp-thumbnail-name {
    font-weight: 500;
    color: #2c3e50;
    word-break: break-all;
}

.list-view .itp-thumbnail-size {
    font-size: 0.85rem;
    color: #777;
}

.itp-result-info {
    font-size: 17px;
    text-align: center;
    color: #555;
    margin: 0;
    word-break: break-all;
    /* Prevent long filenames from overflowing */
}

.itp-result-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 15px 0;
    padding: 10px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    background-color: #f8f9fa;
    width: 100%;
    max-width: 300px;
}

/* SortableJS customization */
.sortable-ghost {
    opacity: 0.5;
    background: #c8ebfb;
}

.sortable-fallback {
    opacity: 0.85;
    background: #ffffff;
    border-radius: 4px;
    /* Make the item feel "lifted" */
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    cursor: move;
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

/* Settings Grid */
.itp-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 15px;
    padding: 15px;
    margin: 15px 0 0;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.itp-setting-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.itp-setting-group label {
    font-weight: 500;
    color: #2c3e50;
}

.itp-tool-container .itp-setting-input {
    padding: 8px 5px;
    border: 1px solid #bdc3c7;
    background-color: #fff;
    border-radius: 4px;
    font-size: 16px;
}

.itp-tool-container select.itp-setting-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='22' height='22' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    padding-right: 30px;
}

.itp-setting-input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

/* --- Theme Override for Inputs & Selects --- */
/* Base style for all states to override theme defaults */
.itp-tool-container .itp-setting-input,
.itp-tool-container .itp-sort-select {
    background-color: #fff;
    border-radius: 4px;
    box-shadow: none;
}

/* Override hover/active states to maintain consistency */
.itp-tool-container .itp-setting-input:hover,
.itp-tool-container .itp-sort-select:hover,
.itp-tool-container .itp-setting-input:active,
.itp-tool-container .itp-sort-select:active {
    background-color: #fff;
    box-shadow: none;
}

/* Hide spinners from number inputs */
.itp-tool-container input[type="number"] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.itp-tool-container input[type=number]::-webkit-inner-spin-button,
.itp-tool-container input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Add a highlighted border on focus for better UX */
.itp-tool-container .itp-setting-input:focus,
.itp-tool-container .itp-sort-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.2);
    outline: none;
}

.itp-error-container {
    padding: 0 15px;
}

.itp-error-msg {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 5px;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .itp-tool-container {
        padding-left: 0;
        padding-right: 0;
        margin: 0 auto 50px;
        box-shadow: none;
        border-top: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
        border-radius: 0;
    }

    .itp-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        padding-left: 10px;
        padding-right: 10px;
    }

    .itp-thumbnail {
        width: 130px;
        height: 175px;
    }

    .itp-actions {
        flex-direction: column;
        padding: 5px 0 8px 0;
    }

    /* Collapsible Options Section - Mobile Only */
    .itp-options-section {
        background-color: #f8f9fa;
        border-radius: 8px;
        margin: 15px 0;
        border: 1px solid #e9ecef;
    }

    .itp-options-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        user-select: none;
        padding: 8px;
    }

    .itp-options-title {
        margin: 0;
        font-size: 17px;
        font-weight: 500;
        color: #2c3e50;
    }

    .itp-options-toggle-icon {
        transition: transform 0.3s ease;
        width: 24px;
        height: 24px;
        background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: center;
        transform: rotate(0deg);
    }

    .itp-options-section:not(.collapsed) .itp-options-toggle-icon {
        transform: rotate(180deg);
    }

    .itp-options-content {
        overflow: hidden;
        transition: max-height 0.4s ease-out, padding 0.4s ease-out, margin-top 0.4s ease-out;
        max-height: 1000px;
        /* Large enough value */
        padding: 15px;
        margin-top: 0;
        border-top: 1px solid #e9ecef;
    }

    .itp-options-section.collapsed .itp-options-content {
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-top: 0;
        border-top: none;
    }

    .itp-settings-grid {
        background-color: transparent;
        padding: 0;
        margin: 0;
    }

    .itp-options-section .itp-settings-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }

    .itp-tool-container .itp-sort-select {
        padding: 8px 25px 8px 8px;
    }

    .itp-thumbnail-controls {
        opacity: 1;
    }

    .itp-tool-container h2 {
        font-size: 1.5rem;
    }

    .itp-btn {
        padding: 8px;
    }

    .itp-thumbnails {
        padding-left: 0;
        padding-right: 0;
    }

    .list-view .itp-thumbnail {
        padding: 10px 5px;
    }

    .itp-result-details {
        max-width: 90%;
    }
    
    .itp-tool-container .itp-page-number-input {
        padding: 3px;
        width: 40px;
    }
    
}    

/* Desktop Styles: Override mobile collapsible behavior */
@media (min-width: 769px) {
    .itp-options-section {
        border: none;
        background-color: transparent;
        margin: 0;
    }

    .itp-options-header {
        display: none;
        /* Hide the "PDF Options" header on desktop */
    }

    .itp-options-content {
        padding: 0;
        /* Remove padding from the content wrapper */
    }
}

.itp-options-header {
    display: none;
}