/* =================================================================
   SBM ZEN SPACE STYLES (v3.0 - Full Screen Immersive)
   ================================================================= */

/* 1. THIẾT LẬP BIẾN MÀU (THEME: LOFI CHILL NIGHT) */
:root {
    --zen-bg-wall: linear-gradient(to bottom, #1e293b, #334155);
    --zen-bg-floor: #451a03;
    --zen-window-frame: #1e293b;
    --zen-sky: linear-gradient(to bottom, #020617, #1e1b4b);
    --zen-text: #e2e8f0;
}

/* 2. CONTAINER CHÍNH: PHỦ KÍN MÀN HÌNH */
.sbm-zen-space-page {
    position: fixed !important; /* Cố định khung nhìn, thoát khỏi dòng chảy văn bản */
    top: 0;
    left: 0;
    width: 100vw !important; /* 100% chiều rộng viewport */
    height: 100vh !important; /* 100% chiều cao viewport */
    z-index: 999999 !important; /* Cao hơn cả Header/Footer/AdminBar của theme */
    background-color: #111827; 
    font-family: 'Nunito', sans-serif;
    color: var(--zen-text);
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}

/* Class hỗ trợ ẩn thanh cuộn của trang gốc */
body.sbm-in-zen-mode {
    overflow: hidden !important;
}

/* Wrapper nội dung */
.sbm-zen-space-page .sbmalpha-wrapper {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Reset căn giữa */
}

/* 3. TOOLBAR (Glassmorphism) */
.sbm-zen-toolbar {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 800px;
    padding: 10px 20px;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 100;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.sbm-zen-back-btn, .sbm-zen-action-btn {
    color: #cbd5e1; text-decoration: none; display: flex; align-items: center; gap: 8px;
    background: transparent; padding: 8px 16px; border-radius: 20px;
    cursor: pointer; border: 1px solid transparent; transition: all 0.2s; font-size: 0.9rem; font-weight: 600;
}
.sbm-zen-back-btn:hover, .sbm-zen-action-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sbm-zen-title { color: #f1f5f9; font-weight: 800; font-size: 1.1rem; letter-spacing: 1px; text-transform: uppercase; }
.sbm-zen-action-btn.save-btn { background: #10b981; color: #fff; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4); }

/* 4. KHÔNG GIAN PHÒNG (3D Perspective) */
.sbm-zen-room {
    position: relative; width: 100%; height: 100%;
    display: flex; flex-direction: column;
    perspective: 1000px;
    overflow: hidden; /* Ngăn đồ vật tràn ra ngoài */
}

/* Tường & Sàn */
.sbm-zen-wall {
    flex: 2; /* Tường cao hơn */
    background: var(--zen-bg-wall);
    position: relative; display: flex; justify-content: center; align-items: center;
    box-shadow: inset 0 -50px 150px rgba(0,0,0,0.5);
}
.sbm-zen-floor {
    flex: 1;
    background-color: var(--zen-bg-floor);
    /* Họa tiết sàn gỗ */
    background-image: repeating-linear-gradient(90deg, transparent 0, transparent 48px, rgba(0,0,0,0.1) 50px);
    box-shadow: inset 0 20px 50px rgba(0,0,0,0.6);
    position: relative; z-index: 1;
}

/* Cửa sổ mưa */
.sbm-zen-window {
    width: 300px; height: 200px;
    background: #0f172a;
    border: 12px solid var(--zen-window-frame);
    border-bottom-width: 18px; border-radius: 4px;
    position: relative; overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.8);
    transform: translateY(-40px);
}
.sbm-zen-window::before { content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 8px; background: var(--zen-window-frame); transform: translateY(-50%); z-index: 5; }
.sbm-zen-window::after { content: ''; position: absolute; top: 0; left: 50%; width: 8px; height: 100%; background: var(--zen-window-frame); transform: translateX(-50%); z-index: 5; }
.sbm-zen-sky { width: 100%; height: 100%; background: var(--zen-sky); }
.sbm-zen-rain {
    position: absolute; inset: 0;
    background-image: url('https://i.imgur.com/M2IgKkX.png');
    animation: rain 0.6s linear infinite; opacity: 0.4;
}
@keyframes rain { from { background-position: 0 0; } to { background-position: -20px 200px; } }

/* 5. CÁC VẬT PHẨM (ITEMS) */
.sbm-zen-item {
    position: absolute; cursor: grab; transition: transform 0.1s; z-index: 10;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.4));
}
.sbm-zen-item.is-dragging { cursor: grabbing; z-index: 1000; opacity: 0.9; scale: 1.05; }

/* Kệ sách */
.sbm-bookshelf {
    width: 240px; height: 150px;
    background: #431407; border: 8px solid #270a02; border-radius: 4px;
    display: flex; align-items: flex-end; justify-content: flex-start;
    padding: 8px 12px 6px 12px; gap: 2px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}
.sbm-books-container { width: 100%; height: 100%; display: flex; align-items: flex-end; justify-content: flex-start; gap: 3px; }
.sbm-book-spine {
    border-radius: 2px; box-shadow: inset 2px 0 4px rgba(0,0,0,0.3), 1px 0 2px rgba(0,0,0,0.4);
    cursor: pointer; transition: all 0.2s;
    writing-mode: vertical-rl; text-orientation: mixed;
    color: rgba(255,255,255,0.8); font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; white-space: nowrap; border-top: 1px solid rgba(255,255,255,0.2);
}
.sbm-book-spine:hover { transform: translateY(-10px) scale(1.05); z-index: 100; box-shadow: 0 5px 15px rgba(0,0,0,0.5); color: #fff; }

/* Đèn bàn */
.sbm-decor-lamp { width: 60px; height: 100px; display: flex; flex-direction: column; align-items: center; }
.lamp-shade { width: 50px; height: 35px; background: #f59e0b; border-radius: 30px 30px 5px 5px; z-index: 2; box-shadow: 0 0 30px rgba(245, 158, 11, 0.8); }
.lamp-stand { width: 6px; height: 50px; background: #1e293b; border-radius: 2px; }
.lamp-light {
    position: absolute; top: 20px; left: -70px; width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(255, 210, 100, 0.25) 0%, transparent 70%);
    pointer-events: none; z-index: 1; mix-blend-mode: screen;
    animation: flicker 5s infinite alternate;
}
@keyframes flicker { 0% { opacity: 0.8; } 100% { opacity: 1; } }

/* Con mèo */
.sbm-pet-cat img { width: 100px; filter: drop-shadow(0 5px 5px rgba(0,0,0,0.4)); }
/* Cây */
.sbm-decor-plant { font-size: 4rem; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5)); }

/* 6. PLAYER NHẠC */
.sbm-zen-player {
    position: absolute; bottom: 30px; left: 30px;
    background: rgba(15, 23, 42, 0.8);
    padding: 12px 16px; border-radius: 20px;
    display: flex; align-items: center; gap: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4); width: 280px; z-index: 90;
    border: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(10px);
}
.sbm-player-disc {
    width: 45px; height: 45px; background: #000; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    animation: spin 5s linear infinite; animation-play-state: paused;
    border: 2px solid #334155;
}
.sbm-player-disc.is-playing { animation-play-state: running; border-color: #ef4444; }
.sbm-disc-inner { width: 14px; height: 14px; background: #ef4444; border-radius: 50%; border: 2px solid #fff; }
.sbm-player-info { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.sbm-track-name { font-size: 0.85rem; font-weight: 700; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbm-player-controls button { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: #94a3b8; transition: color 0.2s; }
.sbm-player-controls button:hover { color: #fff; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* 7. NÚT CHỤP ẢNH */
#sbm-zen-snapshot-btn {
    position: absolute; bottom: 30px; right: 30px;
    background: #fff; color: #1e293b; width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 90; box-shadow: 0 5px 20px rgba(255,255,255,0.3);
    transition: all 0.3s;
}
#sbm-zen-snapshot-btn:hover { transform: scale(1.1); box-shadow: 0 0 30px rgba(255,255,255,0.6); }

/* Flash */
.sbm-flash-overlay { position: fixed; inset: 0; background: #fff; z-index: 999999; pointer-events: none; opacity: 0; transition: opacity 0.5s ease-out; }
.sbm-flash-overlay.flash { opacity: 1; transition: none; }

/* MODAL QUẢN LÝ (Style tối) */
.sbm-zen-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 20000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.sbm-zen-modal-overlay.sbmalpha-active,
.sbm-zen-modal-overlay.is-visible {
    display: flex !important;
}
.sbm-zen-modal { background: #1e293b; width: 90%; max-width: 500px; border-radius: 12px; border: 1px solid #334155; color: #fff; display: flex; flex-direction: column; overflow: hidden; }
.sbm-zen-modal-header { padding: 15px 20px; background: #0f172a; border-bottom: 1px solid #334155; display: flex; justify-content: space-between; align-items: center; }
.sbm-zen-modal-body { padding: 20px; }
.sbm-zen-input { background: #334155; border: 1px solid #475569; color: #fff; padding: 10px; width: 100%; border-radius: 8px; }
.sbm-zen-list-item { background: #0f172a; border-bottom: 1px solid #334155; padding: 10px; margin-bottom: 5px; display: flex; justify-content: space-between; }
.sbm-zen-remove-book { color: #ef4444; background: none; border: none; cursor: pointer; }
.sbm-zen-search-results { background: #0f172a; margin-top: 5px; max-height: 150px; overflow-y: auto; }
.sbm-zen-search-item { padding: 10px; cursor: pointer; border-bottom: 1px solid #1e293b; }
.sbm-zen-search-item:hover { background: #334155; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sbm-zen-room { transform: scale(0.8); transform-origin: top center; height: 120%; }
    .sbm-zen-player { bottom: 80px; left: 50%; transform: translateX(-50%); width: 90%; }
    #sbm-zen-snapshot-btn { bottom: 20px; right: 50%; transform: translateX(50%); }
}

/* KỆ SÁCH DÙNG ẢNH */
.sbm-bookshelf {
    width: 240px; height: 160px;
    background-color: transparent; border: none; box-shadow: none;
    background-image: url('https://i.imgur.com/O0e3L9o.png'); /* Ảnh mẫu */
    background-size: contain; background-repeat: no-repeat; background-position: bottom center;
    padding: 10px 25px 18px 25px; /* Căn chỉnh vị trí sách */
    display: flex; align-items: flex-end; justify-content: flex-start;
    gap: 2px; filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
}

/* SHOP SIDEBAR (Glassmorphism) */
.sbm-zen-shop-sidebar {
    position: absolute; top: 0; right: 0; width: 320px; height: 100%;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(15px);
    border-left: 1px solid rgba(255,255,255,0.1);
    z-index: 2000; /* Cao nhất */
    transform: translateX(100%); /* Ẩn mặc định */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.3);
}
.sbm-zen-shop-sidebar.is-active { transform: translateX(0); }

.sbm-shop-header {
    padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: space-between; align-items: center;
}
.sbm-shop-header h3 { margin: 0; color: #fff; font-size: 1.1rem; }
#sbm-close-shop-btn {
    background: none; border: none; color: #94a3b8; font-size: 1.5rem; cursor: pointer;
}

/* Tabs */
.sbm-shop-tabs { display: flex; padding: 10px; gap: 10px; background: rgba(0,0,0,0.2); }
.sbm-shop-tab {
    flex: 1; padding: 8px; background: transparent; border: none;
    color: #94a3b8; font-weight: 600; cursor: pointer; border-radius: 6px;
    transition: all 0.2s;
}
.sbm-shop-tab.is-active { background: var(--sbm-primary-color); color: #fff; }

/* Grid Sản phẩm */
.sbm-shop-content { flex: 1; overflow-y: auto; padding: 15px; }
.sbm-shop-view { display: none; }
.sbm-shop-view.is-active { display: block; }

.sbm-shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.sbm-shop-item {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; padding: 10px; text-align: center;
    transition: all 0.2s; position: relative;
}
.sbm-shop-item:hover { background: rgba(255,255,255,0.1); border-color: var(--sbm-primary-color); }
.sbm-shop-item img { width: 80px; height: 80px; object-fit: contain; margin-bottom: 8px; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.3)); }
.sbm-shop-item-name { font-size: 0.85rem; color: #e2e8f0; margin-bottom: 5px; display: block; font-weight: 600;}
.sbm-shop-item-price { font-size: 0.8rem; color: #f59e0b; font-weight: 700; display: block; margin-bottom: 8px; }

.sbm-shop-action-btn {
    width: 100%; padding: 6px; border-radius: 4px; border: none;
    font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.sbm-shop-action-btn.buy { background: #3b82f6; color: #fff; }
.sbm-shop-action-btn.use { background: #10b981; color: #fff; }

/* Item đã đặt ra phòng (class hỗ trợ) */
.sbm-zen-item img { width: 100%; height: auto; pointer-events: none; }

/* Admin Add Item Button */
#sbm-admin-add-item-btn {
    background: #3b82f6; color: #fff; border: none;
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; margin-left: auto; /* Căn phải trong header */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
#sbm-admin-add-item-btn:hover { transform: scale(1.1); background: #2563eb; }

/* Form Admin trong Modal */
.sbm-admin-form-row { margin-bottom: 15px; }
.sbm-admin-form-row label { display: block; color: #94a3b8; font-size: 0.85rem; margin-bottom: 5px; }
.sbm-admin-form-row input, .sbm-admin-form-row select {
    width: 100%; background: #334155; border: 1px solid #475569;
    color: #fff; padding: 8px 12px; border-radius: 6px; outline: none;
}
.sbm-admin-form-row input[type="file"] { padding: 5px; }
#sbm-admin-item-preview {
    width: 100px; height: 100px; object-fit: contain;
    border: 1px dashed #475569; margin-top: 10px; display: none;
}