/* ==========================================================================
   Dashboard + Server Rail
   ========================================================================== */

.dashboard-shell {
    position: relative;
    display: flex;
    min-height: calc(100vh - 78px);
    overflow-x: hidden;   /* clip rail drawer, never horizontal page scroll */
    background: var(--md-sys-color-surface-container-low);
}

.dashboard-mode {
    background: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
}

.dashboard-mode .top-bar {
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.dashboard-mode .top-bar-inner {
    max-width: none;
    margin: 0;
    padding: 0.75rem 1.5rem;
}

.dashboard-mode .brand,
.dashboard-mode .m3-text-button {
    color: var(--md-sys-color-primary);
}

.dashboard-mode .m3-text-button:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary) 8%, transparent);
}

.dashboard-mode .dashboard-main {
    color: var(--md-sys-color-on-surface);
}

.server-rail {
    width: 72px;
    flex-shrink: 0;
    background: var(--md-sys-color-surface-container);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    position: relative;
    z-index: 2;
    animation: railIn 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.server-rail::after {
    display: none;
}

@keyframes railIn {
    from { transform: translateX(-16px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.server-rail-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 0.8rem 0.2rem;
}

.server-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 0.5rem;
}

.server-folder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.server-folder[hidden] {
    display: none !important;
}

.server-folder-toggle .material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
}

.server-item {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: var(--md-sys-color-surface-container-high);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: transform 0.16s ease, border-radius 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
    position: relative;
}

.server-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(-2px);
    padding: 0.45rem 0.6rem;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--md-sys-color-shadow) 12%, transparent);
    z-index: 40;
}

.server-item:hover::after,
.server-item:focus-visible::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

@media (hover: none) {
    .server-item[data-tooltip]::after {
        display: none;
    }
}

.server-item:hover,
.server-item.active {
    border-color: color-mix(in srgb, var(--md-sys-color-primary) 60%, transparent);
    background: color-mix(in srgb, var(--md-sys-color-primary) 20%, var(--md-sys-color-surface-container-high));
    color: var(--md-sys-color-on-primary-container);
    border-radius: 16px;
    transform: translateY(-1px) scale(1.02);
}

.server-item::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    width: 4px;
    height: 0;
    border-radius: 999px;
    background: var(--md-sys-color-primary);
    transform: translateY(-50%);
    transition: height 0.16s ease;
}

.server-item:hover::before {
    height: 14px;
}

.server-item.active::before {
    height: 22px;
}

.server-item-avatar {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.server-item-home-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    opacity: 0.95;
}

.dashboard-sections {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.dashboard-section-block h2 {
    margin-bottom: 0.7rem;
}

.dashboard-server-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    align-items: start;
}

.dashboard-server-card-item {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 16px;
    background: var(--md-sys-color-surface-container);
    overflow: hidden;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.dashboard-server-card-item-locked {
    position: relative;
}

.dashboard-lock-overlay {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: color-mix(in srgb, #808080 22%, transparent);
    pointer-events: none;
    z-index: 2;
}

.dashboard-lock-overlay .material-symbols-outlined {
    position: absolute;
    right: 0.8rem;
    top: 0.8rem;
    font-size: 22px;
    color: var(--md-sys-color-error);
    background: color-mix(in srgb, var(--md-sys-color-error) 20%, var(--md-sys-color-surface));
    border: 1px solid color-mix(in srgb, var(--md-sys-color-error) 50%, transparent);
    border-radius: 999px;
    padding: 0.3rem;
}

.dashboard-server-card-item-locked .dashboard-server-head,
.dashboard-server-card-item-locked .dashboard-server-tags,
.dashboard-server-card-item-locked .dashboard-manage-button {
    opacity: 0.62;
}

.dashboard-server-card-item:hover {
    border-color: color-mix(in srgb, var(--md-sys-color-primary) 28%, var(--md-sys-color-outline-variant));
    background: color-mix(in srgb, var(--md-sys-color-primary) 5%, var(--md-sys-color-surface-container));
    transform: translateY(-1px);
}

.dashboard-server-card-item-example {
    border-style: dashed;
    opacity: 0.96;
}

.dashboard-server-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.dashboard-guild-icon,
.dashboard-guild-icon-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dashboard-guild-icon-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-container-low);
}

.dashboard-guild-meta {
    min-width: 0;
}

.dashboard-guild-meta p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-guild-meta span {
    color: var(--md-sys-color-on-surface-variant);
}

.dashboard-server-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.dashboard-manage-button {
    width: 100%;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 1;
    margin-top: 0.65rem;
}

.dashboard-tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 0.2rem 0.6rem;
    font-family: 'Roboto', system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-container-high);
}

.dashboard-tag-custom {
    color: var(--md-sys-color-on-primary-container);
    background: var(--md-sys-color-primary-container);
    border-color: color-mix(in srgb, var(--md-sys-color-primary) 35%, transparent);
}

.dashboard-tag-premium {
    color: var(--md-sys-color-on-tertiary-container);
    background: var(--md-sys-color-tertiary-container);
    border-color: color-mix(in srgb, var(--md-sys-color-tertiary) 35%, transparent);
}

.dashboard-tag-example {
    color: var(--md-sys-color-on-surface-variant);
    background: transparent;
    border-style: dashed;
}

.dashboard-empty {
    color: var(--md-sys-color-on-surface-variant);
}

.dashboard-main {
    flex: 1;
    min-width: 0;
    padding: 1.1rem 1.2rem 1.8rem;
    animation: dashIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
    background: var(--md-sys-color-surface-container-low);
}

@keyframes dashIn {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.dashboard-mobile-bar {
    display: none;
    margin-bottom: 0.8rem;
}

.dashboard-hero {
    margin-bottom: 1rem;
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 16px;
    padding: 1rem 1.1rem;
}

.dashboard-hero h1 {
    margin-bottom: 0.3rem;
}

.dashboard-hero p {
    color: var(--md-sys-color-on-surface-variant);
}

.dashboard-context-indicator {
    margin-top: 0.65rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.dashboard-context-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 0.2rem 0.6rem;
    font-family: 'Roboto', system-ui, sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-container-high);
}

.dashboard-context-chip-active {
    color: var(--md-sys-color-on-primary-container);
    background: var(--md-sys-color-primary-container);
    border-color: color-mix(in srgb, var(--md-sys-color-primary) 35%, transparent);
}

.nav-alert-strip {
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
}

.nav-alert-strip-inner {
    width: min(1200px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0.55rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-alert {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 0.5rem 0.7rem;
    font-family: 'Roboto', system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface-container-high);
}

.nav-alert .material-symbols-outlined {
    font-size: 18px;
}

.nav-alert-error {
    color: var(--md-sys-color-error);
    border-color: color-mix(in srgb, var(--md-sys-color-error) 34%, var(--md-sys-color-outline-variant));
    background: color-mix(in srgb, var(--md-sys-color-error) 11%, var(--md-sys-color-surface-container-high));
}

.nav-alert-success {
    color: #2f8d57;
    border-color: color-mix(in srgb, #2f8d57 30%, var(--md-sys-color-outline-variant));
    background: color-mix(in srgb, #2f8d57 10%, var(--md-sys-color-surface-container-high));
}

.nav-alert-info {
    color: var(--md-sys-color-primary);
    border-color: color-mix(in srgb, var(--md-sys-color-primary) 34%, var(--md-sys-color-outline-variant));
    background: color-mix(in srgb, var(--md-sys-color-primary) 10%, var(--md-sys-color-surface-container-high));
}

.dashboard-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 999px;
    margin-bottom: 1rem;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.dashboard-tabs::-webkit-scrollbar { display: none; }

.dashboard-tab-button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 999px;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    font-family: 'Roboto', system-ui, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.005rem;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.dashboard-tab-button:hover {
    background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
    color: var(--md-sys-color-on-surface);
}

.dashboard-tab-button.active {
    background: color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
    color: var(--md-sys-color-primary);
}

/* Labels hidden on desktop, shown on mobile via media query */
.server-folder-label,
.server-item-label {
    display: none;
}

@media (max-width: 860px) {
    .server-rail {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(84vw, 320px);
        max-width: 320px;
        transform: translateX(calc(-100% - 8px));
        transition: transform 0.28s ease;
        z-index: 35;
        box-shadow: 16px 0 40px color-mix(in srgb, var(--md-sys-color-shadow) 28%, transparent);
        border-right: 1px solid var(--md-sys-color-outline-variant);
        overflow-y: auto;
    }

    .server-rail.open {
        transform: translateX(0);
    }

    .server-rail-head {
        display: flex;
        padding: 1rem 1rem 0.35rem;
        gap: 0.5rem;
    }

    .server-list {
        align-items: stretch;
        padding: 0.75rem 0.75rem 1rem;
    }

    .server-folder {
        align-items: stretch;
        gap: 0.55rem;
    }

    .server-item {
        width: 100%;
        border-radius: 16px;
        justify-content: flex-start;
        gap: 0.75rem;
        padding: 0 0.85rem;
        min-height: 48px;
    }

    .server-item::before {
        left: 8px;
    }

    .server-item:hover,
    .server-item.active {
        transform: none;
    }

    .server-item-avatar {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }

    .server-folder-toggle {
        width: 100%;
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        gap: 0.65rem;
    }

    .server-folder-label {
        display: inline;
        font-family: 'Roboto', system-ui, sans-serif;
        font-size: 0.875rem;
        font-weight: 600;
        color: inherit;
    }

    .server-item-label {
        display: block;
        font-family: 'Roboto', system-ui, sans-serif;
        font-size: 0.8125rem;
        font-weight: 500;
        color: inherit;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
        text-align: left;
    }

    .dashboard-mobile-bar {
        display: block;
    }

    .dashboard-server-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-server-head {
        align-items: flex-start;
    }

    .dashboard-manage-button {
        width: 100%;
        justify-content: center;
    }

}

/* ── Guild loading skeleton ── */
@keyframes skeleton-shimmer {
    0%   { background-position: -200% center; }
    100% { background-position:  200% center; }
}

.dashboard-skeleton-card {
    min-height: 130px;
    background: linear-gradient(
        90deg,
        var(--md-sys-color-surface-container) 25%,
        color-mix(in srgb, var(--md-sys-color-primary) 6%, var(--md-sys-color-surface-container)) 50%,
        var(--md-sys-color-surface-container) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    pointer-events: none;
}

/* ============================================================
   Tablet breakpoint (no sidebar, but not phone-small)
   ============================================================ */
@media (max-width: 640px) {
    .dashboard-main {
        padding: 0.85rem 0.9rem 1.5rem;
    }
    .dashboard-hero {
        padding: 1rem 1.1rem;
    }
    .dashboard-hero h1,
    .dashboard-hero .m3-headline-large {
        font-size: 1.5rem;
    }
    .dashboard-mode .top-bar-inner {
        padding: 0.6rem 0.85rem;
    }
    .dashboard-tabs .dashboard-tab-button {
        padding: 0.4rem 0.65rem;
        font-size: 0.82rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ============================================================
   Small phones
   ============================================================ */
@media (max-width: 480px) {
    .dashboard-main {
        padding: 0.7rem 0.65rem 1.25rem;
    }
    .dashboard-hero {
        padding: 0.85rem 0.9rem;
        border-radius: 14px;
    }
    .dashboard-hero h1,
    .dashboard-hero .m3-headline-large {
        font-size: 1.3rem;
    }
    .dashboard-hero p,
    .dashboard-hero .m3-body-large {
        font-size: 0.875rem;
    }
    .dashboard-server-card-item {
        border-radius: 14px;
        padding: 0.85rem;
    }
    .dashboard-guild-icon {
        width: 36px;
        height: 36px;
    }
    .dashboard-tabs {
        border-radius: 12px;
        gap: 0.15rem;
        padding: 0.2rem;
    }
    .dashboard-tabs .dashboard-tab-button {
        flex-direction: column;
        gap: 0.1rem;
        padding: 0.45rem 0.6rem;
        font-size: 0.7rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .dashboard-tabs .dashboard-tab-button .material-symbols-outlined {
        font-size: 18px;
    }
}


