/* 
  FlowBrief - Design System & Global Styles
  Tone: Calm, Minimal, Focused, Clear 
*/

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&display=swap');

:root {
    /* Colors */
    --bg-main: #FFFFFF;
    --bg-surface: #F8FAFC;
    --bg-surface-hover: #F1F5F9;
    --bg-surface-elevated: #FFFFFF;

    --accent-base: #2563EB;
    --accent-hover: #1D4ED8;
    --accent-subtle: rgba(37, 99, 235, 0.1);

    --positive-base: #16A34A;
    --positive-subtle: rgba(22, 163, 74, 0.1);

    --negative-base: #DC2626;
    --negative-subtle: rgba(220, 38, 38, 0.1);

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-hover: rgba(0, 0, 0, 0.15);

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;

    /* Layout */
    --max-width: 1100px;
    --max-width-narrow: 800px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modern Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Typography elements */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    /* SemiBold */
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
}

h2 {
    font-size: clamp(2rem, 4vw, 3rem);
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.25rem;
}

p {
    color: var(--text-secondary);
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-base);
}

/* Data / Mono text */
.mono {
    font-family: var(--font-mono);
    font-size: 0.875em;
    letter-spacing: -0.01em;
}

/* Layout Utilities */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.container-narrow {
    max-width: var(--max-width-narrow);
}

.section {
    padding: 6rem 0;
    position: relative;
}

.underline-premium {
    position: relative;
    display: inline-block;
}

.underline-premium::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 0;
    width: 100%;
    height: 8px;
    background: var(--accent-subtle);
    z-index: -1;
    transform: skewX(-15deg);
}

/* Typography Utilities */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-base {
    font-size: 1rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* Morning Ritual & Comparison Grids */
.morning-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 2.5rem;
    align-items: stretch;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 992px) {
    .morning-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 580px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.gap-8 {
    gap: 2rem;
}

.gap-12 {
    gap: 3rem;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-8 {
    margin-top: 2rem;
}

.mt-12 {
    margin-top: 3rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mb-12 {
    margin-bottom: 3rem;
}

/* Components */
.surface {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.surface:hover {
    border-color: var(--border-color-hover);
}

.surface-elevated {
    background-color: var(--bg-surface-elevated);
    box-shadow: 0 4px 24px -4px rgba(0, 0, 0, 0.08);
}

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    font-size: 0.9375rem;
}

.btn-primary {
    background-color: var(--accent-base);
    color: #FFFFFF;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-color-hover);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Navigation */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1rem 0;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.navbar.scrolled {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.logo-icon {
    color: var(--accent-base);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

/* Tags / Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-outline {
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.badge-blue {
    background-color: var(--accent-subtle);
    color: var(--accent-base);
}

.badge-green {
    background-color: var(--positive-subtle);
    color: var(--positive-base);
}

.badge-red {
    background-color: var(--negative-subtle);
    color: var(--negative-base);
}

/* Decorative Elements */
.glow-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
    top: -300px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: -1;
}

@media (max-width: 768px) {
    .glow-bg {
        display: none;
    }
}

/* Section Specifics */
.hero-section {
    padding: 8rem 0 6rem;
    text-align: center;
    max-width: 860px;
    margin: 0 auto;
}

.feature-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.feature-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent-subtle);
    color: var(--accent-base);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Form Elements */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.input,
.custom-select {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast);
    outline: none;
}

select.input,
.custom-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    cursor: pointer;
}

.input:focus,
.custom-select:focus {
    border-color: var(--accent-base);
}

/* Utilities */
.text-accent {
    color: var(--accent-base);
}

.text-positive {
    color: var(--positive-base);
}

.text-negative {
    color: var(--negative-base);
}

.text-white {
    color: #FFFFFF;
}

.hidden {
    display: none !important;
}

/* Flows Grid */
.flows-content-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--bg-surface-elevated);
        flex-direction: column;
        padding: 1.5rem;
        gap: 1.5rem;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-actions {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    /* Better tap targets on mobile */
    .container {
        padding: 0 1.5rem;
    }

    .theme-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .theme-header>.flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }

    .source-avatars {
        margin-top: 0.25rem;
    }

    .btn,
    .sidebar-link,
    .nav-link,
    .source-chip,
    .flow-card {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevent iOS zoom */
    }
}

/* Footer */
footer {
    border-top: 1px solid var(--border-color);
    padding: 4rem 0 2rem;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 3rem;
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

.footer-link {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.footer-link:hover {
    color: var(--text-primary);
}

/* App Layout (Dashboard, Settings, Sources) */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-sidebar {
    width: 260px;
    background-color: var(--bg-surface-elevated);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 40;
}

.app-content {
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: 0.9375rem;
    font-weight: 500;
}

.sidebar-link:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background-color: var(--accent-subtle);
    color: var(--accent-base);
}

.sidebar-link i {
    width: 18px;
    height: 18px;
}

/* Accordion Layout */
.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    background: var(--bg-surface);
    overflow: hidden;
}

.accordion-trigger {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
}

.accordion-trigger:hover {
    background-color: var(--bg-surface-hover);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: var(--bg-main);
}

.accordion-body {
    padding: 1rem 1.5rem 1.5rem;
}

/* Dashboard Specific Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        transform: translateX(-100%);
        z-index: 100;
        transition: transform var(--transition-normal);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-topbar {
        padding: 0 1rem;
    }

    .app-content {
        padding: 1rem;
    }
}

/* Pricing Toggle */
.pricing-toggle {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.25rem;
    margin-bottom: 3rem;
    position: relative;
    cursor: pointer;
}

.toggle-option {
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    z-index: 2;
    position: relative;
}

.toggle-option.active {
    color: var(--text-primary);
}

.toggle-slider {
    position: absolute;
    top: 0.25rem;
    bottom: 0.25rem;
    left: 0.25rem;
    width: calc(50% - 0.25rem);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
}

.pricing-toggle[data-active="yearly"] .toggle-slider {
    transform: translateX(100%);
}

/* ── Mobile Activity Dot ── */
.activity-dot {
    display: inline-block;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ══════════════════════════════════════
   MOBILE — Additional Responsive Fixes
   ══════════════════════════════════════ */

/* Reduce section padding on mobile */
@media (max-width: 768px) {
    .section {
        padding: 3.5rem 0;
    }

    /* Container padding tighter on small screens */
    .container {
        padding: 0 1rem;
    }

    /* Nav actions visible on mobile — show Demo link only */
    .nav-actions .btn-primary {
        display: none;
    }

    .nav-actions {
        display: flex;
    }

    /* Hero buttons stack */
    .hero-content .flex {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-content .btn {
        text-align: center;
        justify-content: center;
    }

    /* About page 2-col grid */
    .grid.grid-cols-2 {
        grid-template-columns: 1fr;
    }

    /* Announcement bar wraps cleanly */
    .announcement-bar {
        font-size: 0.75rem;
    }

    /* App pages: sidebar toggle button visible */
    #mobile-sidebar-toggle {
        display: flex !important;
    }

    /* Waitlist email+button stacks */
    #waitlist .flex.gap-3 {
        flex-direction: column;
    }

    #waitlist input {
        width: 100%;
    }

    /* Source grid in problem section */
    .source-grid {
        gap: 0.5rem;
    }

    /* Usecase sections */
    .usecase-content {
        grid-template-columns: 1fr !important;
    }
}

/* Flows & Manage: collapse inline fixed grids */
@media (max-width: 768px) {

    /* flows.html: 320px 1fr → 1fr */
    .flows-content-grid {
        grid-template-columns: 1fr !important;
    }

    /* past-brief-detail contrasting grid */
    .contrast-grid {
        grid-template-columns: 1fr !important;
    }

    /* brief-meta bar wraps */
    .brief-meta {
        gap: 0.5rem;
    }

    .brief-meta>span,
    .brief-meta>div {
        font-size: 0.75rem;
    }

    /* Contact page: split stacks */
    .contact-split {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        padding: 3rem 1rem !important;
    }

    .contact-left {
        position: static !important;
    }

    .contact-headline {
        font-size: 2rem !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Settings / Sources: fix manage grid */
    .manage-layout {
        grid-template-columns: 1fr !important;
    }

    /* App topbar: limit height */
    .app-topbar {
        height: auto;
        min-height: 60px;
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* App content full width */
    .app-content {
        padding: 1rem;
        max-width: 100%;
    }

    /* Flows detail panel */
    .flow-detail-panel {
        border-radius: var(--radius-md);
    }

    /* Dashboard grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Onboarding steps */
    .onboarding-grid {
        grid-template-columns: 1fr !important;
    }

    /* Past briefs list */
    .past-briefs-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Extra-small screens (<480px) */
@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.625rem;
    }

    h3 {
        font-size: 1.375rem;
    }

    .section {
        padding: 2.5rem 0;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.625rem 1.125rem;
    }

    /* source tag pill size */
    .source-tag {
        font-size: 0.8125rem !important;
    }

    /* Brief meta on tiny screens: vertical stack */
    .brief-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    /* Hide separator dots on tiny screens */
    .brief-meta>span:not(:last-child) {
        display: none;
    }

    /* App topbar on very small screens */
    .app-topbar {
        height: auto;
        flex-wrap: wrap;
    }
}

/* Error Shake Animation */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}