/* ============================================================
   TIB Prompt Engine v2 — Standalone Styles
   Extracted from prompt-engine-frontend, no Tailwind CDN needed.
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --tpe-paper: #fffdf5;
    --tpe-ink: #2d2d2d;
    --tpe-brand: #db7c00;
    --tpe-brand-50: #fff8f0;
    --tpe-brand-100: #ffecd6;
    --tpe-brand-600: #db7c00;
    --tpe-brand-700: #b86800;
    --tpe-slate-50: #f8fafc;
    --tpe-slate-100: #f1f5f9;
    --tpe-slate-200: #e2e8f0;
    --tpe-slate-300: #cbd5e1;
    --tpe-slate-400: #94a3b8;
    --tpe-slate-500: #64748b;
    --tpe-slate-600: #475569;
    --tpe-slate-700: #334155;
}

/* ---------- Reset for WP theme isolation ---------- */
.tpe-app *,
.tpe-app *::before,
.tpe-app *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---------- App Container ---------- */
.tpe-app {
    background-color: var(--tpe-paper);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--tpe-ink);
    width: 100%;
    max-width: 72rem;
    margin: 0.5rem auto;
    border: 2px solid var(--tpe-ink);
    border-radius: 2px 255px 3px 25px / 255px 5px 225px 3px;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    min-height: 700px;
    box-shadow: 5px 5px 0px rgba(0,0,0,0.2);
    line-height: 1.5;
    box-sizing: border-box;
}

/* ---------- Header ---------- */
.tpe-header {
    padding: 1rem 1.5rem;
    border-bottom: 2px dashed var(--tpe-slate-300);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--tpe-paper);
    position: relative;
    overflow: hidden;
}

.tpe-header-content { position: relative; z-index: 10; }

.tpe-header .tpe-badge {
    font-size: 0.75rem;
    font-weight: 900;
    background: black;
    color: white;
    padding: 0.125rem 0.5rem;
    transform: rotate(-2deg);
    display: inline-block;
}

.tpe-header h2 {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--tpe-ink);
    margin: 0;
    line-height: 1.3;
}

.tpe-header-desc {
    color: var(--tpe-slate-600);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.6;
    margin-top: 0.5rem;
}

.tpe-header-desc strong {
    color: var(--tpe-brand-600);
    background: var(--tpe-brand-50);
    padding: 0 0.25rem;
}

.tpe-header-desc ol {
    margin-top: 0.35rem;
    padding-left: 1.25rem;
    font-size: 0.85rem;
    color: var(--tpe-slate-600);
}

.tpe-header-emoji {
    font-size: 3.75rem;
    opacity: 0.2;
    transform: rotate(3deg);
    user-select: none;
    pointer-events: none;
}

/* ---------- Workbench Subheader ---------- */
.tpe-subheader {
    padding: 1rem 1.5rem;
    border-bottom: 2px dashed var(--tpe-slate-300);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--tpe-slate-50);
    position: relative;
    z-index: 20;
}

.tpe-subheader h2 {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--tpe-ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.tpe-subheader .tpe-pro-badge {
    font-size: 0.7rem;
    background: var(--tpe-brand-600);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    border: 2px solid black;
    transform: rotate(2deg);
    box-shadow: 1px 1px 0px black;
}

.tpe-subheader p {
    color: var(--tpe-slate-500);
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

/* ---------- Main Layout ---------- */
.tpe-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: rgba(255,255,255,0.5);
    min-width: 0;
}

@media (min-width: 768px) {
    .tpe-main { flex-direction: row; }
    .tpe-header h2 { font-size: 1.875rem; }
    .tpe-app { margin: 1.5rem auto; }
}

/* ---------- Navigation Sidebar ---------- */
.tpe-nav {
    width: 100%;
    border-bottom: 2px dashed var(--tpe-slate-200);
    flex-shrink: 0;
    display: flex;
    padding: 1rem;
    gap: 0.5rem;
    overflow-x: auto;
}

@media (min-width: 768px) {
    .tpe-nav {
        width: 16rem;
        border-bottom: none;
        border-right: 2px dashed var(--tpe-slate-200);
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

.tpe-nav-item {
    margin-bottom: 0;
    margin-right: 0.5rem;
    min-width: 35%;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .tpe-nav-item {
        margin-bottom: 0.5rem;
        margin-right: 0;
        min-width: 0;
    }
}

/* ---------- Buttons ---------- */
.tpe-btn-sketchy {
    border: 2px solid var(--tpe-ink);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    box-shadow: 2px 3px 0px rgba(0,0,0,0.8);
    transition: all 0.1s ease-in-out;
    background: white;
    color: var(--tpe-slate-700);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: inherit;
    line-height: 1.4;
}

@media (min-width: 768px) {
    .tpe-btn-sketchy {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

.tpe-btn-sketchy:hover {
    box-shadow: 1px 1px 0px rgba(0,0,0,0.8);
    transform: translate(1px, 2px);
    background: var(--tpe-slate-50);
}

.tpe-btn-sketchy.active {
    background-color: var(--tpe-brand);
    color: white;
}

.tpe-btn-sketchy .tpe-count {
    font-size: 0.7rem;
    opacity: 0.5;
    background: rgba(0,0,0,0.05);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.tpe-btn-sketchy .tpe-arrow {
    color: var(--tpe-slate-400);
}

@media (max-width: 767px) {
    .tpe-btn-sketchy .tpe-arrow { display: none; }
}

/* Child category buttons */
.tpe-btn-child {
    border: 2px solid transparent;
    border-bottom: 2px dashed var(--tpe-slate-200);
    transition: all 0.1s;
    border-radius: 3px;
    color: var(--tpe-slate-500);
    cursor: pointer;
    background: transparent;
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: inherit;
    font-weight: 400;
}

.tpe-btn-child:hover {
    background: var(--tpe-slate-50);
    color: var(--tpe-brand);
}

.tpe-btn-child.active {
    background: var(--tpe-brand-50);
    color: var(--tpe-brand);
    font-weight: 700;
    border: 2px solid var(--tpe-brand);
    border-radius: 8px;
}

.tpe-btn-child .tpe-child-count {
    font-size: 0.625rem;
    opacity: 0.4;
}

.tpe-sub-menu {
    margin-top: 0.25rem;
    padding-left: 1rem;
    display: none;
}

@media (min-width: 768px) {
    .tpe-sub-menu { display: block; }
}

.tpe-sub-menu > * + * { margin-top: 0.25rem; }

/* ---------- Card Grid ---------- */
.tpe-content {
    flex: 1;
    background: var(--tpe-paper);
    padding: 0.75rem;
    overflow-y: auto;
    position: relative;
    min-width: 0;
    width: 100%;
}

@media (min-width: 768px) {
    .tpe-content { padding: 1.25rem; }
}

.tpe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.25rem;
    padding-bottom: 5rem;
    min-width: 0;
    width: 100%;
}

.tpe-card-sketchy {
    border: 2px solid var(--tpe-ink);
    border-radius: 5px;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.15);
    transition: all 0.2s;
    background: white;
    padding: 1rem;
    cursor: pointer;
    min-height: 170px;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
    box-sizing: border-box;
}

.tpe-card-sketchy:hover {
    transform: rotate(-1deg) scale(1.02);
    box-shadow: 6px 6px 0px var(--tpe-brand);
    z-index: 10;
}

.tpe-card-title {
    font-weight: 900;
    color: var(--tpe-ink);
    font-size: 0.95rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.tpe-card-header {
    margin-bottom: 0.35rem;
    border-bottom: 2px dashed var(--tpe-slate-100);
    padding-bottom: 0.35rem;
    min-width: 0;
}

.tpe-card-desc {
    flex: 1;
    overflow: hidden;
    position: relative;
    margin-bottom: 0.5rem;
    min-width: 0;
}

.tpe-card-desc p {
    font-size: 0.75rem;
    color: var(--tpe-slate-500);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    word-break: break-word;
}

.tpe-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--tpe-slate-100);
}

.tpe-tag {
    font-size: 0.625rem;
    background: var(--tpe-brand-50);
    color: var(--tpe-brand-700);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    border: 1px solid var(--tpe-brand-100);
}

.tpe-grid-empty {
    grid-column: 1 / -1;
    padding: 2.5rem 0;
    opacity: 0.5;
    font-style: italic;
    text-align: center;
}

/* ---------- Footer ---------- */
.tpe-footer {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--tpe-slate-100);
    text-align: center;
    font-size: 0.75rem;
    color: var(--tpe-slate-400);
    padding-bottom: 0.5rem;
}

.tpe-footer p { margin: 0.25rem 0; }

/* ---------- Modal ---------- */
.tpe-modal-bg {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: rgba(45,45,45,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

@media (min-width: 768px) {
    .tpe-modal-bg { padding: 1.5rem; }
}

.tpe-modal-bg.hidden { display: none; }

.tpe-modal-container {
    background: var(--tpe-paper);
    border-radius: 0.5rem;
    border: 4px solid var(--tpe-ink);
    box-shadow: 8px 8px 0px black;
    width: 100%;
    max-width: 72rem;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.tpe-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 2px dashed var(--tpe-ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--tpe-brand-50);
    flex-shrink: 0;
}

.tpe-modal-title {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--tpe-ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 2.5rem;
    margin: 0;
}

.tpe-modal-title .tpe-title-icon { font-size: 1.875rem; }

.tpe-modal-title .tpe-title-text {
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: var(--tpe-brand-600);
}

.tpe-modal-close {
    color: var(--tpe-ink);
    border: 2px solid var(--tpe-ink);
    border-radius: 9999px;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0px black;
    cursor: pointer;
    background: transparent;
    font-size: 1rem;
    flex-shrink: 0;
    font-family: inherit;
}

.tpe-modal-close:hover {
    color: var(--tpe-brand-600);
    background: white;
}

/* Modal body */
.tpe-modal-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .tpe-modal-body {
        overflow: hidden;
        flex-direction: row;
    }
}

/* Left panel: inputs */
.tpe-modal-inputs-panel {
    width: 100%;
    background: var(--tpe-slate-50);
    padding: 1.5rem;
    border-bottom: 2px dashed var(--tpe-slate-200);
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .tpe-modal-inputs-panel {
        width: 20rem;
        border-bottom: none;
        border-right: 2px dashed var(--tpe-slate-200);
        overflow-y: auto;
    }
}

.tpe-modal-inputs-title {
    font-size: 0.875rem;
    font-weight: 900;
    color: var(--tpe-slate-500);
    text-transform: uppercase;
    margin-bottom: 1.25rem;
}

.tpe-modal-inputs-list > * + * { margin-top: 1.25rem; }

.tpe-input-group {
    padding-bottom: 1rem;
    border-bottom: 2px dashed var(--tpe-slate-200);
}

.tpe-input-group:last-child { border-bottom: none; }

.tpe-input-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.tpe-input-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--tpe-brand-600);
}

.tpe-input-label span {
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--tpe-slate-600);
    text-transform: uppercase;
}

.tpe-input-sketchy {
    border: 2px solid var(--tpe-slate-300);
    border-radius: 8px 2px 6px 3px;
    background-color: white;
    width: 100%;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--tpe-ink);
    line-height: 1.5;
}

.tpe-input-sketchy:focus {
    border-color: var(--tpe-brand);
    outline: none;
    box-shadow: 2px 2px 0px var(--tpe-brand);
}

textarea.tpe-input-sketchy {
    resize: none;
    height: 6rem;
}

.tpe-no-inputs {
    color: var(--tpe-slate-400);
    font-size: 0.75rem;
    text-align: center;
    padding: 1rem;
    background: var(--tpe-slate-100);
    border-radius: 5px;
    border: 2px dashed var(--tpe-slate-300);
}

/* Right panel: editor */
.tpe-modal-editor-panel {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    background: var(--tpe-paper);
    min-height: 60vh;
}

@media (min-width: 768px) {
    .tpe-modal-editor-panel {
        overflow: hidden;
        min-height: 0;
    }
}

.tpe-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tpe-editor-label {
    font-size: 0.875rem;
    font-weight: 900;
    color: var(--tpe-slate-600);
    text-transform: uppercase;
}

.tpe-editor-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tpe-version-select {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: white;
    border: 2px solid var(--tpe-slate-300);
    border-radius: 8px 2px 6px 3px;
    font-family: inherit;
    color: var(--tpe-ink);
}

.tpe-version-select:focus {
    border-color: var(--tpe-brand);
    outline: none;
}

.tpe-editable-badge {
    font-size: 0.75rem;
    background: #fef9c3;
    color: #854d0e;
    padding: 0.25rem 0.5rem;
    border: 1px solid #fde68a;
    border-radius: 4px;
}

.tpe-editor-textarea {
    flex: 1;
    width: 100%;
    background: white;
    border: 2px solid var(--tpe-slate-300);
    border-radius: 8px 2px 6px 3px;
    padding: 1.25rem;
    font-size: 0.875rem;
    color: var(--tpe-ink);
    line-height: 1.6;
    resize: none;
    font-family: inherit;
}

.tpe-editor-textarea:focus {
    border-color: var(--tpe-brand);
    outline: none;
    box-shadow: 2px 2px 0px var(--tpe-brand);
}

/* Bottom action bar */
.tpe-editor-actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 2px dashed var(--tpe-slate-100);
    margin-top: 1rem;
}

.tpe-editor-actions-left {
    display: flex;
    gap: 0.5rem;
}

.tpe-editor-actions-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tpe-action-btn {
    font-weight: 700;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    border: 2px solid var(--tpe-ink);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    box-shadow: 2px 3px 0px rgba(0,0,0,0.8);
    transition: all 0.1s ease-in-out;
}

.tpe-action-btn:hover {
    box-shadow: 1px 1px 0px rgba(0,0,0,0.8);
    transform: translate(1px, 2px);
}

.tpe-action-btn-secondary {
    background: var(--tpe-slate-100);
    color: var(--tpe-slate-700);
}

.tpe-action-btn-danger {
    background: #fef2f2;
    color: #dc2626;
}

.tpe-action-btn-danger.hidden { display: none; }

.tpe-copy-btn {
    background: var(--tpe-brand-600);
    color: white;
    padding: 0.75rem 2rem;
    font-size: 1.125rem;
}

.tpe-copy-feedback {
    font-size: 0.875rem;
    font-weight: 700;
    color: #16a34a;
    opacity: 0;
    transition: opacity 0.3s;
}

/* ---------- Scrollbar ---------- */
.tpe-scrollbar::-webkit-scrollbar { width: 8px; }
.tpe-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--tpe-slate-300);
    border-radius: 10px;
}

/* ---------- Loading state ---------- */
.tib-pe-loading {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--tpe-slate-400);
    font-size: 1rem;
}

/* ---------- Utility: truncate ---------- */
.tpe-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
