/* --- THEME VARIABLES --- */
:root {
  --bg-base: #f8f5f2; 
  --bg-card: #ffffff;
  --bg-input: #f0f0f0;
  --text-main: #1a1a1a;
  --text-sub: #666666;
  --gold-royal: #B8860B; 
  --teal-dark: #013220; 
  --teal-light: #004d40;
  --cream-card: #F9F4EF;
  --border-glass: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 10px rgba(0,0,0,0.05);
  --btn-text: #ffffff;
  --danger: #d32f2f;
  --success: #2e7d32;
}

body[data-theme='dark'] {
  --bg-base: #050505;
  --bg-card: #141414;
  --bg-input: #1f1f1f;
  --text-main: #ffffff;
  --text-sub: #b0b0b0;
  --gold-royal: #D4AF37;
  --teal-dark: #003333; 
  --teal-light: #b0b0b0;
  --cream-card: #1a1a1a;
  --border-glass: rgba(255, 255, 255, 0.15);
  --shadow: 0 4px 10px rgba(0,0,0,0.5);
  --btn-text: #000000;
  --danger: #ff4d4d;
  --success: #b0b0b0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body, html { 
    margin: 0; padding: 0; width: 100%; height: 100%; 
    font-family: 'Inter', sans-serif; 
    color: var(--text-main); overflow: hidden; 
    background: linear-gradient(0deg, rgba(184, 134, 11, 0.05) 0%, var(--bg-base) 60%);
    background-attachment: fixed;
}

#app-viewport { width: 100%; height: 100%; position: relative; overflow: hidden; padding-top: 60px; }

/* --- HEADER --- */
#global-header {
    position: absolute; top: 0; left: 0; width: 100%; height: 60px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; z-index: 500;
    background: var(--bg-card); backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-glass);
}
.header-brand-text { 
    font-family: 'Playfair Display', serif; 
    font-weight: 900; 
    font-size: 24px; 
    color: var(--text-main); 
    letter-spacing: 2px; 
    text-transform: uppercase; 
    position: relative;
    cursor: pointer;
}

.header-btn { background: transparent; border: 1px solid var(--border-glass); color: var(--text-main); font-size: 16px; cursor: pointer; width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; overflow:hidden; }
.header-avatar { width:100%; height:100%; object-fit:cover; display:none; }

/* --- SIDEBAR --- */
#app-sidebar { position: fixed; top: 0; left: 0; width: 280px; height: 100%; background: var(--bg-base); z-index: 600; transform: translateX(-100%); transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); border-right: 1px solid var(--gold-royal); padding: 20px; padding-top: 80px; }
#sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 550; display: none; backdrop-filter: blur(5px); }
#sidebar-overlay.active { display: block; }
.side-link { display: flex; align-items: center; gap: 15px; color: var(--text-main); text-decoration: none; padding: 15px; border-radius: 10px; margin-bottom: 5px; font-weight: 500; transition: 0.2s; border: 1px solid transparent; }
.side-link:hover { background: var(--bg-input); color: var(--gold-royal); border-color: var(--border-glass); }
.side-link i { width: 25px; text-align: center; color: var(--gold-royal); }

/* --- SCREENS --- */
.screen { position: absolute; top: 60px; left: 0; width: 100%; height: calc(100% - 60px); display: none; flex-direction: column; overflow-y: auto; padding-bottom: 20px; }
.screen.active { display: flex; z-index: 10; }
#login-screen, #nav-ar-view, #chat-room-screen { top: 0; height: 100%; z-index: 1000; background: var(--bg-base); }

/* --- COMPONENTS --- */
.dashboard-card { background: var(--bg-card); border: 1px solid var(--border-glass); border-radius: 16px; margin: 15px; padding: 20px; box-shadow: var(--shadow); color: var(--text-main); position: relative; }
.glass-input { width: 100%; background: var(--bg-input); border: 1px solid var(--border-glass); border-radius: 10px; padding: 12px; color: var(--text-main); font-size: 13px; margin-bottom: 12px; outline: none; font-family: 'Inter', sans-serif; }
select.glass-input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23B8860B%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: right 15px top 50%; background-size: 10px auto; }
.primary-btn { width: 100%; padding: 14px; border-radius: 10px; border: none; background: var(--gold-royal); color: white; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; margin-top: 10px; }
.small-btn { padding: 6px 12px; border-radius: 6px; font-size: 10px; font-weight: bold; cursor: pointer; border: none; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }

/* --- CONCIERGE CARD --- */
.concierge-card { 
    background: var(--bg-card); 
    border-radius: 16px; 
    padding: 20px; 
    margin: 15px; 
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.15); 
    border-top: 4px solid var(--gold-royal); 
    border-bottom: 1px solid var(--border-glass);
    animation: popIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    opacity: 0; transform: translateY(20px); 
}
.concierge-card:active { transform: scale(0.98) translateY(20px); box-shadow: 0 5px 15px -5px rgba(0,0,0,0.1); }
@keyframes popIn { 0% { opacity: 0; transform: translateY(20px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
.cc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; }
.cc-module-code { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 900; color: var(--text-main); line-height: 1; }
.cc-module-name { font-size: 12px; font-weight: bold; color: var(--gold-royal); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.cc-status { font-size: 9px; background: var(--teal-dark); color: white; padding: 3px 8px; border-radius: 4px; font-weight: 800; text-transform: uppercase; }
.cc-details { margin-bottom: 20px; }
.cc-row { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 11px; }
.cc-label { color: var(--text-sub); font-weight: 500; }
.cc-value { color: var(--text-main); font-weight: bold; }
.cc-actions { display: flex; gap: 10px; }
.cc-btn { flex: 1; padding: 12px; border-radius: 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; cursor: pointer; text-align: center; transition: all 0.2s; }
.cc-btn:active { transform: scale(0.95); }

/* --- MARKETPLACE --- */
.book-item { background: white; border-radius: 12px; padding: 12px; margin-bottom: 15px; display: flex; gap: 15px; border: 1px solid var(--border-glass); box-shadow: 0 2px 5px rgba(0,0,0,0.05); position: relative; }
.book-cover { width: 85px; height: 115px; background: #333; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.book-info { flex: 1; display: flex; flex-direction: column; }
.book-module-code { color: var(--gold-royal); font-weight: 900; font-size: 16px; margin-bottom: 2px; font-family: 'JetBrains Mono'; }
.book-title { font-weight: bold; font-size: 13px; line-height: 1.2; margin-bottom: 4px; color: var(--text-main); }
.book-meta { font-size: 10px; color: var(--text-sub); display: block; margin-top: 1px; }
.book-bottom-row { margin-top: auto; display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.book-price { font-weight: 900; color: var(--gold-royal); font-size: 18px; }
.book-badge { position: absolute; top: 10px; right: 10px; background: var(--teal-dark); color: white; padding: 3px 8px; border-radius: 4px; font-size: 9px; font-weight: bold; text-transform: uppercase; }

/* --- VAULT --- */
.pulse-card { border-left: 4px solid var(--gold-royal); padding: 20px; background: linear-gradient(90deg, rgba(184, 134, 11, 0.1) 0%, transparent 100%); border-radius: 0 15px 15px 0; margin-bottom: 15px; position: relative; }
.pc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.ledger-row { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-bottom: 1px solid var(--border-glass); font-size: 12px; cursor: pointer; }
.ledger-hash { font-family: 'JetBrains Mono', monospace; font-size: 8px; color: var(--gold-royal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px; }
.amt-pos { color: var(--success); font-weight: bold; }
.amt-neg { color: var(--danger); font-weight: bold; }
.pay-option { background: var(--bg-input); border: 1px solid var(--border-glass); border-radius: 10px; padding: 15px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: 0.2s; }
.pay-option:hover { border-color: var(--gold-royal); }
.pay-logo { font-weight: 800; font-size: 13px; color: var(--text-main); display:flex; align-items:center; gap:10px; }

/* --- TABS --- */
.ac-layout { display: flex; flex-direction: column; height: 100%; }
.ac-left { width: 100%; display: flex; gap: 10px; padding: 10px 15px; overflow-x: auto; background: var(--bg-input); border-bottom: 1px solid var(--border-glass); }
.ac-right { flex: 1; padding: 15px; overflow-y: auto; }
.ac-tab { padding: 8px 16px; border-radius: 20px; font-size: 11px; cursor: pointer; color: var(--text-sub); border: 1px solid transparent; }
.ac-tab.active { background: var(--gold-royal); color: white; font-weight: bold; }
.ac-content { display: none; height: 100%; }

/* --- MODALS & SOCIAL --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 3000; display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(8px); }
.modal-content { background: var(--bg-card); border: 1px solid var(--gold-royal); color: var(--text-main); border-radius: 20px; padding: 25px; max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto; }
.chat-list-item { display: flex; align-items: center; padding: 15px; border-bottom: 1px solid var(--border-glass); cursor: pointer; }
.chat-avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; margin-right: 15px; border: 1px solid var(--border-glass); }
.msg-bubble { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.4; margin-bottom: 5px; }
.msg-me { align-self: flex-end; background: var(--teal-dark); color: white; border-bottom-right-radius: 2px; }
.msg-them { align-self: flex-start; background: var(--bg-input); color: var(--text-main); border-bottom-left-radius: 2px; }

/* --- SAFETY MODULE --- */
.safety-card { background: var(--bg-card); width: 95%; max-width: 380px; padding: 30px 25px; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); text-align: center; border-top: 6px solid var(--danger); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); margin: auto; }
.safety-card.guardian { border-top-color: var(--success); }
.sc-header { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 900; color: var(--text-main); margin-bottom: 20px; letter-spacing: 2px; text-transform: uppercase; border-bottom: 1px solid var(--border-glass); padding-bottom: 15px; }
.sc-body { font-size: 13px; line-height: 1.6; color: var(--text-sub); margin-bottom: 25px; text-align: left; }
.status-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:8px; }
.status-red { background: var(--danger); box-shadow: 0 0 5px var(--danger); }
.status-green { background: var(--success); box-shadow: 0 0 5px var(--success); }
.sc-btn { width: 100%; padding: 14px; border-radius: 25px; border: none; font-weight: 800; font-size: 12px; letter-spacing: 1px; cursor: pointer; text-transform: uppercase; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.sc-btn-panic { background: var(--danger); color: white; }
.sc-btn-guardian { background: var(--success); color: white; }

/* ESCROW QR */
.qr-display-box { background: white; padding: 20px; border-radius: 12px; text-align: center; margin-bottom: 15px; border: 2px dashed var(--gold-royal); }
.pin-code-text { font-family: 'JetBrains Mono', monospace; font-size: 32px; font-weight: 900; color: var(--text-main); letter-spacing: 5px; margin: 10px 0; }

/* ==========================================
   GLOBAL MODAL & FROSTED GLASS ENFORCEMENT
   ========================================== */
.modal-overlay, 
#internal-edit-modal, 
#dossier-form-modal, 
#tag-form-modal {
    background: rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

.modal-content, 
.safety-card {
    background: var(--bg-card) !important;
    border-radius: 20px !important;
    border: 1px solid var(--gold-royal) !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2) !important;
    padding: 25px !important;
}

/* Fix text spacing inside the newly formatted safety cards */
.safety-card .sc-body {
    margin-bottom: 20px !important;
    line-height: 1.6;
}
