/* Shared layout for Technochiya PDF tools. */

.pdf-tool-section {
    --pdf-danger: #b42318;
    --pdf-success: #2f7d4a;
    --pdf-working: #805019;

    max-width: var(--tc-max-width);
    margin-inline: auto;
}

.pdf-tool-card [hidden] {
    display: none !important;
}

.pdf-tool-card {
    margin-top: 2.5rem;
    padding: clamp(1.1rem, 4vw, 2.5rem);

    background: var(--tc-white);
    border: 1px solid var(--tc-border);
    border-radius: 24px;

    box-shadow: 0 24px 70px rgba(23, 36, 51, 0.1);
}

.pdf-drop-zone {
    padding: clamp(2.5rem, 8vw, 5rem) 1.5rem;
    text-align: center;

    background: rgba(166, 106, 36, 0.04);
    border: 2px dashed var(--tc-border);
    border-radius: 20px;

    transition:
        border-color 180ms ease,
        background-color 180ms ease,
        transform 180ms ease;
}

.pdf-drop-zone.drag-active {
    background: rgba(166, 106, 36, 0.12);
    border-color: var(--tc-copper);
    transform: scale(1.01);
}

.pdf-drop-zone h3 {
    margin: 1rem 0 0.5rem;
    font-size: clamp(1.25rem, 3vw, 1.6rem);
}

.pdf-drop-zone > p:not(.status-message) {
    margin: 0 0 1.5rem;
}

.pdf-drop-zone .status-message {
    text-align: center;
}

.pdf-workspace {
    display: grid;
    gap: 1.5rem;
}

.pdf-workspace-heading,
.pdf-list-heading,
.pdf-source-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;

    padding-bottom: 1rem;
    border-bottom: 1px solid var(--tc-border);
}

.pdf-workspace-heading h3,
.pdf-list-heading h3,
.pdf-source-summary h3 {
    margin: 0 0 0.2rem;
    font-size: 1.15rem;
}

.pdf-workspace-heading p,
.pdf-list-heading p,
.pdf-source-summary p {
    margin: 0;
    color: var(--tc-text-muted);
    font-size: 0.84rem;
}

.pdf-heading-actions,
.pdf-actions,
.pdf-item-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.pdf-tool-section .btn-secondary {
    color: var(--tc-copper-dark);
    background: var(--tc-white);
    border: 1px solid var(--tc-border);
}

.pdf-tool-section .btn-secondary:hover {
    color: var(--tc-white);
    background: var(--tc-copper);
    border-color: var(--tc-copper);
}

.pdf-tool-section .btn:disabled,
.pdf-tool-section button:disabled,
.pdf-tool-section input:disabled,
.pdf-tool-section select:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    transform: none;
}

.pdf-file-list {
    display: grid;
    gap: 0.85rem;
}

.pdf-file-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;

    padding: 0.9rem;

    background: var(--tc-cream);
    border: 1px solid var(--tc-border);
    border-radius: 14px;
}

.pdf-file-order {
    display: grid;
    place-items: center;

    width: 40px;
    height: 40px;

    color: var(--tc-white);
    font-size: 0.82rem;
    font-weight: 800;

    background: var(--tc-copper);
    border-radius: 11px;
}

.pdf-file-information {
    min-width: 0;
}

.pdf-file-information strong,
.pdf-file-information span {
    display: block;
}

.pdf-file-information strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-file-information span {
    margin-top: 0.25rem;
    color: var(--tc-text-muted);
    font-size: 0.78rem;
}

.pdf-icon-button {
    min-height: 38px;
    padding: 0.5rem 0.65rem;

    color: var(--tc-heading);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;

    background: var(--tc-white);
    border: 1px solid var(--tc-border);
    border-radius: 8px;
    cursor: pointer;
}

.pdf-icon-button:hover:not(:disabled) {
    color: var(--tc-white);
    background: var(--tc-copper);
    border-color: var(--tc-copper);
}

.pdf-icon-button.remove {
    color: var(--pdf-danger);
}

.pdf-icon-button.remove:hover:not(:disabled) {
    color: var(--tc-white);
    background: var(--pdf-danger);
    border-color: var(--pdf-danger);
}

.pdf-settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;

    padding: 1.2rem;

    background: var(--tc-cream);
    border: 1px solid var(--tc-border);
    border-radius: 16px;
}

.pdf-setting-field {
    display: grid;
    align-content: start;
    gap: 0.55rem;
}

.pdf-setting-field > span,
.pdf-setting-field > label,
.pdf-setting-label {
    color: var(--tc-heading);
    font-size: 0.88rem;
    font-weight: 700;
}

.pdf-setting-field input,
.pdf-setting-field select,
.pdf-setting-field textarea {
    width: 100%;
    min-height: 48px;
    padding: 0.72rem 0.85rem;

    color: var(--tc-heading);
    font: inherit;

    background: var(--tc-white);
    border: 1px solid var(--tc-border);
    border-radius: 9px;
    outline: none;
}

.pdf-setting-field textarea {
    min-height: 94px;
    resize: vertical;
}

.pdf-setting-field input:focus,
.pdf-setting-field select:focus,
.pdf-setting-field textarea:focus {
    border-color: var(--tc-copper);
    box-shadow: 0 0 0 3px rgba(166, 106, 36, 0.16);
}

.pdf-setting-help {
    margin: 0;
    color: var(--tc-text-muted);
    font-size: 0.75rem;
}

.pdf-checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;

    width: fit-content;

    color: var(--tc-heading);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
}

.pdf-checkbox-field input {
    width: 18px;
    height: 18px;
    accent-color: var(--tc-copper);
}

.pdf-range-setting {
    display: grid;
    gap: 0.65rem;
}

.pdf-range-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pdf-range-heading label {
    color: var(--tc-heading);
    font-size: 0.88rem;
    font-weight: 700;
}

.pdf-range-heading output {
    min-width: 60px;
    padding: 0.25rem 0.55rem;

    color: var(--tc-copper-dark);
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;

    background: rgba(166, 106, 36, 0.1);
    border-radius: 999px;
}

.pdf-range-setting input[type="range"] {
    width: 100%;
    accent-color: var(--tc-copper);
}

.pdf-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 1rem;
}

.pdf-page-card {
    position: relative;
    min-width: 0;
    padding: 0.75rem;

    background: var(--tc-cream);
    border: 1px solid var(--tc-border);
    border-radius: 13px;

    transition:
        border-color 160ms ease,
        opacity 160ms ease,
        transform 160ms ease;
}

.pdf-page-card:hover {
    border-color: var(--tc-copper);
}

.pdf-page-card.dragging {
    opacity: 0.45;
    transform: scale(0.98);
}

.pdf-page-card.deleted {
    opacity: 0.48;
}

.pdf-page-thumbnail {
    display: grid;
    place-items: center;

    width: 100%;
    min-height: 180px;
    overflow: hidden;

    background: #e9e6e1;
    border-radius: 9px;
}

.pdf-page-thumbnail canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.pdf-page-card h4 {
    margin: 0.7rem 0 0.15rem;
    font-size: 0.88rem;
}

.pdf-page-card p {
    margin: 0;
    color: var(--tc-text-muted);
    font-size: 0.72rem;
}

.pdf-page-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.pdf-page-controls button {
    min-height: 34px;
    padding: 0.4rem;

    color: var(--tc-heading);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;

    background: var(--tc-white);
    border: 1px solid var(--tc-border);
    border-radius: 7px;
    cursor: pointer;
}

.pdf-page-controls button:hover:not(:disabled) {
    color: var(--tc-white);
    background: var(--tc-copper);
    border-color: var(--tc-copper);
}

.pdf-page-card.selected {
    border-color: var(--tc-copper);
    box-shadow: 0 0 0 3px rgba(166, 106, 36, 0.12);
}

.pdf-progress {
    width: 100%;
    height: 10px;
    overflow: hidden;

    background: var(--tc-border);
    border-radius: 999px;
}

.pdf-progress-bar {
    width: 0;
    height: 100%;

    background: var(--tc-copper);
    border-radius: inherit;

    transition: width 180ms ease;
}

.pdf-tool-section .status-message {
    min-height: 1.5rem;
    margin: 0;
    text-align: right;
}

.pdf-tool-section .status-message.status-working {
    color: var(--pdf-working);
}

.pdf-tool-section .status-message.status-success {
    color: var(--pdf-success);
}

.pdf-tool-section .status-message.status-error {
    color: var(--pdf-danger);
}

@media (max-width: 720px) {
    .pdf-tool-card {
        padding: 1rem;
        border-radius: 18px;
    }

    .pdf-file-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .pdf-item-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .pdf-actions,
    .pdf-heading-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .pdf-actions .btn,
    .pdf-heading-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .pdf-tool-section .status-message {
        text-align: center;
    }
}

@media (max-width: 440px) {
    .pdf-file-item {
        grid-template-columns: 1fr;
    }

    .pdf-file-order {
        width: 34px;
        height: 34px;
    }

    .pdf-file-information strong {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .pdf-page-grid {
        grid-template-columns: 1fr;
    }
}
