/* ============================================================
   Tool Page Layout — mobile-first
   ============================================================ */
.tool-page { background-color: var(--bg-light); }

.workspace-section {
    padding: clamp(2rem, 5vw, 4rem) 0 clamp(3rem, 7vw, 6rem);
    min-height: 60vh;
}

.workspace-header {
    text-align: center;
    margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.workspace-header h1 {
    font-size: clamp(1.5rem, 4vw + 0.5rem, 2.5rem);
    margin-bottom: 0.5rem;
}

.workspace-header p {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text-body);
}

.workspace-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

/* ============================================================
   Workspace States
   ============================================================ */
.workspace-state {
    padding: clamp(1.25rem, 5vw, 3rem);
    width: 100%;
    display: none;
    animation: fadeIn 0.35s ease-in-out;
}

.workspace-state.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   File List (review state)
   ============================================================ */
.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
}

.file-list-header h3 { font-size: clamp(0.95rem, 2vw, 1.1rem); }

.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1.5rem;
    max-height: 320px;
    overflow-y: auto;
    /* Smooth momentum scroll on iOS */
    -webkit-overflow-scrolling: touch;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background-color: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
    gap: 0.5rem;
}

.file-item.sortable-ghost  { opacity: 0.35; background: var(--primary-light); }
.file-item.sortable-chosen { box-shadow: var(--shadow-md); border-color: var(--primary); background: var(--bg-white); }

.file-info { display: flex; align-items: center; gap: 0.75rem; min-width: 0; flex: 1; }
.file-info svg { color: #ef4444; flex-shrink: 0; }

.file-name {
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 0.375rem;
    line-height: 0;
    flex-shrink: 0;
    border-radius: 0.375rem;
    /* 44px touch target via min-width/height in base */
}

.remove-btn:hover { color: #ef4444; background: #fef2f2; }
.workspace-actions { text-align: center; }

/* ============================================================
   Processing State
   ============================================================ */
.processing-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 2rem) 0;
}

.spinner {
    width: clamp(48px, 8vw, 60px);
    height: clamp(48px, 8vw, 60px);
    border: 4px solid var(--primary-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.25rem;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.progress-bar-bg {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background-color: var(--border);
    border-radius: 4px;
    margin: 1.25rem 0 0.875rem;
    overflow: hidden;
}

.progress-bar-fill { height: 100%; background-color: var(--primary); width: 0%; transition: width 0.3s ease; }
.processing-subtext { font-size: 0.875rem; color: var(--text-muted); }

/* ============================================================
   Success State
   ============================================================ */
.success-container {
    text-align: center;
    padding: clamp(1.5rem, 4vw, 2rem) 0;
}

.success-icon {
    width: clamp(60px, 10vw, 80px);
    height: clamp(60px, 10vw, 80px);
    background-color: #dcfce7;
    color: #16a34a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
}

.success-icon svg { width: clamp(28px, 5vw, 40px); height: clamp(28px, 5vw, 40px); }
.success-container h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); margin-bottom: 0.5rem; }
.success-container p { color: var(--text-body); margin-bottom: 1.5rem; }
.success-actions { display: flex; flex-direction: column; gap: 0.875rem; align-items: center; }

/* ============================================================
   SEO Content Section
   ============================================================ */
.seo-content {
    padding: clamp(2.5rem, 5vw, 4rem) 0;
    border-top: 1px solid var(--border);
}

/* Mobile-first: single column */
.seo-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
.seo-text h2 { font-size: clamp(1.125rem, 2.5vw, 1.5rem); margin-bottom: 1rem; }
.seo-text ol { padding-left: 1.25rem; color: var(--text-body); }
.seo-text li { margin-bottom: 0.625rem; line-height: 1.6; }
.seo-text p { color: var(--text-body); line-height: 1.7; }

/* ============================================================
   Toggle button group (rotate)
   ============================================================ */
.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-toggle {
    padding: 0.625rem 1.125rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-white);
    color: var(--text-dark);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    /* Touch target: min 44px height via base.css */
}

.btn-toggle:hover { border-color: var(--primary); color: var(--primary); }
.btn-toggle.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================================
   Sortable page list (rearrange)
   ============================================================ */
.page-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    max-height: 340px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: grab;
    user-select: none;
    transition: var(--transition);
}

.page-list-item:active       { cursor: grabbing; }
.page-list-item.sortable-ghost  { opacity: 0.35; background: var(--primary-light); }
.page-list-item.sortable-chosen { box-shadow: var(--shadow-md); border-color: var(--primary); background: var(--bg-white); }

.drag-handle { color: var(--text-muted); display: flex; align-items: center; flex-shrink: 0; }

.page-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 0.375rem;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ============================================================
   Image preview grid (image-to-pdf)
   ============================================================ */
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100px, 100%), 1fr));
    gap: 0.625rem;
    margin-bottom: 1.5rem;
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.image-thumb {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-light);
}

.image-thumb img { width: 100%; height: 80px; object-fit: cover; display: block; }

.img-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.3rem 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-thumb {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    line-height: 1;
    transition: background 0.2s;
    /* Override base.css min-width/height for this tiny button */
    min-width: unset;
    min-height: unset;
}

.remove-thumb:hover { background: #ef4444; }

/* ============================================================
   Info / warning callout
   ============================================================ */
.info-box {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--primary-light);
    border: 1px solid rgba(14, 165, 233, 0.25);
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
}

.info-box svg { color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.info-box p   { font-size: 0.875rem; color: var(--text-body); line-height: 1.55; margin: 0; }

/* ============================================================
   Select & slider inputs
   ============================================================ */
.form-select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--bg-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    appearance: none;
    outline: none;
    transition: var(--transition);
    cursor: pointer;
}

.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.form-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    appearance: none;
    outline: none;
    cursor: pointer;
    margin-top: 0.5rem;
}

.form-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: #cbd5e0;
    border: none;
}

.form-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 0 3px var(--primary-light);
    margin-top: -7px;
}

.form-slider::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: #cbd5e0;
    border: none;
}

.form-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.slider-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.35rem; display: block; }

/* ============================================================
   Compression level picker
   ============================================================ */
.compress-level-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.625rem;
}

.compress-levels {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
}

.compress-level-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    text-align: left;
    width: 100%;
    font-family: inherit;
}

.compress-level-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.compress-level-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.clc-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.compress-level-card.active .clc-icon,
.compress-level-card:hover .clc-icon {
    background: white;
    color: var(--primary);
}

.clc-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.clc-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clc-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
    background: white;
    border: 1px solid var(--primary);
    border-radius: 999px;
    padding: 0.1rem 0.4rem;
}

.clc-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Compression meter bars */
.clc-bars {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
}

.clc-bars .bar {
    width: 6px;
    height: 16px;
    border-radius: 3px;
    background: var(--border);
    transition: background 0.15s;
}

.clc-bars .bar.active {
    background: var(--text-muted);
}

.compress-level-card.active .clc-bars .bar.active {
    background: var(--primary);
}

@media (min-width: 480px) {
    .compress-levels { flex-direction: row; }
    .compress-level-card { flex-direction: column; align-items: flex-start; gap: 0.625rem; flex: 1; }
    .clc-bars { margin-top: auto; }
}

/* ============================================================
   Watermark tool controls
   ============================================================ */

/* Type tabs */
.wm-type-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.wm-type-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.wm-type-tab:hover { border-color: var(--primary); }
.wm-type-tab.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.wm-section { margin-bottom: 1.25rem; }

/* Position grid */
.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pos-btn {
    padding: 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    font-size: 1.25rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.pos-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.pos-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* Page range tabs */
.page-range-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.pr-tab {
    flex: 1;
    padding: 0.625rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.pr-tab:hover { border-color: var(--primary); }
.pr-tab.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* Color input styling */
.form-color {
    height: 44px;
    padding: 0.5rem;
    cursor: pointer;
}

/* Image preview */
#image-preview {
    max-width: 200px;
    max-height: 100px;
    object-fit: contain;
}

/* ============================================================
   Two-column option row (watermark)
   ============================================================ */
/* Mobile-first: single column */
.option-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* ============================================================
   Password / Form inputs
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.125rem;
}

.form-group label { font-size: 0.9rem; font-weight: 500; color: var(--text-dark); }

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-dark);
    background-color: var(--bg-white);
    transition: var(--transition);
    outline: none;
    /* Prevent iOS zoom on focus (font-size >= 16px) */
}

.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ============================================================
   480px breakpoint
   ============================================================ */
@media (min-width: 480px) {
    .image-preview-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ============================================================
   768px breakpoint
   ============================================================ */
@media (min-width: 768px) {
    .seo-grid { grid-template-columns: 1fr 1fr; gap: 4rem; }
    .option-row { grid-template-columns: 1fr 1fr; }
    .btn-group { justify-content: flex-start; }
}

/* ============================================================
   1024px breakpoint
   ============================================================ */
@media (min-width: 1024px) {
    .workspace-card { min-height: 420px; }
}
