/*
 * Folder: client/shared/css/
 * File Purpose: Manages the 1200px split layout (300px sticky sidebar + 900px canvas), 
 * the CSS Grid block system, and interactive widget behaviors (like the Hidden Door).
 */

/* --- GLOBAL HEADER & NAVBAR --- */
.global-header { width: 100%; background: var(--card-bg); border-bottom: 1px solid var(--border-color); padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; box-sizing: border-box; }
.header-logo { font-size: 24px; font-weight: bold; color: var(--accent-color); text-decoration: none; }
.header-ad-banner { width: 728px; height: 90px; background: var(--bg-color); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 12px; }
.header-search { display: flex; align-items: center; gap: 20px; }
.search-bar { padding: 8px 15px; border-radius: 20px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color); width: 200px; outline: none; }

/* Search & Live Dropdown */
.search-container { position: relative; display: flex; align-items: center; }
.search-dropdown { display: none; position: absolute; top: 100%; left: 0; width: 100%; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; margin-top: 5px; z-index: 200; box-shadow: var(--card-shadow); flex-direction: column; overflow: hidden; }
.search-dropdown.active { display: flex; }
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer; border-bottom: 1px solid var(--border-color); text-decoration: none; color: var(--text-color); }
.search-result-item:hover { background: var(--bg-color); }
.search-result-img { width: 30px; height: 45px; object-fit: cover; border-radius: 2px; }

/* Header Icons & User Menu */
.header-icons { display: flex; align-items: center; gap: 20px; margin-right: 15px; }
.icon-btn { position: relative; cursor: pointer; font-size: 20px; color: var(--text-color); display: flex; align-items: center; }
.icon-badge { position: absolute; top: -6px; right: -8px; background: #ff0055; color: white; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 10px; pointer-events: none; }

.header-user-menu { display: flex; align-items: center; gap: 10px; cursor: pointer; position: relative; padding: 5px 0; }
.header-user-menu img { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; border: 1px solid var(--accent-color); }
.header-user-menu span { font-weight: bold; color: var(--text-color); font-size: 15px; }
.header-user-menu.active .dropdown-menu { display: flex; } 

/* Floating Chat Widget */
.floating-chat-widget { position: fixed; bottom: 20px; z-index: 1000; transition: left 0.3s, right 0.3s; }
.floating-chat-widget.pos-right { right: 20px; left: auto; }
.floating-chat-widget.pos-left { left: 20px; right: auto; }

.chat-circle { width: 60px; height: 60px; background: var(--card-bg); border: 2px solid var(--accent-color); border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 24px; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.5); transition: transform 0.2s; position: relative; }
.chat-circle:hover { transform: scale(1.05); }

.chat-box { width: 320px; height: 450px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; display: none; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,0.8); overflow: hidden; }
.chat-box-header { background: var(--bg-color); padding: 12px 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; cursor: pointer; color: var(--accent-color); }

/* Friend List View */
.chat-friend-list { flex-grow: 1; overflow-y: auto; padding: 5px 0; display: block; }
.chat-friend-item { display: flex; align-items: center; gap: 12px; padding: 12px 15px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05); }
.chat-friend-item:hover { background: var(--bg-color); }
.chat-friend-item img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-friend-item.unread .unread-dot { width: 10px; height: 10px; background: #ff0055; border-radius: 50%; margin-left: auto; }

/* Active Chat View */
.chat-active-view { flex-grow: 1; display: none; flex-direction: column; }
.chat-history { flex-grow: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-color); }
.chat-msg { background: var(--card-bg); padding: 10px 12px; border-radius: 8px; font-size: 13px; max-width: 80%; line-height: 1.4; color: var(--text-color); border: 1px solid var(--border-color); }
.chat-msg.mine { align-self: flex-end; background: var(--accent-color); color: #000; border: none; }
.chat-input-area { display: flex; padding: 10px; border-top: 1px solid var(--border-color); background: var(--card-bg); gap: 10px; }
.chat-input-area input { flex-grow: 1; padding: 10px 15px; border-radius: 20px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color); outline: none; font-size: 13px; }

.global-toolbar { width: 100%; background: var(--accent-color); padding: 0 30px; display: flex; align-items: center; }
.toolbar-link { color: var(--accent-text-color, #000); font-weight: bold; padding: 12px 15px; text-decoration: none; cursor: pointer; position: relative; display: flex; align-items: center; }
.dropdown-menu.right-aligned { right: 0; left: auto; }
.toolbar-link:hover { background: rgba(0,0,0,0.1); }

/* Hover Dropdowns */
.dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background: var(--card-bg); border: 1px solid var(--border-color); min-width: 200px; z-index: 100; box-shadow: var(--card-shadow); flex-direction: column; }
.toolbar-link:hover .dropdown-menu { display: flex; }
.dropdown-menu a { padding: 10px 15px; color: var(--text-color); text-decoration: none; border-bottom: 1px solid var(--border-color); font-size: 13px; font-weight: normal; }
.dropdown-menu a:hover { background: var(--bg-color); color: var(--accent-color); }

/* --- MASTER LAYOUT UPDATE (Expanded to 1500px for Ads) --- */
.profile-master-container {
    display: flex;
    flex-direction: row; 
    flex-wrap: nowrap; 
    width: 1500px; /* Expanded for 300px Right Ad Sidebar */
    max-width: 100vw; 
    margin: 40px auto;
    align-items: flex-start;
    gap: 0; 
}

/* 300px Right Ad Sidebar */
.ad-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-left: 20px;
}
.sidebar-ad { width: 100%; background: var(--card-bg); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 12px; }
.ad-box-1 { height: 250px; }
.ad-box-2 { height: 600px; }

/* Friends 3x3 Grid (Strictly Constrained) */
.sidebar-links { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.sidebar-links a { color: var(--text-color); font-weight: bold; font-size: 14px; text-decoration: none; padding-bottom: 5px; border-bottom: 1px solid var(--border-color); }
.sidebar-links a:hover { color: var(--accent-color); }

.friends-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; box-sizing: border-box; }
.friends-grid a { display: block; width: 100%; overflow: hidden; border-radius: 4px; }
.friends-grid a img { width: 100%; height: 75px; object-fit: cover; border: 1px solid var(--border-color); display: block; transition: border-color 0.2s; }
.friends-grid a img:hover { border-color: var(--accent-color); cursor: pointer; }

/* 300px Sticky Sidebar */
.profile-sidebar {
    width: 300px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 12px 0 0 12px; /* Flat right edge */
    box-sizing: border-box;
}

/* 900px Infinite Canvas & Comment Section */
.profile-main-canvas {
    width: 900px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

/* 3x3 Infinite Grid (Sliced into 50px layers) */
.grid-canvas {
    display: grid;
    grid-template-columns: repeat(3, 300px);
    grid-auto-rows: 50px;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
}

/* Grid Blocks (Widgets) */
.grid-block {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Hidden Door Widget Mechanics */
.widget-hidden-door {
    overflow: visible; /* Allows doors to span over neighboring blocks */
    z-index: 10;
}

.door-panel {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    background-color: var(--accent-color);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    cursor: pointer;
    background-size: cover;
    background-position: center;
}

.door-left { left: 0; transform-origin: left; }
.door-right { right: 0; transform-origin: right; }

/* Open State */
.door-left.open { transform: translateX(-100%); z-index: 50; }
.door-right.open { transform: translateX(100%); z-index: 50; }

.door-interior {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 15;
}

/* Avatar Frame Overlays */
.avatar-container { position: relative; width: 100%; padding-top: 100%; margin-bottom: 15px; }
.avatar-image { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-frame { position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px; pointer-events: none; }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; border-radius: 6px; margin-bottom: 12px; }
.badge-primary { background-color: var(--accent-color); color: #000; }

/* --- 3D WIDGET MECHANICS --- */
.widget-3d-viewport {
    perspective: 1000px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-3d {
    width: 200px;
    height: 200px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s linear; /* Smooth drag rotation */
    cursor: grab;
}
.shape-3d:active { cursor: grabbing; }

/* Shape Faces Base */
.shape-face {
    position: absolute;
    width: 200px;
    height: 200px;
    background: var(--card-bg);
    border: 2px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    box-sizing: border-box;
    backface-visibility: hidden;
    overflow: hidden;
    color: var(--text-color);
    font-weight: bold;
}

/* Image overrides for faces */
.shape-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; left: 0;
}

.face-content { z-index: 2; position: relative; }

/* Cube Construction (6 Faces) */
.cube .face-1 { transform: rotateY(0deg) translateZ(100px); }
.cube .face-2 { transform: rotateY(180deg) translateZ(100px); }
.cube .face-3 { transform: rotateY(-90deg) translateZ(100px); }
.cube .face-4 { transform: rotateY(90deg) translateZ(100px); }
.cube .face-5 { transform: rotateX(90deg) translateZ(100px); }
.cube .face-6 { transform: rotateX(-90deg) translateZ(100px); }

/* Sphere/Coin Construction (2 Faces) */
.coin { border-radius: 50%; }
.coin .shape-face { border-radius: 50%; }
.coin .face-1 { transform: rotateY(0deg) translateZ(10px); }
.coin .face-2 { transform: rotateY(180deg) translateZ(10px); }

/* Triangle Construction (4 Faces - Simplified Pyramid) */
.pyramid .shape-face {
    /* Using CSS clip-path to create triangles */
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: transparent;
    border: none;
}
.pyramid .shape-face::before {
    content: '';
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--card-bg);
    border-bottom: 4px solid var(--accent-color);
    z-index: -1;
}
.pyramid .face-1 { transform: rotateY(0deg) translateZ(50px) rotateX(30deg); }
.pyramid .face-2 { transform: rotateY(90deg) translateZ(50px) rotateX(30deg); }
.pyramid .face-3 { transform: rotateY(180deg) translateZ(50px) rotateX(30deg); }
.pyramid .face-4 { transform: rotateY(-90deg) translateZ(50px) rotateX(30deg); }