/* ================================
   EnchantedDB — Split View Layout
   ================================ */

:root {
    --bg-deep: #0c0e14;
    --bg-hero: #111520;
    --bg-section: #13161e;
    --bg-section-alt: #0f1118;
    --bg-card: #191d28;
    --bg-card-hover: #1e2332;
    --bg-input: #181c26;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.1);
    --accent: #00b4ff;
    --accent-dark: #0088cc;
    --accent-dim: rgba(0, 180, 255, 0.12);
    --text: #ffffff;
    --text-secondary: #8a8f98;
    --text-muted: #575d66;
    /* Slightly lighter for readability */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s ease;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.view {
    display: none;
}

.view.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ================================
   NAVBAR
   ================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(17, 21, 32, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 54px;
}

.nav-inner {
    width: 100%;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.nav-logo {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.nav-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.accent {
    color: var(--accent);
}

.nav-tabs {
    display: flex;
    gap: 30px;
    height: 100%;
    align-items: center;
    margin-right: auto;
    margin-left: 3rem;
}

.nav-tab {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    height: 100%;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.nav-tab:hover {
    color: var(--text);
}

.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.nav-search {
    position: relative;
    max-width: 280px;
    flex: 1;
}

.nav-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}

#nav-search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 7px 14px 7px 34px;
    font-family: var(--font);
    font-size: 0.82rem;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}

#nav-search-input::placeholder {
    color: var(--text-muted);
}

#nav-search-input:focus {
    border-color: var(--accent);
}

/* ================================
   HOME VIEWS (HERO/SECTIONS)
   (Keeping existing styles for home view)
   ================================ */
.hero {
    position: relative;
    padding: 6rem 2rem 4rem;
    text-align: center;
    overflow: hidden;
    background: var(--bg-hero);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 600px 400px at 50% 30%, rgba(0, 180, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 620px;
    margin: 0 auto;
}

.hero-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 20px var(--accent-dim));
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-search {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 28px;
    overflow: hidden;
}

.hero-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

#search-input {
    flex: 1;
    background: none;
    border: none;
    padding: 13px 0 13px 22px;
    color: var(--text);
    outline: none;
}

.hero-search-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0 28px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.hero-search-btn:hover {
    background: var(--accent-dark);
}

.search-error {
    color: #f85149;
    font-size: 0.85rem;
    margin-top: 0.8rem;
    min-height: 1.2em;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.section {
    padding: 3rem 2rem;
    background: var(--bg-section);
    border-top: 1px solid var(--border);
}

.section-alt {
    background: var(--bg-section-alt);
}

.section-inner {
    max-width: 1000px;
    margin: 0 auto;
}

.section-heading {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
}

.player-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
}

.player-card-info {
    min-width: 0;
}

.player-card-name {
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-card-xuid {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
    padding: 2rem 0;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.5rem 1rem;
    text-align: center;
    border-radius: var(--radius);
}

.stat-number {
    font-size: 2rem;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
}

.site-footer {
    padding: 1.5rem 2rem;
    background: var(--bg-deep);
    border-top: 1px solid var(--border);
}

.footer-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ================================
   PROFILE VIEW (SPLIT LAYOUT)
   ================================ */
/* Profile View Overhaul */
.profile-bg {
    background: #080a0f;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.profile-container {
    width: 100%;
    height: calc(100vh - 54px);
    display: flex;
    position: relative;
    z-index: 10;
}

/* Background Decorations */
.profile-decorations {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.glow-bg {
    position: absolute;
    width: 140%;
    height: 140%;
    top: -20%;
    left: -20%;
    background:
        radial-gradient(circle at 20% 30%, rgba(0, 180, 255, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(0, 180, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(12, 14, 20, 1) 0%, transparent 100%);
    filter: blur(60px);
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(circle at 50% 50%, black, transparent 80%);
    opacity: 0.15;
}

.bg-name-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.bg-gamertag-text {
    font-size: 8vw;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.02);
    text-transform: uppercase;
    white-space: nowrap;
    letter-spacing: -0.05em;
    transform: rotate(-10deg);
}

/* LEFT COLUMN: MODEL & CONTROLS */
.profile-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 2rem;
}

.model-unavailable {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.model-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 2rem;
    z-index: 10;
}

#player-model {
    width: 600px !important;
    height: 800px !important;
    max-width: 100%;
    max-height: 80vh;
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover,
.control-btn.active {
    color: var(--text);
    background: var(--bg-card-hover);
}

/* RIGHT COLUMN: SIDEBAR (GLASSMORPHISM) */
.profile-sidebar {
    width: 550px;
    background: rgba(13, 16, 23, 0.6);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
    position: relative;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 2.5rem 2rem;
    gap: 1.5rem;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-icon {
    width: 54px;
    height: 54px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.sidebar-titles {
    display: flex;
    flex-direction: column;
}

.profile-gamertag {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    color: var(--text);
    letter-spacing: -0.5px;
}

.profile-xuid {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.6;
    margin: 0;
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-top: 2px;
}

.sidebar-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Scrollbar styling for sidebar */
.sidebar-scrollable::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar-scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Info Stack Layout (re-written for sidebar) */
/* Info Stack Layout */
.info-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), background var(--transition);
}

.info-section:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.section-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.8rem;
}

/* Badges */
.badges-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.gold-gradient {
    background: linear-gradient(135deg, #ffc400, #ff8c00);
}

.blue-gradient {
    background: linear-gradient(135deg, #00b4ff, #0055ff);
}

/* Capes */
.capes-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cape-item {
    width: 42px;
    height: 68px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Stats grid */
.stats-grid-small {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: fit-content;
}

.stat-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 2px;
}

.stat-lbl {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* CAPES BROWSER GRID */
.capes-browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.cape-browser-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.cape-browser-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 243, 255, 0.1);
}

.cape-browser-preview {
    width: 100px;
    height: 160px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s ease;
}

.cape-browser-card:hover .cape-browser-preview {
    transform: scale(1.05);
}

.cape-browser-id {
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    width: 100%;
    text-align: center;
    line-height: 1.1;
    word-break: break-word;
    /* Truncation removed for dynamic scaling */
}

.cape-browser-uuid {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    margin-top: 2px;
}

/* CAPE DETAIL SPECIFIC */
.cape-detail-large-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.cape-detail-large {
    height: 70vh;
    image-rendering: pixelated;
    filter: drop-shadow(0 20px 50px rgba(0, 0, 0, 0.8));
    animation: floatingCape 6s ease-in-out infinite;
}

@keyframes floatingCape {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: var(--accent);
}

.back-btn svg {
    transition: transform 0.2s ease;
}

.back-btn:hover svg {
    transform: translateX(-3px);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 900px) {
    .profile-container {
        flex-direction: column;
        overflow-y: auto;
    }

    .profile-sidebar {
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }
}

@media (max-width: 650px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
}