/* =========================================================
   PdfSynth — Public Stylesheet  v1.0.0
   ========================================================= */

/* Reset & Base */
.ps-wrap * { box-sizing: border-box; }
.ps-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    color: #1e293b;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* ── Filter Tabs ─────────────────────────────────────────── */
.ps-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 32px;
    padding: 0;
    border: none;
}
.ps-tab {
    padding: 9px 18px;
    border-radius: 100px;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.ps-tab:hover {
    border-color: #6366f1;
    color: #6366f1;
}
.ps-tab.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

/* ── Tool Grid ────────────────────────────────────────────── */
.ps-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
}

/* ── Tool Card ────────────────────────────────────────────── */
.ps-tool-card {
    background: #fff;
    border-radius: 14px;
    padding: 22px 18px 18px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid #e2e8f0;
    border-top: 4px solid var(--card-color, #6366f1);
    box-shadow: 0 1px 6px rgba(0,0,0,.05);
    transition: transform .18s, box-shadow .18s;
    position: relative;
    overflow: hidden;
}
.ps-tool-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--card-color, #6366f1);
    opacity: 0;
    transition: opacity .18s;
}
.ps-tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.ps-tool-card:hover::before { opacity: .04; }
.ps-tool-card.ps-hidden { display: none; }

.ps-card-icon { font-size: 2rem; line-height: 1; }
.ps-card-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
}
.ps-card-desc {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
    flex: 1;
}
.ps-card-arrow {
    font-size: 18px;
    color: var(--card-color, #6366f1);
    align-self: flex-end;
    transition: transform .18s;
}
.ps-tool-card:hover .ps-card-arrow { transform: translateX(4px); }

/* ── Breadcrumb ───────────────────────────────────────────── */
.ps-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
}
.ps-breadcrumb a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}
.ps-breadcrumb a:hover { text-decoration: underline; }

/* ── Tool Header ──────────────────────────────────────────── */
.ps-tool-header {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, var(--card-color,#6366f1) 0%, #4338ca 100%);
    border-radius: 16px;
    padding: 28px 32px;
    margin-bottom: 32px;
    color: #fff;
}
.ps-tool-header-icon { font-size: 3rem; flex-shrink: 0; }
.ps-tool-header h1 { font-size: 1.8rem; margin: 0 0 6px; color: #fff; }
.ps-tool-header p  { margin: 0; opacity: .85; font-size: 15px; }

/* ── Drop Zone ────────────────────────────────────────────── */
.ps-form { max-width: 720px; }

.ps-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
}
.ps-dropzone:hover,
.ps-dropzone.ps-drag-over {
    border-color: #6366f1;
    background: #eef2ff;
}
.ps-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.ps-dropzone-icon { font-size: 3rem; margin-bottom: 12px; }
.ps-dropzone-text {
    font-size: 16px;
    color: #475569;
    margin: 0 0 6px;
}
.ps-dropzone-text span {
    color: #6366f1;
    font-weight: 600;
    text-decoration: underline;
}
.ps-dropzone-sub { font-size: 13px; color: #94a3b8; margin: 0; }

/* ── File List ────────────────────────────────────────────── */
.ps-file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ps-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
}
.ps-file-item-icon { font-size: 1.3rem; }
.ps-file-item-name { flex: 1; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-file-item-size { color: #64748b; font-size: 13px; flex-shrink: 0; }
.ps-file-item-remove {
    cursor: pointer;
    color: #ef4444;
    font-size: 1.2rem;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
}

/* ── Options ──────────────────────────────────────────────── */
.ps-options {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.ps-option { display: flex; flex-direction: column; gap: 6px; }
.ps-option label { font-size: 13px; font-weight: 600; color: #475569; }
.ps-input,
.ps-option select {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    background: #fff;
    transition: border-color .2s;
    width: 100%;
}
.ps-input:focus,
.ps-option select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ── Buttons ──────────────────────────────────────────────── */
.ps-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 100px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    text-decoration: none;
}
.ps-btn:disabled { opacity: .45; cursor: not-allowed; }
.ps-btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.18); }

.ps-btn-primary {
    background: var(--btn-color, #6366f1);
    color: #fff;
    margin-top: 24px;
}
.ps-btn-download {
    background: #10b981;
    color: #fff;
}
.ps-btn-outline {
    background: transparent;
    color: #475569;
    border: 2px solid #e2e8f0;
}
.ps-btn-outline:hover { border-color: #6366f1; color: #6366f1; }

/* ── Progress ─────────────────────────────────────────────── */
.ps-progress-wrap {
    max-width: 720px;
    margin-top: 24px;
    text-align: center;
}
.ps-progress-bar {
    height: 6px;
    border-radius: 100px;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    background-size: 200% 100%;
    animation: ps-progress-anim 1.5s infinite linear;
}
@keyframes ps-progress-anim {
    0%   { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}
.ps-progress-label {
    margin-top: 10px;
    font-size: 14px;
    color: #64748b;
}

/* ── Result ───────────────────────────────────────────────── */
.ps-result {
    max-width: 720px;
    margin-top: 32px;
    padding: 36px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.ps-result-icon { font-size: 3rem; }
.ps-result h3 { margin: 0; font-size: 1.4rem; color: #166534; }

/* ── Error ────────────────────────────────────────────────── */
.ps-error-box {
    max-width: 720px;
    margin-top: 20px;
    padding: 16px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #991b1b;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Ad Slot ──────────────────────────────────────────────── */
.ps-ad-slot {
    margin: 20px 0;
    text-align: center;
    overflow: hidden;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .ps-tools-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .ps-tool-header { flex-direction: column; text-align: center; padding: 24px 16px; }
    .ps-tool-header h1 { font-size: 1.4rem; }
    .ps-tabs { gap: 6px; }
    .ps-tab { padding: 7px 12px; font-size: 13px; }
    .ps-dropzone { padding: 32px 16px; }
    .ps-options { grid-template-columns: 1fr; }
}
@media (max-width: 400px) {
    .ps-tools-grid { grid-template-columns: 1fr; }
}

/* ── SPA routing additions ────────────────────────────────── */

/* Card is now a <button> not <a> */
button.ps-card {
    background: #fff;
    border-radius: 14px;
    padding: 22px 18px 18px;
    text-align: left;
    cursor: pointer;
    color: inherit;
    border: 1px solid #e2e8f0;
    border-top: 4px solid var(--c, #6366f1);
    box-shadow: 0 1px 6px rgba(0,0,0,.05);
    transition: transform .18s, box-shadow .18s;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    width: 100%;
}
button.ps-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
button.ps-card .ps-card-arrow {
    font-size: 18px;
    color: var(--c, #6366f1);
    align-self: flex-end;
    transition: transform .18s;
}
button.ps-card:hover .ps-card-arrow { transform: translateX(4px); }
button.ps-card .ps-card-icon { font-size: 2rem; line-height: 1; }
button.ps-card h3 { font-size: 15px; font-weight: 700; margin: 0; color: #0f172a; }
button.ps-card p  { font-size: 13px; color: #64748b; margin: 0; line-height: 1.5; flex: 1; }

/* Back button as link-style */
.ps-btn-link {
    background: none;
    border: none;
    color: #6366f1;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.ps-btn-link:hover { opacity: .8; }

/* ─────────────────────────────────────────────────────────
   EDIT PDF — in-browser editor
───────────────────────────────────────────────────────── */
.ps-edit-wrap { max-width: 960px; }

.ps-edit-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    border-radius: 10px 10px 0 0;
    padding: 10px 14px;
    color: #e2e8f0;
    font-size: 13px;
}
.pse-tool-label { font-weight: 600; color: #94a3b8; margin-right: 4px; }
.pse-tool, .pse-action {
    padding: 5px 11px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.pse-tool:hover, .pse-action:hover { background: #334155; }
.pse-tool.ps-active { background: #6366f1; border-color: #6366f1; color: #fff; }
.pse-divider { color: #475569; padding: 0 4px; }
.pse-pages { color: #94a3b8; font-size: 13px; white-space: nowrap; }

.ps-edit-toolbar label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #94a3b8;
}
.ps-edit-toolbar input[type="color"] {
    width: 28px; height: 24px;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    background: none;
}

.ps-edit-canvas-area {
    background: #475569;
    padding: 20px;
    border-radius: 0 0 10px 10px;
    overflow: auto;
    max-height: 70vh;
    display: flex;
    justify-content: center;
}
#pse-canvas-stack {
    position: relative;
    display: inline-block;
    box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
#pse-pdf-canvas  { display: block; }
#pse-draw-canvas {
    position: absolute;
    top: 0; left: 0;
    cursor: crosshair;
}

.ps-edit-footer {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
#pse-text-input-wrap { display: flex; align-items: center; gap: 8px; width: 100%; }
#pse-text-input {
    flex: 1;
    padding: 9px 14px;
    border: 2px solid #6366f1;
    border-radius: 8px;
    font-size: 14px;
}

.ps-error-inline {
    margin-top: 10px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 14px;
}

/* ─────────────────────────────────────────────────────────
   ASK PDF — chat interface
───────────────────────────────────────────────────────── */
.ps-ask-wrap { max-width: 760px; }

.ps-ask-doc-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #334155;
}
.ps-ask-doc-icon { font-size: 1.3rem; }

.ps-ask-messages {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.psa-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 88%;
}
.psa-msg-user {
    flex-direction: row-reverse;
    align-self: flex-end;
}
.psa-avatar {
    font-size: 1.4rem;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
}
.psa-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.psa-msg-ai .psa-bubble {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 4px 14px 14px 14px;
    color: #1e293b;
}
.psa-msg-user .psa-bubble {
    background: #6366f1;
    color: #fff;
    border-radius: 14px 4px 14px 14px;
}

/* Thinking animation */
.psa-dots { display: inline-flex; gap: 3px; }
.psa-dots span {
    width: 6px; height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: psa-dot-bounce 1.2s infinite ease-in-out;
}
.psa-dots span:nth-child(2) { animation-delay: .2s; }
.psa-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes psa-dot-bounce {
    0%,80%,100% { transform: scale(0.7); opacity: .5; }
    40%          { transform: scale(1);   opacity: 1; }
}

.ps-ask-input-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}
.ps-ask-input-row input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 100px;
    font-size: 14px;
    transition: border-color .2s;
    outline: none;
}
.ps-ask-input-row input:focus { border-color: #6366f1; }
.ps-ask-hint {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 8px;
    font-style: italic;
}

/* Active tab fix */
.ps-tab.ps-active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}
