/* =========================================
   InsightFlow Design System (Vanilla CSS with Utility Helpers)
   ========================================= */

:root {
    /* Colors */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --indigo-50: #eef2ff;
    --indigo-100: #e0e7ff;
    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;
    --indigo-700: #4338ca;

    --purple-500: #a855f7;
    --purple-600: #9333ea;

    --blue-600: #2563eb;

    --white: #ffffff;
    --black: #000000;

    /* Semantic */
    --primary: var(--indigo-600);
    --bg-body: var(--white);
    --text-main: var(--slate-900);
    --text-muted: var(--slate-500);

    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Dashboard Specific Colors (Legacy Support) */
    --bg-surface: var(--white);
    --border: var(--slate-200);
    --text-muted: var(--slate-500);
    --primary: var(--indigo-600);
    --primary-light: var(--indigo-50);
    --success: var(--green-500);
    --warning: var(--orange-500);
    --danger: var(--red-500);
}

[data-theme="dark"] {
    --bg-body: var(--slate-900);
    --bg-surface: var(--slate-800);
    --text-main: var(--slate-100);
    --text-muted: var(--slate-400);
    --border: var(--slate-700);

    --slate-50: var(--slate-900);
    --slate-100: var(--slate-800);
    --slate-200: var(--slate-700);

    --white: var(--slate-900);
    /* Invert white for dark mode surface mapping if needed */

    /* Specific overrides */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);

    /* Ensure dashboard specific variables map correctly */
    --primary-light: rgba(99, 102, 241, 0.1);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    margin: 0;
    line-height: 1.2;
}

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

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

/* =========================================
   Utility Classes (Tailwind-Lite) 
   ========================================= */

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.fixed {
    position: fixed;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.z-0 {
    z-index: 0;
}

.z-10 {
    z-index: 10;
}

.z-40 {
    z-index: 40;
}

.z-50 {
    z-index: 50;
}

.overflow-hidden {
    overflow: hidden;
}

/* Flexbox & Grid */
.flex {
    display: flex;
}

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

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

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

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

.justify-end {
    justify-content: flex-end;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.gap-8 {
    gap: 2rem;
}

.gap-12 {
    gap: 3rem;
}

.gap-16 {
    gap: 4rem;
}

.grid {
    display: grid;
}

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

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

/* Spacing */
.p-2 {
    padding: 0.5rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.p-8 {
    padding: 2rem;
}

.p-10 {
    padding: 2.5rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.px-5 {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

.px-6 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.px-8 {
    padding-left: 2rem;
    padding-right: 2rem;
}

.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.py-20 {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

.py-24 {
    padding-top: 6rem;
    padding-bottom: 6rem;
}

.pt-20 {
    padding-top: 5rem;
}

.pt-32 {
    padding-top: 8rem;
}

.pb-10 {
    padding-bottom: 2.5rem;
}

.pb-20 {
    padding-bottom: 5rem;
}

.m-0 {
    margin: 0;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.my-4 {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

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

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

.mb-6 {
    margin-bottom: 1.5rem;
}

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

.mb-10 {
    margin-bottom: 2.5rem;
}

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

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

.mb-20 {
    margin-bottom: 5rem;
}

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

.mt-6 {
    margin-top: 1.5rem;
}

.mt-20 {
    margin-top: 5rem;
}

.mt-24 {
    margin-top: 6rem;
}

/* Sizing */
.w-full {
    width: 100%;
}

.w-px {
    width: 1px;
}

.h-full {
    height: 100%;
}

.h-px {
    height: 1px;
}

.h-10 {
    height: 2.5rem;
}

.w-12 {
    width: 3rem;
}

.h-12 {
    height: 3rem;
}

.w-14 {
    width: 3.5rem;
}

.h-14 {
    height: 3.5rem;
}

.w-24 {
    width: 6rem;
}

.h-24 {
    height: 6rem;
}

.max-w-xs {
    max-width: 20rem;
}

.max-w-md {
    max-width: 28rem;
}

.max-w-2xl {
    max-width: 42rem;
}

.max-w-3xl {
    max-width: 48rem;
}

.max-w-5xl {
    max-width: 64rem;
}

.max-w-6xl {
    max-width: 72rem;
}

/* Typography */
.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;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-3xl {
    font-size: 1.875rem;
}

.text-4xl {
    font-size: 2.25rem;
}

.text-5xl {
    font-size: 3rem;
}

.text-7xl {
    font-size: 4.5rem;
}

.font-light {
    font-weight: 300;
}

.font-normal {
    font-weight: 400;
}

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

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

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

.font-mono {
    font-family: monospace;
}

.font-display {
    font-family: var(--font-heading);
}

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

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

.tracking-tight {
    letter-spacing: -0.025em;
}

.tracking-wider {
    letter-spacing: 0.05em;
}

.uppercase {
    text-transform: uppercase;
}

.leading-relaxed {
    line-height: 1.625;
}

/* Colors */
.text-white {
    color: var(--white);
}

.text-slate-300 {
    color: var(--slate-300);
}

.text-slate-400 {
    color: var(--slate-400);
}

.text-slate-500 {
    color: var(--slate-500);
}

.text-slate-600 {
    color: var(--slate-600);
}

.text-slate-700 {
    color: var(--slate-700);
}

.text-slate-800 {
    color: var(--slate-800);
}

.text-slate-900 {
    color: var(--slate-900);
}

.text-indigo-600 {
    color: var(--indigo-600);
}

.text-indigo-100 {
    color: var(--indigo-100);
}

.bg-white {
    background-color: var(--white);
}

.bg-slate-50 {
    background-color: var(--slate-50);
}

.bg-slate-100 {
    background-color: var(--slate-100);
}

.bg-slate-800 {
    background-color: var(--slate-800);
}

.bg-slate-900 {
    background-color: var(--slate-900);
}

.bg-indigo-600 {
    background-color: var(--indigo-600);
}

.bg-indigo-100 {
    background-color: var(--indigo-100);
}

/* Borders & Rounded */
.border {
    border: 1px solid;
}

.border-b {
    border-bottom: 1px solid;
}

.border-t {
    border-top: 1px solid;
}

.border-slate-100 {
    border-color: var(--slate-100);
}

.border-slate-200 {
    border-color: var(--slate-200);
}

.border-slate-700 {
    border-color: var(--slate-700);
}

.border-slate-800 {
    border-color: var(--slate-800);
}

.border-indigo-100 {
    border-color: var(--indigo-100);
}

.rounded-md {
    border-radius: 0.375rem;
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-2xl {
    border-radius: 1rem;
}

.rounded-full {
    border-radius: 9999px;
}

/* Effects */
.shadow-sm {
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.shadow-md {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.shadow-lg {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.shadow-xl {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.opacity-0 {
    opacity: 0;
}

.opacity-100 {
    opacity: 1;
}

.backdrop-blur-md {
    backdrop-filter: blur(12px);
}

/* Common Hover */
.hover\:bg-slate-50:hover {
    background-color: var(--slate-50);
}

.hover\:text-indigo-600:hover {
    color: var(--indigo-600);
}

.hover\:shadow-xl:hover {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.hover\:-translate-y-1:hover {
    transform: translateY(-0.25rem);
}

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 300ms;
}

.duration-300 {
    transition-duration: 300ms;
}

.duration-500 {
    transition-duration: 500ms;
}

.duration-700 {
    transition-duration: 700ms;
}

/* =========================================
   Custom Components 
   ========================================= */

/* Hero Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--purple-600) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Gradient Button */
.btn-gradient {
    background: linear-gradient(135deg, var(--indigo-600) 0%, var(--purple-600) 100%);
    position: relative;
    overflow: hidden;
}

.btn-gradient::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-gradient:hover::after {
    opacity: 1;
}

/* Browser Mockup Perspective */
.perspective-1000 {
    perspective: 1000px;
}

.rotate-x-3 {
    transform: rotateX(3deg);
}

.rotate-x-0 {
    transform: rotateX(0deg);
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeUp 0.8s ease-out forwards;
    opacity: 0;
}

.delay-100 {
    animation-delay: 100ms;
}

.delay-200 {
    animation-delay: 200ms;
}

.delay-300 {
    animation-delay: 300ms;
}

.delay-400 {
    animation-delay: 400ms;
}

.delay-500 {
    animation-delay: 500ms;
}

/* Floating Cards Animation */
@keyframes float {

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

    50% {
        transform: translateY(-10px);
    }
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

.sticky-filters {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

[data-theme="dark"] .sticky-filters {
    background: rgba(15, 23, 42, 0.9);
}

.chart-container-responsive {
    position: relative;
    height: 350px;
    width: 100%;
}

.heatmap-cell {
    transition: all 0.2s ease;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

@keyframes pulse-green {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}

.animate-pulse-green {
    animation: pulse-green 2s infinite;
}

@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease-out forwards;
}

@keyframes check-scale {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-check {
    animation: check-scale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

.animate-marquee {
    animation: marquee 30s linear infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

/* Visibility */
.hidden {
    display: none;
}

@media (min-width: 768px) {
    .md\:block {
        display: block;
    }

    .md\:hidden {
        display: none;
    }

    .md\:flex {
        display: flex;
    }

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

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

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

    .md\:text-5xl {
        font-size: 3rem;
    }

    .md\:text-7xl {
        font-size: 4.5rem;
    }

    .md\:p-10 {
        padding: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-5 {
        grid-template-columns: repeat(5, 1fr);
    }

    .lg\:col-span-2 {
        grid-column: span 2 / span 2;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .hero-section {
        padding-top: 6rem;
    }

    .text-5xl {
        font-size: 2.5rem;
    }
}

/* Misc Helpers */
.shrink-0 {
    flex-shrink: 0;
}

.group:hover .group-hover\:text-indigo-600 {
    color: var(--indigo-600);
}

.group:hover .group-hover\:scale-110 {
    transform: scale(1.1);
}

.group:hover .group-hover\:shadow-xl {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.transition-transform {
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 300ms;
}

/* Dashboard Mockup Fallback if img fails */
/* Dashboard Layout & App Styles */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--slate-50);
}

[data-theme="dark"] .app-layout {
    background-color: #0f172a;
    /* Slate 900 */
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 50;
    transition: transform 0.3s ease-in-out;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2rem;
    text-decoration: none;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar-item:hover,
.sidebar-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.sidebar-item i {
    width: 20px;
    height: 20px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    /* Sidebar width */
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.mobile-menu-btn {
    display: none;
    /* Hidden on desktop */
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
}

/* Responsive Dashboard */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block;
        margin-right: 1rem;
    }
}

/* Dashboard Cards & Grid */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

/* --- Dashboard Specifics --- */
.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.metric-icon-bg {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.metric-sparkline {
    height: 40px;
    width: 100%;
    margin-top: 1rem;
    opacity: 0.5;
}

.sticky-filters {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

[data-theme="dark"] .sticky-filters {
    background: rgba(15, 23, 42, 0.95);
}

.activity-feed-item {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 1.5rem;
    border-left: 2px solid var(--border);
}

.activity-feed-item:last-child {
    border-left-color: transparent;
}

.activity-icon-point {
    position: absolute;
    left: -9px;
    top: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--primary);
}

/* Modal Enhancements */
.modal-overlay {
    backdrop-filter: blur(4px);
}

.modal-content {
    animation: modalSlideUp 0.3s ease-out forwards;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.top-banner {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    transition: transform 0.3s ease;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.trend-up {
    color: #10b981;
}

.trend-down {
    color: #ef4444;
}

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

.chart-card,
.transactions-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    height: 100%;
}

.transactions-table {
    width: 100%;
    border-collapse: collapse;
}

.transactions-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
}

.transactions-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.875rem;
}

.status {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status.paid {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status.pending {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.status.refunded {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* AI Insight Box */
.ai-insight {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(147, 51, 234, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.ai-icon {
    width: 40px;
    height: 40px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--indigo-600);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}