/*
 * © 2026 Shannon Henry. All rights reserved.
 *
 * This software and its associated documentation (the "Power 369 Vortex Enterprise") are the exclusive property of the owner.
 *
 * UNAUTHORIZED COPYING, REPRODUCTION, MODIFICATION, OR DISTRIBUTION OF THIS WORK, OR ANY PORTION OF IT, IS STRICTLY PROHIBITED.
 *
 * This includes, but is not limited to, the proprietary 3-6-9 harmonic architecture, dual-state monitoring protocol, Soul Guide Protocol, Oracle Reading Engine, four-currency economic model, Forge Ratio mechanics, card-economy system, DreamScape Gateway architecture, Zero-Drift Development methodology, Hyper Biological Coding theory, and Constitutional File Theory.
 *
 * For inquiries regarding licensing or permissions, please contact: power369app@gmail.com
 */

/* ============================================
   POWER369 — sanctuary.css
   Sanctuary Page — Self-contained styles
   ============================================ */

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --accent-green: #00ff88;
  --accent-purple: #9d4edd;
  --accent-gold: #ffd700;
  --accent-blue: #4dabf7;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --border-color: #2a2a3a;
  --harmony-green: #00ff88;
  --dissonance-yellow: #ffd700;
  --vortex-red: #ff0033;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body.chat-open { overflow: hidden; position: fixed; width: 100%; height: 100%; }

/* --- Vortex Pulse --- */
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: #00ff41; box-shadow: 0 0 8px #00ff41; animation: pulse-breathe 4s ease-in-out infinite; }
@keyframes pulse-breathe { 0%, 100% { opacity: 0.4; transform: scale(0.95); } 50% { opacity: 1; transform: scale(1.1); } }
.vortex-pulse-indicator { width: 10px; height: 10px; border-radius: 50%; transition: all 0.5s ease; }
.vortex-pulse-indicator.pulse-sovereign { background: #00ff41; box-shadow: 0 0 12px #00ff41; animation: pulse-breathe 4s ease-in-out infinite; }
.vortex-pulse-indicator.pulse-monitored { background: #fdfd96; box-shadow: 0 0 12px #fdfd96; animation: pulse-breathe 4s ease-in-out infinite; }
.vortex-pulse-indicator.pulse-contained { background: #ff0033; box-shadow: 0 0 12px #ff0033; animation: pulse-breathe 2s ease-in-out infinite; }

/* --- Top Bar --- */
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 100; }
.top-bar h1 { font-size: 1rem; color: var(--accent-green); }
.atom-display { font-size: 0.8rem; color: var(--accent-gold); font-weight: 600; }

/* --- Status Strip --- */
.status-strip { display: flex; justify-content: space-around; padding: 8px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); font-size: 0.7rem; }
.status-item { text-align: center; }
.status-item label { color: var(--text-secondary); display: block; margin-bottom: 2px; }
.tier-badge { padding: 2px 8px; border-radius: 10px; font-size: 0.65rem; font-weight: 600; }
.tier-badge.STANDARD { background: #333; color: #aaa; }
.tier-badge.PREMIUM_CREATIVE { background: #3a2a6d; color: #b794f6; }
.tier-badge.PRO_ORACLE { background: #1a4a3a; color: var(--accent-green); }

/* --- Main Content --- */
.main-content { padding-bottom: 70px; }
.section { padding: 14px; }
.section-title { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }

/* --- Vault Grid --- */
.vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.vault-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 12px; cursor: pointer; transition: all 0.2s; position: relative; }
.vault-card:hover { border-color: var(--accent-purple); transform: translateY(-2px); }
.vault-card.expired { opacity: 0.5; border-color: #ff4444; }
.vault-card.archived { opacity: 0.6; border-color: var(--text-secondary); }
.vault-card.archived::after { content: 'ARCHIVED'; position: absolute; top: 8px; right: 8px; font-size: 0.6rem; background: var(--text-secondary); color: var(--bg-primary); padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.vault-name { font-size: 0.95rem; font-weight: 600; color: var(--accent-purple); margin-bottom: 6px; padding-right: 60px; }
.vault-guides { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.guide-chip { font-size: 0.65rem; padding: 2px 6px; border-radius: 8px; background: var(--bg-secondary); border: 1px solid var(--border-color); }
.vault-stats { display: flex; gap: 10px; font-size: 0.7rem; color: var(--text-secondary); }
.vault-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.vault-action-btn { background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-secondary); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.vault-action-btn:hover { border-color: var(--accent-purple); color: var(--text-primary); }
.vault-action-btn.archive:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

/* --- Card & Form --- */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px; }
.create-form { display: grid; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 0.75rem; color: var(--text-secondary); }
.form-group input, .form-group select { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; color: var(--text-primary); font-size: 0.9rem; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent-purple); }
.btn { padding: 10px 18px; border-radius: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: var(--accent-green); color: #000; }
.btn-primary:hover { box-shadow: 0 0 20px rgba(0, 255, 136, 0.4); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color); }
.cost-preview { background: var(--bg-secondary); border-radius: 8px; padding: 10px; text-align: center; }
.cost-preview .amount { font-size: 1.2rem; font-weight: 700; color: var(--accent-gold); }
.cost-preview.free .amount { color: var(--accent-green); }
/* --- Chat View --- */
#chatView { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); z-index: 200; flex-direction: column; overflow: hidden; }
#chatView.active { display: flex; }

.chat-header { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.chat-back-btn { background: none; border: none; color: var(--text-primary); font-size: 1.3rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: background 0.2s; }
.chat-back-btn:hover { background: var(--bg-card); }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h2 { font-size: 0.9rem; color: var(--accent-purple); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-info span { font-size: 0.65rem; color: var(--text-secondary); }
.chat-header-actions { display: flex; gap: 6px; }
.chat-header-actions button { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); padding: 6px 10px; border-radius: 6px; font-size: 0.9rem; cursor: pointer; transition: all 0.2s; position: relative; }
.chat-header-actions button:hover { border-color: var(--accent-purple); color: var(--text-primary); }

.memory-mode-toggle { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); padding: 6px 10px; border-radius: 6px; font-size: 0.75rem; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.memory-mode-toggle:hover { border-color: var(--accent-purple); color: var(--text-primary); }
.memory-mode-toggle.active { background: rgba(157, 78, 221, 0.2); border-color: var(--accent-purple); color: var(--accent-purple); }

.cooldown-bar { display: none; padding: 6px 12px; background: rgba(255, 0, 51, 0.1); border-bottom: 1px solid rgba(255, 0, 51, 0.3); font-size: 0.7rem; color: var(--vortex-red); text-align: center; flex-shrink: 0; }
.cooldown-bar.active { display: block; }

/* --- Guide Tabs --- */
.guide-tabs { display: flex; gap: 6px; padding: 8px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); overflow-x: auto; -webkit-overflow-scrolling: touch; flex-shrink: 0; }
.guide-tabs::-webkit-scrollbar { display: none; }
.guide-tab { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; cursor: pointer; white-space: nowrap; transition: all 0.2s; font-size: 0.75rem; }
.guide-tab:hover { border-color: var(--accent-purple); }
.guide-tab.active { background: var(--accent-purple); border-color: var(--accent-purple); color: white; }
.guide-tab .emoji { font-size: 0.9rem; }
.guide-tab .name { font-weight: 500; }
.guide-tab.add-guide { background: transparent; border-style: dashed; color: var(--text-secondary); }
.guide-tab.add-guide:hover { color: var(--accent-green); border-color: var(--accent-green); }

/* --- Chat Messages --- */
.chat-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (min-width: 768px) { .chat-messages { max-width: 800px; width: 100%; margin: 0 auto; padding: 16px; gap: 12px; } }

.message { max-width: 90%; animation: fadeIn 0.3s ease; }
@media (min-width: 768px) { .message { max-width: 80%; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; }
.message.guide { align-self: flex-start; }
.message-header { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.message-sender { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.message-mode-badge { font-size: 0.55rem; padding: 1px 5px; border-radius: 6px; font-weight: 600; margin-left: 4px; }
.message-mode-badge.memory { background: rgba(157, 78, 221, 0.2); color: var(--accent-purple); border: 1px solid rgba(157, 78, 221, 0.4); }
.message-mode-badge.cooldown { background: rgba(255, 0, 51, 0.15); color: var(--vortex-red); border: 1px solid rgba(255, 0, 51, 0.3); }
.message-content { padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.message.user .message-content { background: var(--accent-purple); color: white; border-bottom-right-radius: 4px; }
.message.guide .message-content { background: var(--bg-card); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; }
.message-time { font-size: 0.6rem; color: var(--text-secondary); margin-top: 4px; padding: 0 4px; }
.message-copy-btn { display: flex; align-items: center; gap: 4px; margin-top: 6px; padding: 4px 10px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; color: var(--text-secondary); font-size: 0.7rem; cursor: pointer; transition: all 0.2s; width: fit-content; }
.message.user .message-copy-btn { margin-left: auto; }
.message-copy-btn:hover { border-color: var(--accent-green); color: var(--accent-green); }
.message-copy-btn:active { transform: scale(0.95); }
.message-copy-btn.copied { border-color: var(--accent-green); color: var(--accent-green); }

/* --- Message Attachments --- */
.message-attachment { margin-top: 8px; padding: 8px; background: rgba(0,0,0,0.25); border-radius: 10px; }
.message-attachment img { max-width: 100%; max-height: 250px; border-radius: 6px; cursor: pointer; }
.message-attachment .file-info { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 0.8rem; }
.message-attachment .file-icon { font-size: 1.5rem; }

/* --- Typing Indicator --- */
.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 10px 14px; }
.typing-indicator span { width: 8px; height: 8px; background: var(--accent-purple); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; }
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* --- Chat Input Area --- */
.chat-input-area { padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--bg-secondary); border-top: 1px solid var(--border-color); flex-shrink: 0; }
@media (min-width: 768px) { .chat-input-area { max-width: 800px; width: 100%; margin: 0 auto; padding: 12px 16px 16px; } }

.harmony-indicator { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; margin-bottom: 6px; border-radius: 8px; font-size: 0.65rem; font-weight: 600; transition: all 0.3s ease; opacity: 0; height: 0; overflow: hidden; }
.harmony-indicator.visible { opacity: 1; height: auto; padding: 6px 10px; margin-bottom: 8px; }
.harmony-indicator.zone-green { background: rgba(0, 255, 136, 0.08); border: 1px solid rgba(0, 255, 136, 0.2); color: var(--harmony-green); }
.harmony-indicator.zone-yellow { background: rgba(255, 215, 0, 0.08); border: 1px solid rgba(255, 215, 0, 0.3); color: var(--dissonance-yellow); }
.harmony-indicator.zone-red { background: rgba(255, 0, 51, 0.08); border: 1px solid rgba(255, 0, 51, 0.3); color: var(--vortex-red); }
.harmony-indicator .zone-label { flex: 1; }
.harmony-indicator .char-count { font-family: 'Courier New', monospace; }

/* --- Attachment Bar --- */
.attachment-bar { display: flex; gap: 6px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.attach-btn { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); padding: 6px 10px; border-radius: 16px; font-size: 0.75rem; cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all 0.2s; }
.attach-btn:hover { border-color: var(--accent-purple); color: var(--text-primary); background: rgba(157, 78, 221, 0.1); }
.attach-btn:active { transform: scale(0.96); }
.attach-btn .icon { font-size: 1rem; }
.attach-btn .label { display: none; }
@media (min-width: 360px) { .attach-btn .label { display: inline; } }

.attachment-preview { display: none; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; padding: 10px; background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border-color); }
.attachment-preview.has-items { display: flex; }
.attachment-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-secondary); border-radius: 8px; font-size: 0.75rem; position: relative; max-width: 160px; }
.attachment-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.attachment-item .file-icon { font-size: 1.3rem; }
.attachment-item .file-details { flex: 1; min-width: 0; }
.attachment-item .file-name { color: var(--text-primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; font-size: 0.7rem; }
.attachment-item .file-size { color: var(--text-secondary); font-size: 0.6rem; }
.remove-attachment { background: rgba(255, 68, 68, 0.15); border: none; color: #ff6666; cursor: pointer; font-size: 1.1rem; padding: 2px 6px; border-radius: 4px; line-height: 1; transition: all 0.2s; }
.remove-attachment:hover { background: rgba(255, 68, 68, 0.3); color: #ff4444; }

/* --- Chat Input --- */
.chat-input-container { display: flex; gap: 8px; align-items: flex-end; }
.chat-input { flex: 1; background: var(--bg-card); border: 2px solid var(--border-color); border-radius: 24px; padding: 10px 16px; color: var(--text-primary); font-size: 0.95rem; resize: none; max-height: 120px; min-height: 44px; line-height: 1.4; font-family: inherit; transition: border-color 0.2s, box-shadow 0.2s; }
.chat-input:focus { outline: none; border-color: var(--accent-purple); box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.15); }
.chat-input::placeholder { color: var(--text-secondary); }
.chat-input.glow-green { border-color: var(--harmony-green); box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.1); }
.chat-input.glow-yellow { border-color: var(--dissonance-yellow); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1); }
.chat-input.glow-red { border-color: var(--vortex-red); box-shadow: 0 0 0 3px rgba(255, 0, 51, 0.15); }

.send-btn { background: var(--accent-green); color: #000; border: none; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.2s; }
.send-btn:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 0 20px rgba(0, 255, 136, 0.5); }
.send-btn:active:not(:disabled) { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* --- Modals --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); z-index: 300; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 20px; max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto; animation: modalSlideIn 0.3s ease; }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal h3 { color: var(--accent-purple); margin-bottom: 8px; font-size: 1.1rem; }
.modal p { color: var(--text-secondary); margin-bottom: 16px; font-size: 0.85rem; line-height: 1.5; }
.modal input { width: 100%; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; color: var(--text-primary); font-size: 0.9rem; margin-bottom: 14px; }
.modal input:focus { outline: none; border-color: var(--accent-purple); }

.guide-type-list { display: grid; gap: 8px; margin-bottom: 16px; max-height: 280px; overflow-y: auto; }
.guide-type-option { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg-secondary); border: 2px solid var(--border-color); border-radius: 10px; cursor: pointer; transition: all 0.2s; }
.guide-type-option:hover { border-color: var(--accent-purple); }
.guide-type-option.selected { border-color: var(--accent-green); background: rgba(0, 255, 136, 0.08); }
.guide-type-option.disabled { opacity: 0.4; cursor: not-allowed; }
.guide-type-option .emoji { font-size: 1.5rem; }
.guide-type-option .info { flex: 1; }
.guide-type-option .info .name { font-weight: 600; font-size: 0.85rem; color: var(--text-primary); }
.guide-type-option .info .desc { font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; padding: 10px 14px; font-size: 0.85rem; }

.export-preview { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; max-height: 200px; overflow-y: auto; font-family: 'SF Mono', 'Consolas', monospace; font-size: 0.7rem; white-space: pre-wrap; margin-bottom: 14px; line-height: 1.4; }

.archive-info { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.archive-info .label { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 4px; }
.archive-info .value { font-size: 0.9rem; color: var(--text-primary); }
.archive-info .refund { color: var(--accent-gold); font-weight: 600; }

/* --- Loading & Toast --- */
.loading { text-align: center; padding: 30px; color: var(--text-secondary); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-color); border-top-color: var(--accent-green); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--bg-card); border: 1px solid var(--accent-green); color: var(--text-primary); padding: 12px 24px; border-radius: 10px; font-size: 0.85rem; z-index: 500; animation: toastSlideUp 0.3s ease; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); max-width: 90%; text-align: center; }
.toast.error { border-color: #ff4444; }
.toast.info { border-color: var(--accent-blue); }
@keyframes toastSlideUp { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* --- Archived Section --- */
.archived-section { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border-color); }
.archived-section .section-title { color: var(--text-secondary); opacity: 0.7; }

/* --- Nav Spacer --- */
.p369-nav-spacer { height: 70px; }
