/*!
 * Family AI - Agent Zero Theme
 * Admin-style layout: fixed left sidebar with toggle (Joomla Atum-inspired)
 */

/* =========================================================
   CSS variables
   ========================================================= */
:root {
    --a0-bg:           #0a0a0f;
    --a0-bg-2:         #12121a;
    --a0-surface:      rgba(20, 20, 30, 0.85);
    --a0-surface-2:    rgba(30, 30, 45, 0.7);
    --a0-border:       rgba(139, 92, 246, 0.15);
    --a0-border-hi:    rgba(139, 92, 246, 0.45);
    --a0-text:         #e6e6f0;
    --a0-text-dim:     #9090a8;
    --a0-purple:       #8b5cf6;
    --a0-cyan:         #06b6d4;
    --a0-green:        #10b981;
    --a0-mono:         'SF Mono', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --a0-sidebar-open:    240px;
    --a0-sidebar-closed:  60px;
    --a0-header-h:        72px;
    --a0-transition:      cubic-bezier(.4, 0, .2, 1) 280ms;
}

/* =========================================================
   Reset & base
   ========================================================= */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body.familyai-agentzero {
    background: var(--a0-bg);
    color: var(--a0-text);
    font-family: var(--a0-mono);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: var(--a0-cyan); text-decoration: none; transition: color 180ms ease; }
a:hover { color: var(--a0-purple); }

/* Animated grid background */
.grid-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(139, 92, 246, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 92, 246, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: gridShift 40s linear infinite;
}
@keyframes gridShift {
    from { background-position: 0 0; }
    to   { background-position: 40px 40px; }
}

/* Terminal prompts/cursors */
.prompt {
    color: var(--a0-purple);
    font-weight: 700;
    margin-right: 8px;
}
.cursor {
    display: inline-block;
    color: var(--a0-cyan);
    animation: blink 1s step-end infinite;
    margin-left: 4px;
}
@keyframes blink {
    0%, 50%   { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* =========================================================
   Wrapper layout
   ========================================================= */
.a0-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* =========================================================
   Sidebar (fixed, left)
   ========================================================= */
.a0-sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--a0-sidebar-open);
    background: linear-gradient(180deg, var(--a0-bg-2) 0%, var(--a0-bg) 100%);
    border-right: 1px solid var(--a0-border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    overflow: hidden;
    transition: width var(--a0-transition), transform var(--a0-transition);
}

.a0-wrapper.closed .a0-sidebar-wrapper {
    width: var(--a0-sidebar-closed);
}

.a0-sidebar-sticky {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
    display: flex;
    flex-direction: column;
}
.a0-sidebar-sticky::-webkit-scrollbar { width: 6px; }
.a0-sidebar-sticky::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

/* Brand mini */
.a0-sidebar-brand {
    height: var(--a0-header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid var(--a0-border);
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}
.a0-brand-prompt {
    color: var(--a0-purple);
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}
.a0-brand-text {
    color: var(--a0-cyan);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
    transition: opacity 180ms ease;
}
.a0-wrapper.closed .a0-brand-text { opacity: 0; }

/* Toggle button row */
.a0-sidebar-toggle {
    border-bottom: 1px solid var(--a0-border);
    flex-shrink: 0;
}
.a0-sidebar-toggle a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: var(--a0-text-dim);
    transition: background 180ms ease, color 180ms ease;
    white-space: nowrap;
    overflow: hidden;
}
.a0-sidebar-toggle a:hover {
    background: rgba(139, 92, 246, 0.08);
    color: var(--a0-purple);
}

/* Hamburger / collapse icon (pure CSS) */
/* Hamburger / collapse icon: element = middle bar, ::before = top, ::after = bottom */
.a0-collapse-icon {
    display: inline-block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
    flex-shrink: 0;
    margin: 7px 0;
}
.a0-collapse-icon::before,
.a0-collapse-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 220ms ease, opacity 220ms ease;
}
.a0-collapse-icon::before { top: -6px; }
.a0-collapse-icon::after  { top: 6px; }
/* Closed state: top line rotates to arrow pointing right */
.a0-collapse-icon.is-closed::before { transform: translateY(3px) rotate(30deg) scaleX(0.7); }
.a0-collapse-icon.is-closed::after  { transform: translateY(-3px) rotate(-30deg) scaleX(0.7); }

.a0-sidebar-item-title {
    transition: opacity 180ms ease;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.a0-wrapper.closed .a0-sidebar-item-title { opacity: 0; }

/* Sidebar menu container */
.a0-sidebar-menu {
    flex: 1 1 auto;
    padding: 8px 0;
}

/* =========================================================
   Menu module styling (mod_a0menu items inside sidebar)
   ========================================================= */
.a0-menu-tree,
.a0-sidebar-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.a0-menu-item,
.a0-sidebar-menu li {
    margin: 0;
}
.a0-menu-link,
.a0-sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: var(--a0-text-dim);
    border-left: 2px solid transparent;
    transition: all 180ms ease;
    white-space: nowrap;
    overflow: hidden;
}
.a0-menu-link:hover,
.a0-sidebar-menu a:hover {
    background: rgba(139, 92, 246, 0.10);
    color: var(--a0-text);
    border-left-color: var(--a0-cyan);
}
.a0-menu-link.current,
.a0-menu-link.active,
.a0-sidebar-menu li.current > a,
.a0-sidebar-menu li.active  > a {
    background: rgba(139, 92, 246, 0.18);
    color: var(--a0-cyan);
    border-left-color: var(--a0-purple);
}
.a0-menu-icon {
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.a0-menu-text {
    transition: opacity 180ms ease;
}
.a0-wrapper.closed .a0-menu-text { opacity: 0; }

/* Children indentation */
.a0-menu-children .a0-menu-link {
    padding-left: 42px;
    font-size: 13px;
}
.a0-wrapper.closed .a0-menu-children { display: none; }

/* =========================================================
   Main container (right of sidebar)
   ========================================================= */
.a0-container-main {
    margin-left: var(--a0-sidebar-open);
    min-height: 100vh;
    transition: margin-left var(--a0-transition);
    display: flex;
    flex-direction: column;
}
.a0-wrapper.closed .a0-container-main {
    margin-left: var(--a0-sidebar-closed);
}

/* Site header */
.a0-site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--a0-header-h);
    background: var(--a0-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--a0-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
}
.a0-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 24px;
}
.a0-logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.a0-site-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--a0-cyan);
    letter-spacing: 1px;
    text-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}
.a0-subheading {
    margin: 0 0 0 12px;
    color: var(--a0-purple);
    font-size: 13px;
    font-style: italic;
    opacity: 0.85;
}
.a0-tagline {
    margin: 0 0 0 12px;
    color: var(--a0-text-dim);
    font-size: 12px;
}

/* Main nav (top header modules) */
.a0-main-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}
.a0-main-nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}
.a0-main-nav a {
    padding: 8px 14px;
    border-radius: 4px;
    color: var(--a0-text);
    transition: all 180ms ease;
    font-size: 13px;
}
.a0-main-nav a:hover {
    background: rgba(139, 92, 246, 0.15);
    color: var(--a0-cyan);
}

/* Banner */
.a0-banner-area {
    position: relative;
    padding: 40px 24px;
    overflow: hidden;
    border-bottom: 1px solid var(--a0-border);
}
.glow-orb {
    position: absolute;
    top: 50%;
    right: 10%;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--a0-purple) 0%, transparent 70%);
    filter: blur(30px);
    opacity: 0.4;
    transform: translateY(-50%);
    animation: pulseOrb 4s ease-in-out infinite;
    pointer-events: none;
}
@keyframes pulseOrb {
    0%, 100% { opacity: 0.3; transform: translateY(-50%) scale(1); }
    50%      { opacity: 0.55; transform: translateY(-50%) scale(1.1); }
}

/* Main content */
.a0-main-content {
    flex: 1 1 auto;
    padding: 32px;
    max-width: 100%;
}
.a0-main-content h1,
.a0-main-content h2,
.a0-main-content h3 {
    color: var(--a0-cyan);
    font-weight: 700;
    letter-spacing: 0.5px;
}
.a0-main-content article,
.a0-main-content .item-page {
    background: var(--a0-surface-2);
    border: 1px solid var(--a0-border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(8px);
}
.a0-main-content article:hover {
    border-color: var(--a0-border-hi);
}
/* Hide Joomla page heading in main content — menu already shows active page */
.a0-main-content .page-header {
    display: none;
}

/* Footer */
.a0-site-footer {
    border-top: 1px solid var(--a0-border);
    background: var(--a0-bg-2);
    padding: 20px 24px;
    color: var(--a0-text-dim);
    font-size: 12px;
}
.a0-site-footer .copyright {
    margin: 0;
    text-align: center;
}
.a0-site-footer .prompt {
    color: var(--a0-green);
}

/* =========================================================
   Mobile burger button (only visible on small screens)
   ========================================================= */
.a0-toggler-burger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border: 1px solid var(--a0-border);
    background: var(--a0-surface);
    border-radius: 6px;
    cursor: pointer;
    color: var(--a0-cyan);
    align-items: center;
    justify-content: center;
}
.a0-burger-icon {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    position: relative;
}
.a0-burger-icon::before,
.a0-burger-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    background: currentColor;
}
.a0-burger-icon::before { top: -7px; }
.a0-burger-icon::after  { top: 7px; }

/* Mobile overlay */
.a0-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--a0-transition);
}

/* =========================================================
   Responsive - Mobile-first improvements
   ========================================================= */

/* TABLETS & SMALL LAPTOPS (max-width: 768px) */
@media (max-width: 768px) {
    .a0-toggler-burger {
        display: flex;
        top: 8px;
        left: 8px;
        width: 48px;
        height: 48px;
        background: var(--a0-surface);
        border: 1px solid var(--a0-border-hi);
    }

    .a0-sidebar-wrapper {
        width: var(--a0-sidebar-open);
        transform: translateX(-100%);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.6);
    }
    .a0-wrapper.open .a0-sidebar-wrapper {
        transform: translateX(0);
    }

    .a0-container-main {
        margin-left: 0 !important;
        padding-top: 64px;
        width: 100vw;
        max-width: 100%;
        overflow-x: hidden;
    }

    .a0-wrapper.open .a0-mobile-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .a0-site-header {
        padding: 0 12px 0 56px;
        height: auto;
        min-height: var(--a0-header-h);
    }
    .a0-header-inner {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 0;
    }
    .a0-logo-area {
        flex-wrap: wrap;
        gap: 4px;
    }
    .a0-site-title {
        font-size: 18px;
        line-height: 1.2;
    }
    .a0-subheading {
        font-size: 12px;
        margin-left: 4px;
    }
    .a0-tagline {
        font-size: 11px;
        margin-left: 0;
        width: 100%;
    }

    .a0-main-nav {
        gap: 8px;
        flex-wrap: wrap;
    }
    .a0-main-nav a {
        padding: 6px 10px;
        font-size: 12px;
    }

    .a0-banner-area { padding: 24px 16px; }
    .glow-orb { width: 140px; height: 140px; opacity: 0.25; }

    .a0-main-content {
        padding: 16px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    .a0-main-content article,
    .a0-main-content .item-page {
        padding: 16px;
        border-radius: 6px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    .a0-main-content h1 { font-size: 20px; }
    .a0-main-content h2 { font-size: 17px; }
    .a0-main-content h3 { font-size: 15px; }

    .a0-site-footer { padding: 16px; font-size: 11px; }
}

/* PHONES (max-width: 480px) */
@media (max-width: 480px) {
    body.familyai-agentzero {
        font-size: 15px;
        line-height: 1.55;
    }

    .a0-toggler-burger {
        width: 44px;
        height: 44px;
        top: 6px;
        left: 6px;
    }

    .a0-container-main {
        padding-top: 56px;
    }

    .a0-site-header {
        padding: 0 10px 0 52px;
        min-height: 56px;
    }
    .a0-header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 6px 0;
    }
    .a0-logo-area {
        width: 100%;
        justify-content: flex-start;
    }
    .a0-site-title {
        font-size: 16px;
    }
    .a0-subheading {
        font-size: 11px;
        margin-left: 0;
        display: block;
        width: 100%;
    }
    .a0-tagline {
        display: none;
    }

    .a0-main-nav {
        width: 100%;
        justify-content: flex-start;
    }
    .a0-main-nav ul {
        flex-wrap: wrap;
        gap: 4px;
    }
    .a0-main-nav a {
        padding: 5px 8px;
        font-size: 12px;
    }

    .a0-banner-area { padding: 16px 12px; }
    .glow-orb { width: 100px; height: 100px; }

    .a0-main-content {
        padding: 12px;
    }
    .a0-main-content article,
    .a0-main-content .item-page {
        padding: 12px;
    }
    .a0-main-content h1 { font-size: 18px; }
    .a0-main-content h2 { font-size: 15px; }
    .a0-main-content h3 { font-size: 14px; }
    .a0-main-content p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Make all sidebar menu items larger for touch */
    .a0-menu-link,
    .a0-sidebar-menu a {
        padding: 14px 16px;
        font-size: 15px;
    }

    .a0-site-footer { padding: 12px; }
    .a0-site-footer .copyright { text-align: left; }
}

/* Extra large content safety: force-wrap long strings */
.a0-main-content pre,
.a0-main-content code,
.a0-main-content table,
.a0-main-content td,
.a0-main-content th {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Prevent Joomla default tables from breaking mobile */
.a0-main-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Touch-friendly links everywhere */
a, button {
    touch-action: manipulation;
}

/* Space Agent login link - top right header */
.a0-space-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.15));
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #f3f7ff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 200ms ease;
    white-space: nowrap;
}
.a0-space-link:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(6, 182, 212, 0.25));
    border-color: rgba(139, 92, 246, 0.6);
    color: #7ddcff;
    box-shadow: 0 0 20px rgba(125, 220, 255, 0.15);
}

/* Conditional login/register link in header (shown to guests) */
.a0-login-link {
    display: inline-flex;
    align-items: center;
    margin-left: 16px;
    padding: 6px 14px;
    border-radius: 6px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: #a78bfa;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 200ms ease;
    white-space: nowrap;
    vertical-align: middle;
}
.a0-login-link:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: rgba(139, 92, 246, 0.5);
    color: #c4b5fd;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

/* My Space link in sidebar for logged-in users */
.a0-space-wrap {
    margin-top: 16px;
    padding: 0 12px;
}
.a0-space-wrap .a0-space-link {
    display: flex;
    width: 100%;
    padding: 10px 16px;
    border-radius: 6px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.12));
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #7ddcff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 200ms ease;
    justify-content: center;
    text-align: center;
}
.a0-space-wrap .a0-space-link:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(6, 182, 212, 0.25));
    border-color: rgba(139, 92, 246, 0.6);
    color: #b7eaff;
    box-shadow: 0 0 20px rgba(125, 220, 255, 0.15);
}

/* Log out link in header nav for authenticated users */
.a0-logout-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 200ms ease;
    white-space: nowrap;
}
.a0-logout-link:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fecaca;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}
