/* 
   Memoria Orbis - Modern Dark Mode / Glassmorphism UI
   Tone: Clean, minimalist, trustworthy, productivity-focused
*/

:root {
    --bg-base: #0a0b10;
    --bg-panel: rgba(20, 22, 30, 0.4);
    --bg-panel-hover: rgba(30, 34, 45, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f2f5;
    --text-muted: #9aa0a6;
    --accent: #5865f2; /* Discord blurple */
    --blurple: #5865f2;
    --accent-green: #43b581; /* Discord green */
    --accent-red: #f04747; /* Discord red */
    --radius: 12px;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.3);

    color-scheme: dark;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Status Pill */
.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(67, 181, 129, 0.4);
    animation: status-pulse 2.5s infinite ease-in-out;
}

@keyframes status-pulse {
    0% { transform: scale(0.9); opacity: 0.6; box-shadow: 0 0 0 0 rgba(67, 181, 129, 0.3); }
    50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 6px rgba(67, 181, 129, 0); }
    100% { transform: scale(0.9); opacity: 0.6; box-shadow: 0 0 0 0 rgba(67, 181, 129, 0); }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    /* Subtle background grid */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 30px 30px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Glass panel utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 32px;
}

.single-col {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Base button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.btn-discord {
    background-color: var(--accent);
    color: white;
}

.btn-discord:hover {
    background-color: var(--blurple);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
}

.btn-slack {
    background-color: white;
    color: #1a1d21;
    border: 1px solid #ddd;
}

.btn-slack:hover {
    background-color: #f8f8f8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-sm {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    color: white;
}

.btn-sm:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-glass);
}

.login-divider:not(:empty)::before {
    margin-right: 1em;
}

.login-divider:not(:empty)::after {
    margin-left: 1em;
}

/* ===== LOGIN PAGE ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fancy radial gradient glow for login */
    background: radial-gradient(circle at 50% -20%, rgba(88, 101, 242, 0.15) 0%, transparent 50%), var(--bg-base);
}

.login-card {
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-card .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.login-card h2 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.login-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-body {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    border-right: 1px solid var(--border-glass);
    background: rgba(10, 11, 16, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 40px;
    color: var(--text-primary);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-links a {
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.badge {
    background: rgba(88, 101, 242, 0.2);
    color: #aeb5ff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-glass);
}

.user-card img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .username {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info .logout {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-info .logout:hover {
    color: #ff6b6b;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
}

/* Ambient glows */
.blur-blob {
    position: fixed;
    width: 400px;
    height: 400px;
    background: var(--accent);
    filter: blur(120px);
    opacity: 0.15;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
}

.blur-blob.tl {
    top: -100px;
    left: -100px;
}

.blur-blob.br {
    bottom: -100px;
    right: -100px;
    background: #6b43a6;
}

/* Header */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    flex-wrap: wrap; /* Added to handle mobile wrapping */
    gap: 16px;
}

.topbar h1 {
    font-size: 1.8rem;
    letter-spacing: -0.5px;
}

.search-bar {
    position: relative;
    width: 300px;
}

.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 10px 10px 10px 40px;
    border-radius: var(--radius);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Grid */
.billing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.memories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.memory-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.memory-card.interactive:hover {
    background: var(--bg-panel-hover);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.memory-card h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.memory-card .summary {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-state svg {
    margin-bottom: 8px;
}

.empty-state h3 {
    font-size: 1.2rem;
}

/* ===== DETAIL PAGE ===== */
.detail-view .content {
    max-width: 900px;
    margin: 0 auto;
}

.detail-view .detail-container {
    padding: 40px;
}

.back-link {
    color: var(--text-muted);
    font-size: 0.9rem;
    display: inline-flex;
    margin-bottom: 24px;
}

.back-link:hover {
    color: var(--text-primary);
}

.detail-header {
    margin-bottom: 40px;
}

.detail-header .meta-row {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.detail-header h1 {
    font-size: 2.2rem;
    letter-spacing: -0.5px;
    margin-bottom: 24px;
}

.summary-box {
    background: rgba(88, 101, 242, 0.08);
    border-left: 3px solid var(--accent);
    padding: 20px;
    border-radius: 4px 8px 8px 4px;
}

.summary-box strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #aeb5ff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.conversation-thread h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-muted);
    font-weight: 500;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-glass);
}

.chat-msg {
    display: grid;
    grid-template-areas:
        "author time"
        "content content";
    grid-template-columns: 1fr auto;
    gap: 4px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-msg:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.chat-msg.target-msg {
    background: rgba(88, 101, 242, 0.1);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(88, 101, 242, 0.2);
}

.msg-author {
    grid-area: author;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.msg-time {
    grid-area: time;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.msg-content {
    grid-area: content;
    color: #d1d5db;
    line-height: 1.5;
    word-break: break-word;
}

.context-warning {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 171, 0, 0.1);
    border: 1px solid rgba(255, 171, 0, 0.2);
    color: #ffd073;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Desktop Defaults */
.mobile-members-list {
    display: none;
}

.desktop-members-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}

.desktop-members-table th {
    padding: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.desktop-members-table td {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.member-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.member-name {
    font-weight: 600;
}

.member-discord-id {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.member-actions {
    display: flex;
    gap: 8px;
}

.btn-kick {
    background: none;
    border: 1px solid #f87171;
    color: #f87171;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.btn-kick:hover {
    background: #f87171;
    color: white;
}

.menu-toggle {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-body {
        flex-direction: column;
        overflow-x: hidden;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 12px 20px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        z-index: 100;
        position: sticky;
        top: 0;
    }

    .sidebar .logo {
        margin-bottom: 0;
        font-size: 1rem;
    }

    /* Mobile specifically hides links until toggled */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #0a0b10;
        padding: 24px;
        border-bottom: 1px solid var(--border-glass);
        flex-direction: column;
        gap: 14px;
        animation: slideDown 0.3s ease forwards;
        max-height: calc(100vh - 80px); /* Ensure it doesn't exceed screen height */
        overflow-y: auto;   /* Enable scrolling within the menu */
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    }

    .nav-links.show {
        display: flex;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .user-card {
        margin-left: initial;
        padding-top: 0;
        border-top: none;
    }

    .user-info .username {
        display: none;
    }

    /* Hide username to save space */

    .menu-toggle {
        display: flex !important;
        background: transparent;
        border: 1px solid var(--border-glass);
        color: white;
        padding: 8px;
        border-radius: 8px;
        cursor: pointer;
    }

    .content {
        padding: 20px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .search-bar {
        width: 100%;
    }

    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .settings-row div, .settings-row .settings-value {
        width: 100%;
        display: block;
    }

    .settings-row .btn, .settings-row button {
        width: 100%;
    }

    .glass-panel {
        padding: 20px;
    }

    .billing-grid, .memories-grid {
        grid-template-columns: 1fr !important;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .mobile-form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    /* Team Members Responsive */
    .desktop-members-table {
        display: none;
    }

    .mobile-members-list {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .member-card-mobile {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border-glass);
        border-radius: 12px;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .member-card-mobile .member-identity {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .member-card-mobile .member-avatar {
        width: 44px;
        height: 44px;
        border-radius: 50%;
    }

    .member-card-mobile .member-name {
        font-weight: 600;
        font-size: 1.1rem;
    }

    .member-card-mobile .member-meta-mobile {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 12px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .member-card-mobile .member-discord-id {
        font-family: monospace;
        font-size: 0.8rem;
        color: var(--text-muted);
    }

    .member-card-mobile .member-joined {
        font-size: 0.8rem;
        color: var(--text-muted);
    }

    .member-card-mobile .member-actions-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .member-card-mobile .member-actions-mobile .input-glass {
        width: 100%;
    }

    .btn-kick {
        background: rgba(248, 113, 113, 0.1);
        border: 1px solid #f87171;
        color: #f87171;
        padding: 8px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 0.85rem;
        font-weight: 600;
        transition: all 0.2s ease;
    }
}
/* ===== MODERN SPA ANIMATIONS (Framer Motion style) ===== */
@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(24px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideRightFade {
    0% {
        opacity: 0;
        transform: translateX(-24px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleInFade {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Globally animate the sidebar entering */
.sidebar {
    animation: slideRightFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Topbar entering */
.topbar {
    opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
}

/* Staggered Grid Items */
.memories-grid .memory-card {
    opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.memories-grid .memory-card:nth-child(1)  { animation-delay: 0.10s; }
.memories-grid .memory-card:nth-child(2)  { animation-delay: 0.15s; }
.memories-grid .memory-card:nth-child(3)  { animation-delay: 0.20s; }
.memories-grid .memory-card:nth-child(4)  { animation-delay: 0.25s; }
.memories-grid .memory-card:nth-child(5)  { animation-delay: 0.30s; }
.memories-grid .memory-card:nth-child(6)  { animation-delay: 0.35s; }
.memories-grid .memory-card:nth-child(7)  { animation-delay: 0.40s; }
.memories-grid .memory-card:nth-child(8)  { animation-delay: 0.45s; }
.memories-grid .memory-card:nth-child(9)  { animation-delay: 0.50s; }
.memories-grid .memory-card:nth-child(n+10) { animation-delay: 0.55s; }

/* Detail View Entries */
.detail-view .back-link {
    opacity: 0;
    animation: slideRightFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
}

.detail-view .detail-header {
    opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.15s;
}

.detail-view .conversation-thread {
    opacity: 0;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.25s;
}

/* Knowledge Graph Canvas */
#graph {
    opacity: 0;
    animation: scaleInFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.2s;
}

/* Interactive subtle pulse for main buttons */
.btn-discord {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.2s ease;
}
.btn-discord:active {
    transform: scale(0.96) !important;
}

/* Glass Inputs / Selects */
.input-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 8px 12px;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.input-glass:focus {
    border-color: rgba(255, 255, 255, 0.2);
}

.input-glass option {
    background-color: #1a1b26;
    color: var(--text-primary);
}

/* Inputs and Forms Focus Ring */
input:focus, textarea:focus, select:focus {
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.4);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Command Center Entry Button */
.btn-command-center {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(74, 222, 128, 0.03);
    border: 1px solid rgba(74, 222, 128, 0.1);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 8px 0 24px 0;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-command-center:hover {
    background: rgba(74, 222, 128, 0.08);
    border-color: rgba(74, 222, 128, 0.3);
    transform: translateX(2px);
    box-shadow: -5px 0 20px rgba(74, 222, 128, 0.05);
}

.btn-command-center .badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 1px;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}