/* =====================================================================
   AIPilot — global site styles
   Sonic-inspired futuristic dark theme with glassmorphism.
   ===================================================================== */

@import url("tokens.css");
@import url("components.css");

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

html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Deep space background with radial purple glow */
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(100, 40, 200, 0.18) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 50% 60% at 20% 80%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
        var(--bg-base);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-3) 0;
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--text-primary);
}
h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
    margin: 0 0 var(--space-4) 0;
    color: var(--text-secondary);
}

a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-base);
}
a:hover { color: var(--color-accent-200); }

img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

code, pre, kbd {
    font-family: var(--font-mono);
    font-size: 0.9em;
}
code {
    background: var(--bg-elevated);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: var(--space-6) 0;
}

::selection {
    background: var(--color-accent-700);
    color: white;
}

/* ==================== Layout primitives ==================== */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding-inline: var(--space-4);
}
.container-narrow {
    width: 100%;
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding-inline: var(--space-4);
}

@media (min-width: 768px) {
    .container,
    .container-narrow {
        padding-inline: var(--space-6);
    }
}

.main-content {
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    /* Top padding clears the oversized brand logo (120px tall, top:8px,
       header is 64px, so the logo bleeds ~64px below the header).
       --logo-overflow is set in tokens.css and shrinks on small viewports. */
    padding-block: calc(var(--logo-overflow, 72px) + var(--space-6)) var(--space-12);
}
/* The 120px brand logo is anchored to the viewport's left edge and bleeds
   below the header. Without this, pages whose content sits in the global
   .container start flush at the container's left edge — directly under the
   logo. Push the container's contents past the logo column so every page
   has the same left inset. --logo-gutter mirrors --logo-overflow's
   responsive breakpoints so this stays in sync. */
:root { --logo-gutter: 140px; }
@media (max-width: 760px) { :root { --logo-gutter: 110px; } }
@media (max-width: 520px) { :root { --logo-gutter: 0px; } }

.main-content > .container,
.main-content > .container-narrow,
.main-content > .container-fluid {
    padding-inline-start: max(var(--container-padding, 0.75rem), var(--logo-gutter));
}

/* ==================== Header / nav ==================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: var(--header-height);
    background: rgba(10, 10, 24, 0.75);
    backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
}

.app-header__inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
    text-decoration: none;
    letter-spacing: var(--letter-spacing-tight);
}
/* Brand mark sizing now lives in tokens.css (.app-brand__mark). */
.app-brand:hover { color: var(--text-primary); }

.app-nav {
    display: none;
    align-items: center;
    gap: var(--space-1);
}
.app-nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    white-space: nowrap;
}
.app-nav__link:hover {
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.1);
}
.app-nav__link.is-active {
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.15);
    box-shadow: inset 0 -2px 0 var(--color-accent-500);
}

.app-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
}
.nav-toggle:hover { background: var(--bg-elevated); }

/* Mobile sheet */
.mobile-sheet {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 24, 0.98);
    backdrop-filter: blur(20px);
    z-index: var(--z-modal);
    display: none;
    flex-direction: column;
}
.mobile-sheet.is-open { display: flex; }
.mobile-sheet__header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}
.mobile-sheet__nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.mobile-sheet__nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: background var(--transition-base);
}
.mobile-sheet__nav a:hover { background: rgba(124, 58, 237, 0.1); }

@media (min-width: 768px) {
    .app-nav { display: flex; }
    .nav-toggle { display: none; }
}

/* ==================== Footer ==================== */
.app-footer {
    border-top: 1px solid var(--border-subtle);
    background: rgba(10, 10, 24, 0.6);
    backdrop-filter: blur(8px);
    padding: var(--space-6) 0;
    margin-top: var(--space-12);
}
.app-footer__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}
.app-footer__inner a { color: var(--text-muted); }
.app-footer__inner a:hover { color: var(--text-secondary); }
.app-footer__status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

@media (min-width: 768px) {
    .app-footer__inner {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
}

/* ==================== Utility classes ==================== */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted) !important; }
.text-accent { color: var(--text-accent) !important; }

.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.hidden { display: none !important; }

@media (min-width: 768px) {
    .md\:hidden { display: none !important; }
    .md\:flex   { display: flex !important; }
    .md\:block  { display: block !important; }
}

/* ==================== Image grid ==================== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3);
}
@media (min-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: var(--space-4);
    }
}

.image-card-container {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    transition: all var(--transition-base);
}
.image-card-container:hover {
    border-color: var(--color-accent-500);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-sm);
}
.image-card-container img { width: 100%; height: auto; display: block; }

.image-trash-btn {
    position: absolute;
    bottom: var(--space-2);
    right: var(--space-2);
    z-index: 10;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    border: none;
    padding: 0;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    backdrop-filter: blur(4px);
}
.image-trash-btn:hover { background: var(--color-danger); box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }

/* ==================== Loading ==================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 18, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-overlay);
}
.loading-overlay.is-visible { display: flex; }

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--color-accent-400);
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

/* ==================== Gradient text helper ==================== */
.gradient-text {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.mm-hero {
margin:40px;
}