/* PrintBrain Knowledge Capture - Card-Based Interface */

/* ------------------------------------------------------------
   PressOS Dark UI Style Guide (foundation theme)
   ------------------------------------------------------------
   Background: #121212 (Cod Gray)
   Text: off-white for reduced glare
   Brand accent: #307FE2
   Depth: use lighter surface fills + borders (avoid heavy shadows)
------------------------------------------------------------- */

:root {
    --bg: #121212;
    --surface-1: #171717;
    --surface-2: #1f1f1f;
    --surface-3: #262626;
    --border: #2c2c2c;
    --border-strong: #3a3a3a;

    --text: #e5e7eb;        /* not pure white */
    --text-muted: #a1a1aa;
    --text-dim: #71717a;

    --brand: #307fe2;
    --brand-2: #2566c9;

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;

    --shadow-1: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 16px 38px rgba(0, 0, 0, 0.45);
}

/* PWA: Prevent text selection on mobile (better UX for swipe) */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* PWA: Prevent zoom on double-tap */
input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    padding: 20px;
    /* PWA: Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: contain;
    /* PWA: Safe area for notched devices */
    padding-top: calc(env(safe-area-inset-top) + 20px);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    color: var(--text);
}

.app-container {
    max-width: 920px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: var(--text);
    margin-bottom: 30px;
    padding-top: 10px;
}

.header h1 {
    font-size: 2.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 20px;
    margin-top: 10px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo {
    display: block;
    height: 54px;
    width: auto;
    object-fit: contain;
}

/* Hide the install button on desktop (keep mobile-only via JS/CSS) */
@media (min-width: 821px) {
    .install-btn {
        display: none !important;
    }
}

.tiny-link {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.tiny-link:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

/* Install Button */
.install-btn {
    background: var(--surface-2);
    color: var(--brand);
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: var(--shadow-1);
    transition: all 0.3s ease;
}

.install-btn:hover {
    background: var(--surface-3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

.install-btn:active {
    transform: translateY(0);
}

.progress {
    background: var(--surface-1);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
}

#progress-text {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.tab-btn {
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: rgba(48, 127, 226, 0.18);
    color: var(--text);
    border-color: rgba(48, 127, 226, 0.55);
    box-shadow: 0 10px 24px rgba(48, 127, 226, 0.12);
}

.tab-section {
    display: none;
}

.tab-section.active {
    display: block;
}

#progress-text {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--brand);
    transition: width 0.3s ease;
    width: 0%;
}

/* Card Container */
.card-container {
    position: relative;
    min-height: 60vh;
    margin-bottom: 40px;
    perspective: 1000px;
}

.card {
    position: absolute;
    width: 100%;
    height: auto;
    min-height: 60vh;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-2);
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, opacity 0.3s ease;
    cursor: grab;
    user-select: none;
    color: var(--text);
}

.card:active {
    cursor: grabbing;
}

.card.active {
    z-index: 10;
    transform: scale(1);
    opacity: 1;
}

.card.inactive {
    z-index: 1;
    transform: scale(0.95);
    opacity: 0.7;
}

.card-header {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}

.card-subheader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-subheader .tiny-link {
    font-size: 0.85rem;
    padding: 6px 10px;
}

.card-category {
    display: none;
}

.card-question {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

/* Global focus indicator visibility */
:focus-visible {
    outline: 2px solid rgba(48, 127, 226, 0.9);
    outline-offset: 2px;
}

.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.recording-section {
    width: 100%;
    text-align: center;
}

.record-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px;
    background: rgba(18, 18, 18, 0.86);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow: 0 -10px 24px rgba(0,0,0,0.45);
    z-index: 1200;
}

.record-btn {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: var(--text);
    border: none;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto;
    box-shadow: 0 12px 28px rgba(48, 127, 226, 0.22);
}

.record-btn:hover {
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    transform: translateY(-1px);
    box-shadow: 0 14px 32px rgba(48, 127, 226, 0.26);
}

.record-btn:active {
    transform: translateY(0);
    background: var(--brand-2);
}

.record-btn.recording {
    background: var(--danger);
    animation: pulse 1.5s infinite;
}

/* Transcript editor modal */
.edit-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.62);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    padding: 16px;
}

.edit-modal-content {
    background: var(--surface-2);
    width: min(800px, 95vw);
    border-radius: 16px;
    box-shadow: var(--shadow-2);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid var(--border);
}

.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-modal-header h3 {
    margin: 0;
    color: var(--text);
}

.edit-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text-muted);
}

.edit-close:hover {
    color: var(--text);
}

.edit-textarea {
    width: 100%;
    min-height: 320px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface-1);
    resize: vertical;
}

.edit-textarea:focus {
    outline: none;
    border-color: rgba(48, 127, 226, 0.65);
    box-shadow: 0 0 0 3px rgba(48,127,226,0.18);
}

.edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.recording-status {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--danger);
    font-weight: 600;
}

.recording-indicator {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.card-status {
    text-align: center;
    margin-top: 12px;
    padding: 8px;
    background: #141416;
    border-radius: 10px;
    border: 1px solid #2c2c31;
}

.status-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.recorded {
    background: #0f5132;
    color: #d1fae5;
}

.status-badge.pending {
    background: #332b10;
    color: #fcd34d;
}

/* Custom Node Section */
.custom-node-section {
    text-align: center;
}

.create-node-btn {
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid rgba(48, 127, 226, 0.6);
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
}

.create-node-btn:hover {
    background: rgba(48, 127, 226, 0.18);
    border-color: rgba(48, 127, 226, 0.75);
    box-shadow: 0 12px 28px rgba(48, 127, 226, 0.18);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 3000; /* above record bar */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.62);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--surface-2);
    margin: 5% auto;
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
}

.modal-content.modal-wide {
    max-width: 1200px;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

@media (min-width: 900px) {
    .modal-grid {
        grid-template-columns: 1.1fr 0.9fr;
        align-items: start;
    }
}

.modal-col {
    min-width: 0;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close:hover {
    color: var(--text);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: var(--surface-1);
    color: var(--text);
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: rgba(48, 127, 226, 0.65);
    box-shadow: 0 0 0 3px rgba(48,127,226,0.18);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.recording-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.tag-container.three-col {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.tag-library.condensed .tag-btn {
    padding: 6px 10px;
    font-size: 0.9rem;
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border);
    display: block;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.tag-library.condensed {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-1);
    min-height: 160px;
}

.tag-empty {
    color: #9ca3af;
    font-size: 0.95rem;
}

.tag-group-title {
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.tag-group.modal {
    margin-top: 6px;
    padding: 4px 2px;
    width: 100%;
}

.edit-tags .tag-group-list.three-col {
    display: grid !important;
}

#edit-tag-library {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    width: 100%;
}

.tag-group-list.three-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.tag-group-list.three-col .tag-btn {
    width: 100%;
    text-align: left;
}

.tag-btn:hover {
    background: var(--surface-3);
    border-color: rgba(48, 127, 226, 0.35);
}

.edit-tags {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.node-tags.review .node-actions.inline {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.tag {
    padding: 8px 16px;
    background: var(--surface-1);
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover {
    background: var(--surface-3);
}

.tag.selected {
    background: rgba(48, 127, 226, 0.22);
    color: var(--text);
}

.tag.suggested {
    background: rgba(245, 158, 11, 0.14);
    border: 2px dashed rgba(245, 158, 11, 0.55);
}

.tag-group {
    margin-bottom: 14px;
}

.tag-group-title {
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.tag-group-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Use two columns of tag groups inside the modals for faster scanning */
#tag-library,
#edit-node-tag-library {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 900px) {
    #tag-library,
    #edit-node-tag-library {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    #tag-library,
    #edit-node-tag-library {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.tag-btn {
    padding: 6px 10px;
    border-radius: 10px;
    line-height: 1.2;
    font-size: 0.9rem;
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border);
    display: block;
    width: 100%;
    text-align: left;
}

/* Tag buttons highlight */
.tag-btn.tag-selected {
    background: rgba(48, 127, 226, 0.22) !important;
    color: var(--text) !important;
    border-color: rgba(48, 127, 226, 0.65) !important;
}

.question-meta {
    width: 100%;
    margin-top: 20px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 12px;
    box-shadow: none;
    border: 1px solid var(--border);
}

.question-meta h4 {
    margin-bottom: 8px;
    color: var(--text);
}

.question-meta .meta-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.question-meta .meta-row:last-child {
    border-bottom: none;
}

.question-meta .meta-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.question-meta .meta-value {
    color: var(--text);
    font-size: 0.95rem;
}

.question-meta .meta-row.notes .meta-value {
    color: var(--text);
}

.question-selected {
    margin-top: 8px;
}

.selected-label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.question-followup {
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(48, 127, 226, 0.35);
    background: rgba(48, 127, 226, 0.10);
}

.question-followup pre {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.35;
}

.question-followup.blocked {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.10);
}

.transcript-text {
    width: 100%;
    white-space: pre-wrap;
    color: var(--text);
    font-size: 0.98rem;
    line-height: 1.45;
}

.transcript-text.collapsed {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
    overflow: hidden;
}

.transcript-text.expanded {
    display: block;
}

.ai-suggestion-content ul {
    margin: 8px 0 14px 20px;
    padding: 0;
    color: var(--text);
}

.ai-suggestion-content pre {
    margin: 0;
    white-space: pre-wrap;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92rem;
    line-height: 1.35;
}

.status-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--surface-3);
    color: var(--text);
    font-size: 0.85rem;
}

.status-pill.ghost {
    background: rgba(48, 127, 226, 0.16);
    color: var(--text);
}

.status-pill.ok {
    background: rgba(34, 197, 94, 0.14);
    color: var(--text);
}

.status-pill.warn {
    background: rgba(245, 158, 11, 0.16);
    color: var(--text);
}

.status-pill.danger {
    background: rgba(239, 68, 68, 0.14);
    color: var(--text);
}

.node-followup {
    margin-top: 10px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(48, 127, 226, 0.35);
    background: rgba(48, 127, 226, 0.10);
}

.node-followup pre {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.35;
}

.node-followup.blocked {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.10);
}
.node-error {
    color: var(--danger);
    font-weight: 600;
    margin: 6px 0;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    background: rgba(48, 127, 226, 0.14);
    color: var(--text);
    font-size: 0.8rem;
    margin-right: 6px;
}

.badge.ghost {
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
}

/* Swipe animations */
.card.swipe-left {
    animation: swipeLeft 0.2s ease forwards;
}

.card.swipe-right {
    animation: swipeRight 0.2s ease forwards;
}

@keyframes swipeLeft {
    to { transform: translateX(-40%) rotate(-4deg); opacity: 0.6; }
}

@keyframes swipeRight {
    to { transform: translateX(40%) rotate(4deg); opacity: 0.6; }
}

.tasks-header {
    background: var(--surface-1);
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-1);
    margin-bottom: 16px;
    width: 100%;
    border: 1px solid var(--border);
}

.tasks-note {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 90px;
}

.task-placeholder {
    background: var(--surface-1);
    border: 1px dashed var(--border-strong);
    padding: 14px;
    border-radius: 12px;
    box-shadow: var(--shadow-1);
    margin-bottom: 12px;
    color: var(--text);
}

.task-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow-1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.task-text {
    color: var(--text);
    font-weight: 600;
    line-height: 1.5;
}

.task-actions {
    margin-top: 8px;
}

/* Questions tab filters */
.question-filters {
    margin-bottom: 12px;
}

.question-filters-row {
    display: grid;
    grid-template-columns: auto auto 1.6fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.question-filter-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-1);
    color: var(--text);
    font-size: 0.95rem;
}

.question-filter-input:focus {
    outline: none;
    border-color: rgba(48, 127, 226, 0.65);
    box-shadow: 0 0 0 3px rgba(48,127,226,0.18);
}

.question-filters-note {
    margin-top: 6px;
}

@media (max-width: 760px) {
    .question-filters-row {
        grid-template-columns: 1fr 1fr;
    }
    .question-filters-row .question-filter-input {
        grid-column: span 2;
    }
    #qfilter-reset {
        grid-column: span 2;
        justify-self: start;
    }
}

/* Edge case form (Tasks tab) */
.edgecase-form {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.edgecase-grid {
    display: grid;
    grid-template-columns: 1.3fr 1.6fr 1fr auto;
    gap: 10px;
    align-items: end;
}

.edgecase-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.edgecase-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

.edgecase-input,
.edgecase-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-1);
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.4;
}

.edgecase-textarea {
    resize: vertical;
    min-height: 72px;
}

.edgecase-input:focus,
.edgecase-textarea:focus {
    outline: none;
    border-color: rgba(48, 127, 226, 0.65);
    box-shadow: 0 0 0 3px rgba(48,127,226,0.18);
}

.edgecase-checkbox {
    display: flex;
    align-items: center;
    padding-bottom: 2px;
}

.edgecase-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
    user-select: none;
}

.edgecase-advanced {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
}

.edgecase-advanced summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
    list-style: none;
}

.edgecase-advanced summary::-webkit-details-marker {
    display: none;
}

.edgecase-advanced summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    color: var(--text-muted);
}

.edgecase-advanced[open] summary::before {
    content: "▾";
}

.edgecase-advanced .edgecase-section {
    margin-top: 10px;
}

@media (max-width: 760px) {
    .edgecase-grid {
        grid-template-columns: 1fr;
    }
}

.task-date {
    font-size: 0.85rem;
}

.task-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-empty {
    color: var(--text-muted);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
}

.form-actions {
    position: static;
    background: transparent;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 0;
    padding-bottom: 0;
}

.form-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.form-actions button[type="button"] {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.form-actions button[type="button"]:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
}

.form-actions button[type="submit"] {
    background: var(--brand);
    color: var(--text);
}

.form-actions button[type="submit"]:hover {
    background: var(--brand-2);
}

.node-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 90px;
}

.node-item {
    background: var(--surface-2);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow-1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text);
}

.node-actions {
    margin-top: 10px;
}

.small-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: var(--brand);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
}

.small-btn:hover {
    background: var(--brand-2);
}

.small-btn.ghost {
    background: var(--surface-1);
    color: var(--text);
    border: 1px solid var(--border);
}

.small-btn.danger {
    background: var(--danger);
    color: var(--text);
}

.small-btn.danger:hover {
    background: #dc2626;
}

.small-btn.ghost:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
}

.small-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-label {
    color: var(--text);
    font-weight: 600;
}

.node-title {
    font-weight: 700;
    color: var(--text);
}

.node-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.node-snippet {
    color: var(--text);
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 14px;
    background: rgba(48, 127, 226, 0.14);
    color: var(--text);
    font-weight: 600;
    font-size: 0.85rem;
}

.custom-node-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.tasks-placeholder {
    background: var(--surface-1);
    border: 1px dashed var(--border-strong);
    color: var(--text);
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 90px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CHAT ARCHIVE STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.chat-messages {
    max-height: 60vh;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface-1);
    border-radius: var(--radius-md);
}

.chat-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border-left: 3px solid var(--border-strong);
}

.chat-message.chat-visitor {
    border-left-color: var(--brand);
    background: rgba(48, 127, 226, 0.08);
}

.chat-message.chat-operator {
    border-left-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}

.chat-message.chat-automation {
    border-left-color: var(--text-dim);
    background: var(--surface-2);
    opacity: 0.7;
}

.chat-actor {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.chat-content {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Order Drafts */
.order-details, .missing-fields, .quote-details {
    padding: 12px;
    background: var(--surface-1);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.status-pending {
    background: #f59e0b !important;
    color: #000 !important;
}

.status-sent {
    background: #22c55e !important;
    color: #000 !important;
}

.status-processing {
    background: #6b7280 !important;
    color: #fff !important;
}

.full-width {
    width: 100%;
    box-sizing: border-box;
}

/* Responsive */
@media (max-width: 768px) {
    .card {
        padding: 30px 20px;
    }
    
    .card-question {
        font-size: 1.4rem;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}


/* ============================================================================
   QUESTION QUEUE STYLES
   ============================================================================ */

.question-filters-simple {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: var(--surface-1);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--brand);
    background: var(--surface-3);
}

.filter-btn.active {
    border-color: var(--brand);
    background: var(--brand);
    color: white;
}

.question-queue {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.question-card {
    background: var(--surface-1);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.3s;
    color: var(--text);
}

.question-card.blocking {
    border-color: var(--danger);
    border-width: 3px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.question-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-color: var(--brand);
}

.question-answer {
    font-size: 14px;
    line-height: 1.5;
}

.question-answer:focus {
    outline: 2px solid #886A49;
    border-color: #886A49;
}

.btn-submit:hover {
    background: #45a049 !important;
}

.btn-skip:hover {
    background: #777 !important;
}

.empty-state {
    animation: fadeIn 0.5s ease;
}

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

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes slideOut {
    from { transform: translateX(0); }
    to { transform: translateX(100%); }
}

/* Mobile optimization */
@media (max-width: 768px) {
    .question-filters-simple {
        padding: 10px;
        gap: 8px;
    }
    
    .filter-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .question-card {
        padding: 15px;
    }
    
    .question-actions {
        flex-direction: column;
        gap: 8px !important;
    }
    
    .question-actions button {
        width: 100%;
    }
}
