/* ═══════════════════════════════════════════════════════════════
   QueBot Profile Engine — Styles
   Prefix: pe- (Profile Engine)
   Supports dark-mode / light-mode via body class
   ═══════════════════════════════════════════════════════════════ */

/* ─── Hidden state ──────────────────────────────────────────── */
#profileVertical.hidden {
    display: none;
}

/* ─── CSS Variables ──────────────────────────────────────────── */
:root {
    --pe-accent: #6c63ff;
    --pe-accent-hover: #5a52e0;
    --pe-accent-light: rgba(108, 99, 255, 0.15);
    --pe-radius: 16px;
    --pe-radius-sm: 10px;
    --pe-transition: 0.2s ease;
    --pe-font: inherit;
}

body.dark-mode,
body:not(.light-mode) {
    --pe-bg: #1a1a2e;
    --pe-bg-card: #222244;
    --pe-bot-bg: #2a2a4a;
    --pe-text: #e0e0e0;
    --pe-text-muted: #9a9ab0;
    --pe-border: #3a3a5c;
    --pe-input-bg: #2a2a4a;
    --pe-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --pe-progress-bg: #2a2a4a;
    --pe-score-bg: #2a2a4a;
    --pe-tag-bg: rgba(108, 99, 255, 0.2);
}

body.light-mode {
    --pe-bg: #ffffff;
    --pe-bg-card: #f8f8fc;
    --pe-bot-bg: #f0f0f5;
    --pe-text: #1a1a2e;
    --pe-text-muted: #6b6b80;
    --pe-border: #e0e0ea;
    --pe-input-bg: #f5f5fa;
    --pe-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --pe-progress-bg: #e8e8f0;
    --pe-score-bg: #e8e8f0;
    --pe-tag-bg: rgba(108, 99, 255, 0.1);
}

/* ─── Container ──────────────────────────────────────────────── */
.pe-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100vh;
    background: var(--pe-bg);
    color: var(--pe-text);
    font-family: var(--pe-font);
    position: relative;
    overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────────── */
.pe-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--pe-border);
    flex-shrink: 0;
    position: relative;
}

.pe-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

.pe-back-btn {
    background: none;
    border: none;
    color: var(--pe-accent);
    font-size: 15px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background var(--pe-transition);
    font-weight: 500;
}

.pe-back-btn:hover {
    background: var(--pe-accent-light);
}

.pe-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--pe-progress-bg);
}

.pe-progress-bar {
    height: 100%;
    background: var(--pe-accent);
    border-radius: 0 3px 3px 0;
    transition: width 0.4s ease;
    min-width: 0;
}

/* ─── Chat Area ──────────────────────────────────────────────── */
.pe-chat {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.pe-chat::-webkit-scrollbar {
    width: 4px;
}

.pe-chat::-webkit-scrollbar-thumb {
    background: var(--pe-border);
    border-radius: 4px;
}

/* ─── Messages ───────────────────────────────────────────────── */
.pe-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--pe-radius);
    margin: 3px 0;
    line-height: 1.5;
    animation: pe-fadeIn 0.3s ease;
    font-size: 14px;
    word-wrap: break-word;
}

.pe-bot {
    align-self: flex-start;
    background: var(--pe-bot-bg);
    border-bottom-left-radius: 4px;
    color: var(--pe-text);
}

.pe-user {
    align-self: flex-end;
    background: var(--pe-accent);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.pe-system {
    align-self: center;
    background: transparent;
    color: var(--pe-text-muted);
    font-size: 13px;
    padding: 6px 12px;
    font-style: italic;
}

.pe-block-divider {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 6px;
    width: 100%;
    color: var(--pe-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pe-block-divider::before,
.pe-block-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--pe-border);
}

/* Typing indicator */
.pe-typing {
    align-self: flex-start;
    background: var(--pe-bot-bg);
    border-radius: var(--pe-radius);
    border-bottom-left-radius: 4px;
    padding: 12px 18px;
    display: flex;
    gap: 5px;
    animation: pe-fadeIn 0.2s ease;
}

.pe-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--pe-text-muted);
    border-radius: 50%;
    animation: pe-typing 1.2s infinite;
}

.pe-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.pe-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ─── Input Area ─────────────────────────────────────────────── */
.pe-input-area {
    border-top: 1px solid var(--pe-border);
    padding: 12px 18px 16px;
    flex-shrink: 0;
    background: var(--pe-bg);
}

.pe-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.pe-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--pe-border);
    background: transparent;
    color: var(--pe-text);
    cursor: pointer;
    transition: all var(--pe-transition);
    font-size: 14px;
    font-family: inherit;
    white-space: nowrap;
    user-select: none;
}

.pe-chip:hover {
    background: var(--pe-accent);
    color: #ffffff;
    border-color: var(--pe-accent);
    transform: translateY(-1px);
}

.pe-chip:active {
    transform: translateY(0);
}

.pe-chip.selected {
    background: var(--pe-accent);
    color: #ffffff;
    border-color: var(--pe-accent);
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.pe-continue-btn {
    display: block;
    margin: 10px auto 0;
    padding: 10px 28px;
    border-radius: 22px;
    border: none;
    background: var(--pe-accent);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--pe-transition);
    font-family: inherit;
}

.pe-continue-btn:hover {
    background: var(--pe-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.pe-continue-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.pe-text-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pe-text-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--pe-border);
    border-radius: 22px;
    background: var(--pe-input-bg);
    color: var(--pe-text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--pe-transition);
    font-family: inherit;
}

.pe-text-input input:focus {
    border-color: var(--pe-accent);
}

.pe-text-input input::placeholder {
    color: var(--pe-text-muted);
}

.pe-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--pe-accent);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--pe-transition);
    flex-shrink: 0;
}

.pe-send:hover {
    background: var(--pe-accent-hover);
    transform: scale(1.05);
}

/* ─── Summary View ───────────────────────────────────────────── */
.pe-summary {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
}

.pe-summary-header {
    text-align: center;
    margin-bottom: 20px;
    animation: pe-fadeIn 0.5s ease;
}

.pe-summary-header h3 {
    font-size: 22px;
    margin: 0 0 4px;
}

.pe-summary-header p {
    color: var(--pe-text-muted);
    font-size: 14px;
    margin: 0;
}

.pe-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.pe-summary-card {
    background: var(--pe-bg-card);
    border: 1px solid var(--pe-border);
    border-radius: var(--pe-radius-sm);
    padding: 14px;
    animation: pe-fadeIn 0.4s ease backwards;
    transition: transform var(--pe-transition), box-shadow var(--pe-transition);
    position: relative;
    overflow: hidden;
}

.pe-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--pe-shadow);
}

.pe-summary-card:nth-child(1) { animation-delay: 0.05s; }
.pe-summary-card:nth-child(2) { animation-delay: 0.1s; }
.pe-summary-card:nth-child(3) { animation-delay: 0.15s; }
.pe-summary-card:nth-child(4) { animation-delay: 0.2s; }
.pe-summary-card:nth-child(5) { animation-delay: 0.25s; }
.pe-summary-card:nth-child(6) { animation-delay: 0.3s; }
.pe-summary-card:nth-child(7) { animation-delay: 0.35s; }
.pe-summary-card:nth-child(8) { animation-delay: 0.4s; }

.pe-card-icon {
    font-size: 24px;
    margin-bottom: 6px;
    display: block;
}

.pe-card-title {
    font-size: 12px;
    color: var(--pe-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}

.pe-card-value {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.pe-card-edit {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--pe-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 6px;
    transition: all var(--pe-transition);
    opacity: 0;
}

.pe-summary-card:hover .pe-card-edit {
    opacity: 1;
}

.pe-card-edit:hover {
    color: var(--pe-accent);
    background: var(--pe-accent-light);
}

/* Scores Section */
.pe-scores-section {
    margin-bottom: 20px;
    animation: pe-fadeIn 0.5s ease 0.3s backwards;
}

.pe-scores-section h4 {
    font-size: 15px;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pe-score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.pe-score-label {
    font-size: 13px;
    color: var(--pe-text-muted);
    min-width: 130px;
    flex-shrink: 0;
}

.pe-score-bar-bg {
    flex: 1;
    height: 8px;
    background: var(--pe-score-bg);
    border-radius: 4px;
    overflow: hidden;
}

.pe-score-bar-fill {
    height: 100%;
    background: var(--pe-accent);
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.pe-score-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--pe-accent);
    min-width: 36px;
    text-align: right;
}

/* Modules Section */
.pe-modules-section {
    margin-bottom: 20px;
    animation: pe-fadeIn 0.5s ease 0.4s backwards;
}

.pe-modules-section h4 {
    font-size: 15px;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pe-module-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pe-module-tag {
    padding: 6px 14px;
    border-radius: 16px;
    background: var(--pe-tag-bg);
    color: var(--pe-accent);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(108, 99, 255, 0.2);
    animation: pe-fadeIn 0.3s ease backwards;
}

.pe-module-tag:nth-child(odd) {
    background: rgba(108, 99, 255, 0.12);
}

.pe-no-modules {
    color: var(--pe-text-muted);
    font-size: 14px;
    font-style: italic;
}

/* Action Buttons */
.pe-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding-bottom: 10px;
    animation: pe-fadeIn 0.5s ease 0.5s backwards;
}

.pe-btn-primary {
    padding: 10px 24px;
    border-radius: 22px;
    border: none;
    background: var(--pe-accent);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--pe-transition);
    font-family: inherit;
}

.pe-btn-primary:hover {
    background: var(--pe-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.pe-btn-secondary {
    padding: 10px 24px;
    border-radius: 22px;
    border: 1px solid var(--pe-border);
    background: transparent;
    color: var(--pe-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--pe-transition);
    font-family: inherit;
}

.pe-btn-secondary:hover {
    border-color: var(--pe-accent);
    color: var(--pe-accent);
}

/* Confidence Badge */
.pe-confidence {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 16px;
}

.pe-confidence-ring {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid var(--pe-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--pe-accent);
    position: relative;
}

.pe-confidence-ring.full {
    border-color: var(--pe-accent);
    box-shadow: 0 0 12px rgba(108, 99, 255, 0.3);
}

.pe-confidence-label {
    font-size: 13px;
    color: var(--pe-text-muted);
}

/* ─── Login Prompt ───────────────────────────────────────────── */
.pe-login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    text-align: center;
    padding: 40px;
}

.pe-login-prompt .pe-login-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.pe-login-prompt p {
    color: var(--pe-text-muted);
    font-size: 15px;
    margin: 0;
}

/* ─── Toast ──────────────────────────────────────────────────── */
.pe-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pe-bot-bg);
    color: var(--pe-text);
    padding: 10px 20px;
    border-radius: 22px;
    font-size: 13px;
    box-shadow: var(--pe-shadow);
    border: 1px solid var(--pe-border);
    animation: pe-toastIn 0.3s ease, pe-toastOut 0.3s ease 2.5s forwards;
    z-index: 100;
    white-space: nowrap;
}

/* ─── Confetti ───────────────────────────────────────────────── */
.pe-confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 50;
}

.pe-confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: pe-confettiFall linear forwards;
    opacity: 0.9;
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes pe-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pe-typing {
    0%, 60% { opacity: 0.3; }
    30% { opacity: 1; }
}

@keyframes pe-toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes pe-toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

@keyframes pe-confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes pe-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .pe-summary-grid {
        grid-template-columns: 1fr;
    }

    .pe-msg {
        max-width: 90%;
    }

    .pe-chips {
        gap: 6px;
    }

    .pe-chip {
        padding: 7px 12px;
        font-size: 13px;
    }

    .pe-header h2 {
        font-size: 16px;
    }

    .pe-actions {
        flex-direction: column;
        align-items: center;
    }

    .pe-score-label {
        min-width: 100px;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .pe-chip {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ─── Cognitive Notes Section ─────────────────────────────────────── */

.pe-note-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary, rgba(255,255,255,0.05));
    border-radius: 12px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

.pe-note-section h4 {
    margin: 0 0 4px 0;
    font-size: 1em;
}

.pe-btn-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary, rgba(255,255,255,0.08));
    border: 1px dashed var(--border-color, rgba(255,255,255,0.2));
    border-radius: 8px;
    color: var(--text-primary, #fff);
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.pe-btn-note:hover {
    background: var(--bg-hover, rgba(255,255,255,0.12));
    border-color: var(--accent, #6366f1);
}

.pe-note-input-area {
    margin-top: 12px;
}

.pe-note-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input, rgba(0,0,0,0.2));
    border: 1px solid var(--border-color, rgba(255,255,255,0.15));
    border-radius: 8px;
    color: var(--text-primary, #fff);
    font-family: inherit;
    font-size: 0.9em;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.pe-note-textarea:focus {
    outline: none;
    border-color: var(--accent, #6366f1);
}

.pe-note-textarea::placeholder {
    color: var(--text-muted, #888);
}

.pe-note-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.pe-btn-sm {
    padding: 6px 14px !important;
    font-size: 0.85em !important;
}

.pe-note-saved {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    color: #4ade80;
    font-size: 0.85em;
    text-align: center;
}
