:root {
    --bg: #050505;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-elevated: rgba(255, 255, 255, 0.08);
    --accent: #ffffff;
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.4);
    --error: #ff453a;
    --success: #34c759;
    --ios-blur: blur(30px);
    --ios-border: rgba(255, 255, 255, 0.08);
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    background: radial-gradient(circle at 50% 0%, #1a1a1a, #050505);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    padding: calc(140px + env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom)) 16px;
    min-height: 100dvh;
    overflow-x: hidden;
}

.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.glow-1 {
    position: absolute;
    top: -10%;
    right: -10%;
    width: 70%;
    height: 70%;
    background: radial-gradient(circle, rgba(100, 100, 255, 0.04) 0%, transparent 70%);
    filter: blur(100px);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    margin-top: 10px;
}

h2 {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(to bottom, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Search Bar */
.search-container {
    margin-bottom: 28px;
    position: relative;
    z-index: 100; /* Ensure search results sit above friend lists */
    animation: slideDown 0.6s var(--transition-bounce) both;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-wrapper {
    background: var(--surface);
    border: 1px solid var(--ios-border);
    border-radius: 22px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: var(--ios-blur);
    -webkit-backdrop-filter: var(--ios-blur);
    transition: all 0.3s ease;
}

.search-wrapper:focus-within {
    background: var(--surface-elevated);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.search-wrapper input {
    background: none;
    border: none;
    color: #fff;
    width: 100%;
    outline: none;
    font-size: 15px;
    font-weight: 500;
}

.search-wrapper input::placeholder {
    color: var(--muted);
}

.search-results {
    position: absolute;
    top: 65px;
    left: 0;
    right: 0;
    background: #0a0a0a !important; /* Solid dark background */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 22px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 9999 !important; /* Make sure it's on top of everything */
    display: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255,255,255,0.05);
    padding: 8px;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

/* Requests Section */
#requests-section {
    margin-bottom: 32px;
    display: none;
    animation: fadeIn 0.8s ease both 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.request-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 26px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.request-info {
    flex: 1;
}

.request-name {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 2px;
}

.request-sub {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.request-actions {
    display: flex;
    gap: 10px;
}

.btn-request {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--transition-bounce);
}

.btn-accept {
    background: #fff;
    color: #000;
    border: none;
}

.btn-decline {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid var(--ios-border);
}

.btn-request:active {
    transform: scale(0.85);
}

/* Section Styling */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* User List */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.user-item {
    background: var(--surface);
    border: 1px solid var(--ios-border);
    border-radius: 24px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.user-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.user-item:active {
    transform: scale(0.97) translateX(4px);
    background: var(--surface-elevated);
}

.user-item:active::before {
    transform: translateX(100%);
}

.user-avatar-wrapper {
    position: relative;
}

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ios-border);
    background: #111;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border: 2px solid var(--bg);
    border-radius: 50%;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.2px;
}

.user-handle {
    font-size: 13px;
    color: var(--muted);
    margin-top: 1px;
}

.btn-action {
    padding: 8px 16px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-delete {
    color: var(--error);
    background: rgba(255, 69, 58, 0.08);
    border: 1px solid rgba(255, 69, 58, 0.15);
}

.btn-add {
    background: #fff;
    color: #000;
    border: none;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-action:active {
    transform: scale(0.9);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    background: var(--surface);
    border-radius: 30px;
    border: 1px dashed var(--ios-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Modal - Profile Quick View */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(40px) saturate(180%);
    z-index: 2000;
    display: none;
    padding: 40px 20px;
    animation: modalFade 0.4s ease;
}

@keyframes modalFade {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(40px); }
}

.modal-content {
    max-width: 400px;
    margin: 40px auto;
    text-align: center;
    animation: modalScale 0.5s var(--transition-bounce);
    max-height: 85vh;
    overflow-y: auto;
    padding: 0 10px 40px 10px;
}

/* Hide scrollbar for modal content but keep it scrollable */
.modal-content::-webkit-scrollbar {
    display: none;
}
.modal-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.modal-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.modal-post-item {
    aspect-ratio: 1;
    border-radius: 12px;
    background: #222;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--ios-border);
}

.modal-post-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes modalScale {
    from { transform: scale(0.8) translateY(30px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-avatar {
    width: 140px;
    height: 140px;
    border-radius: 40px;
    border: 4px solid #fff;
    margin-bottom: 24px;
    object-fit: cover;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: rotate(-3deg);
}

.modal-name {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.modal-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 24px 0;
}

.m-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.m-stat-val { font-weight: 700; font-size: 1.2rem; }
.m-stat-lab { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.modal-close {
    position: absolute;
    top: 30px;
    right: 25px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
