/* ============================================================
   Fluxer Dashboard — Star's Theme
   Primary accent: #4470B0 (Star blue)
   Two modes: light (default) and dark
   Animated floating shapes in background
   ============================================================ */

/* ─── CSS Variables ────────────────────────────────────────── */
:root {
    --accent:        #4470B0;
    --accent-strong: #2d52a0;
    --accent-soft:   #7fa3d4;
    --accent-glow:   rgba(68, 112, 176, 0.35);

    --bg:            #f0f4fb;
    --bg-strong:     #e0e8f5;
    --panel:         rgba(255, 255, 255, 0.88);
    --panel-strong:  #ffffff;
    --border:        rgba(68, 112, 176, 0.14);
    --text:          #1a2540;
    --muted:         #5a6e8c;
    --shadow:        0 12px 40px rgba(30, 60, 120, 0.14);
    --radius:        18px;
    --nav-height:    64px;

    --surface:       rgba(240, 244, 251, 0.9);
    --input-bg:      rgba(255, 255, 255, 0.8);
    --input-border:  rgba(68, 112, 176, 0.22);
    --success:       #2ea879;
    --danger:        #e05252;
    --warn:          #d4943a;
}

[data-theme="dark"] {
    --bg:            #0d111a;
    --bg-strong:     #060810;
    --panel:         rgba(18, 24, 38, 0.92);
    --panel-strong:  #131b2e;
    --border:        rgba(100, 148, 220, 0.2);
    --text:          #e8edf8;
    --muted:         #8ba0c2;
    --shadow:        0 16px 50px rgba(0, 0, 0, 0.5);
    --surface:       rgba(20, 28, 46, 0.92);
    --input-bg:      rgba(18, 24, 38, 0.85);
    --input-border:  rgba(100, 148, 220, 0.28);
    --accent-glow:   rgba(68, 112, 176, 0.45);
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    font-size: 15px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Animated Background Shapes ───────────────────────────── */
.bg-shapes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.07;
    background: var(--accent);
    animation: floatShape linear infinite;
}

[data-theme="dark"] .bg-shape { opacity: 0.1; }

.bg-shape:nth-child(1)  { width: 380px; height: 380px; top: -80px;  left: -80px;  animation-duration: 28s; animation-delay: 0s;   }
.bg-shape:nth-child(2)  { width: 220px; height: 220px; top: 30%;    right: 5%;   animation-duration: 22s; animation-delay: -6s;  }
.bg-shape:nth-child(3)  { width: 500px; height: 500px; bottom: -120px; right: -80px; animation-duration: 35s; animation-delay: -12s; }
.bg-shape:nth-child(4)  { width: 150px; height: 150px; top: 60%;    left: 15%;   animation-duration: 18s; animation-delay: -3s;  }
.bg-shape:nth-child(5)  { width: 280px; height: 280px; top: 20%;    left: 40%;   animation-duration: 30s; animation-delay: -9s;  }

@keyframes floatShape {
    0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
    25%  { transform: translate(20px, -30px) rotate(15deg) scale(1.05); }
    50%  { transform: translate(-15px, 25px) rotate(-10deg) scale(0.97); }
    75%  { transform: translate(10px, 15px) rotate(20deg) scale(1.03); }
    100% { transform: translate(0, 0) rotate(0deg) scale(1); }
}

/* ─── Navigation ────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    background: var(--panel);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    gap: 1.5rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.nav-brand img { width: 32px; height: 32px; border-radius: 50%; }

.nav-links {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin-left: 1rem;
}

.nav-links a {
    padding: 0.35rem 0.75rem;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}

.nav-spacer { flex: 1; }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 10px;
    background: var(--surface);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border: 1px solid var(--border);
    text-decoration: none;
}

.nav-user img { width: 24px; height: 24px; border-radius: 50%; }
.nav-user:hover { background: var(--bg-strong); text-decoration: none; }

/* ─── Theme Toggle ──────────────────────────────────────────── */
.theme-toggle {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
    font-size: 1rem;
    transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover { background: var(--bg-strong); color: var(--text); }

/* ─── Main Layout ───────────────────────────────────────────── */
.page-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.page-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ─── Cards & Panels ────────────────────────────────────────── */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

/* ─── Settings Layout ───────────────────────────────────────── */
.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 768px) {
    .settings-layout { grid-template-columns: 1fr; }
}

.settings-nav {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    position: sticky;
    top: calc(var(--nav-height) + 1rem);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.875rem;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
}

.settings-nav-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.settings-nav-item.active { background: var(--surface); color: var(--accent); }
.settings-nav-item .icon { width: 18px; opacity: 0.7; font-size: 0.9rem; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
    color: #fff;
    text-decoration: none;
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-strong);
    color: var(--text);
    text-decoration: none;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #c03030);
    color: #fff;
}

.btn-danger:hover { transform: translateY(-1px); color: #fff; text-decoration: none; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; border-radius: 12px; }

/* ─── Form Controls ─────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border-radius: 10px;
    border: 1.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea { resize: vertical; min-height: 90px; }

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-label { font-size: 0.9rem; font-weight: 500; }
.toggle-hint  { font-size: 0.78rem; color: var(--muted); }

.toggle {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ─── Guild Grid ────────────────────────────────────────────── */
.guild-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.guild-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    text-decoration: none;
    display: block;
    color: var(--text);
}

.guild-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 24px var(--accent-glow);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}

.guild-card .guild-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
}

.guild-card .guild-icon img { width: 100%; height: 100%; object-fit: cover; }
.guild-card .guild-name { font-weight: 600; font-size: 0.9rem; }
.guild-card .guild-badge {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-managed { background: rgba(68, 112, 176, 0.15); color: var(--accent); }
.badge-invite  { background: rgba(46, 168, 121, 0.15); color: var(--success); }

/* ─── Hero (Home page) ──────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 6rem 2rem 4rem;
    position: relative;
    z-index: 1;
}

.hero-logo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    box-shadow: 0 0 0 4px var(--panel), 0 0 0 6px var(--accent-glow);
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--muted);
    max-width: 460px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Stats bar ─────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.stat-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.875rem 1.25rem;
    flex: 1;
    min-width: 140px;
}

.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; }

/* ─── Unsaved Changes Banner ────────────────────────────────── */
.unsaved-banner {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--panel-strong);
    border: 1.5px solid var(--accent);
    border-radius: 14px;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 500;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}

.unsaved-banner.visible {
    transform: translateX(-50%) translateY(0);
}

.unsaved-banner .unsaved-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.unsaved-banner .unsaved-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(1.3); }
}

/* ─── Toast Notifications ───────────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 1rem);
    right: 1.5rem;
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    min-width: 260px;
    max-width: 360px;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    box-shadow: var(--shadow);
    pointer-events: all;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: opacity 0.2s, transform 0.2s;
}

.toast.hiding {
    opacity: 0;
    transform: translateX(20px);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.05rem; }
.toast-body .toast-title { font-size: 0.85rem; font-weight: 600; }
.toast-body .toast-msg   { font-size: 0.78rem; color: var(--muted); }

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-warn    { border-left: 3px solid var(--warn); }

/* ─── Misc Utils ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.85rem; }
.font-bold { font-weight: 700; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
