/* =============================================================================
   Gov-AIdeaS Custom Styles
   ---------
   NOTE: Tailwind CSS is loaded via CDN (<script src="https://cdn.tailwindcss.com">)
   which already provides all utility classes (flex, grid, text-*, p-*, m-*, etc.).
   This file only contains CUSTOM components, animations, and app-specific styles
   that Tailwind does NOT provide out of the box.
   ============================================================================= */


/* =============================================================================
   BASE OVERRIDES
   ============================================================================= */

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* =============================================================================
   COMPONENT: BUTTONS (extends Tailwind)
   ============================================================================= */

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background-color: var(--color-primary, #2563eb);
    color: white;
}
.btn-primary:hover { background-color: color-mix(in srgb, var(--color-primary, #2563eb), black 15%); }

.btn-secondary {
    background-color: var(--color-secondary, #16a34a);
    color: white;
}
.btn-secondary:hover { background-color: color-mix(in srgb, var(--color-secondary, #16a34a), black 15%); }

.btn-outline {
    background-color: transparent;
    color: var(--color-primary, #2563eb);
    border: 2px solid var(--color-primary, #2563eb);
}
.btn-outline:hover { background-color: #eff6ff; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.125rem; }

.btn-icon {
    width: 2.5rem; height: 2.5rem; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
}

.btn-danger { background-color: #dc2626; color: white; }
.btn-danger:hover { background-color: #b91c1c; }

.btn-warning { background-color: #f59e0b; color: white; }
.btn-warning:hover { background-color: #d97706; }

.btn-success { background-color: #10b981; color: white; }
.btn-success:hover { background-color: #059669; }

.btn-ghost { background-color: transparent; color: #4b5563; }
.btn-ghost:hover { background-color: #f3f4f6; }

.btn-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }


/* =============================================================================
   COMPONENT: CARDS
   ============================================================================= */

.card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }

.card-compact { padding: 1rem; }
.card-spacious { padding: 2rem; }

.card-interactive {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-interactive:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.card-interactive:active { transform: translateY(-2px); }

.card-featured {
    border: 2px solid #2563eb;
    position: relative;
    overflow: hidden;
}
.card-featured::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, #2563eb, #10b981);
}

.card-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.card-glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.card-optimized {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
}
.card-optimized:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}


/* =============================================================================
   COMPONENT: BADGES
   ============================================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-agriculture { background-color: #d1fae5; color: #065f46; }
.badge-health { background-color: #fee2e2; color: #991b1b; }
.badge-education { background-color: #dbeafe; color: #1e40af; }
.badge-environment { background-color: #d1fae5; color: #047857; }
.badge-economy { background-color: #fef3c7; color: #92400e; }
.badge-governance { background-color: #e9d5ff; color: #6b21a8; }
.badge-infrastructure { background-color: #e5e7eb; color: #1f2937; }
.badge-social { background-color: #fce7f3; color: #9f1239; }

.badge-count {
    min-width: 1.5rem; height: 1.5rem;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9999px; font-size: 0.75rem; font-weight: 600;
}

.badge-new { background-color: #ef4444; color: white; animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.badge-trending { background-color: #f59e0b; color: white; }
.badge-trending::before { content: '🔥 '; }
.badge-featured-badge { background: linear-gradient(90deg, #2563eb, #7c3aed); color: white; }

.badge-status-published { background-color: #d1fae5; color: #065f46; }
.badge-status-draft { background-color: #f3f4f6; color: #6b7280; }
.badge-status-review { background-color: #fef3c7; color: #92400e; }


/* =============================================================================
   COMPONENT: FORMS
   ============================================================================= */

.input,
.textarea,
.select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
}
.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}


/* =============================================================================
   COMPONENT: NAVIGATION
   ============================================================================= */

.navbar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 0;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: #4b5563;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-link:hover { color: var(--color-primary, #2563eb); }
.nav-link.active { color: var(--color-primary, #2563eb); border-bottom: 2px solid var(--color-primary, #2563eb); }


/* =============================================================================
   COMPONENT: CHAT WIDGET
   ============================================================================= */

.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.chat-button {
    width: 60px; height: 60px; border-radius: 50%;
    background-color: var(--color-primary, #2563eb); color: white; border: none;
    font-size: 1.5rem; cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}
.chat-button:hover { background-color: color-mix(in srgb, var(--color-primary, #2563eb), black 15%); transform: scale(1.05); }

.chat-window {
    width: 380px; height: 500px;
    background: white; border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    display: flex; flex-direction: column;
    margin-bottom: 1rem;
}

.chat-header {
    background-color: var(--color-primary, #2563eb); color: white;
    padding: 1rem; border-radius: 1rem 1rem 0 0;
    display: flex; justify-content: space-between; align-items: center;
}

.chat-messages {
    flex: 1; overflow-y: auto; padding: 1rem;
}

.chat-input-container {
    padding: 1rem; border-top: 1px solid #e5e7eb;
}

.message {
    margin-bottom: 1rem; padding: 0.75rem;
    border-radius: 0.5rem; max-width: 80%;
}
.message-user { background-color: var(--color-primary, #2563eb); color: white; margin-left: auto; }
.message-ai { background-color: #f3f4f6; color: #1f2937; }


/* =============================================================================
   LOADING & SKELETON STATES
   ============================================================================= */

.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid var(--color-primary, #2563eb);
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 1s linear infinite;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.375rem;
}
.skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton-text:last-child { width: 80%; }
.skeleton-text.large { height: 1.5rem; }
.skeleton-title { height: 2rem; width: 60%; margin-bottom: 1rem; }
.skeleton-card { height: 300px; width: 100%; }
.skeleton-circle { width: 3rem; height: 3rem; border-radius: 50%; }
.skeleton-avatar { width: 3rem; height: 3rem; border-radius: 50%; }
.skeleton-button { height: 2.5rem; width: 120px; }

.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.loading-dots { display: flex; gap: 0.5rem; }
.loading-dots span {
    width: 0.75rem; height: 0.75rem; border-radius: 50%;
    background: var(--color-primary, #2563eb);
    animation: bounce 1.4s infinite ease-in-out both;
}
.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

.loading-state {
    pointer-events: none; opacity: 0.6; position: relative;
}
.loading-state::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}


/* =============================================================================
   ANIMATIONS & KEYFRAMES
   ============================================================================= */

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in { animation: fade-in 0.5s ease-out; }
.animate-slide-in-left { animation: slide-in-left 0.5s ease-out; }
.animate-slide-in-right { animation: slide-in-right 0.5s ease-out; }


/* =============================================================================
   MICRO-INTERACTIONS
   ============================================================================= */

.hover-lift { transition: transform 0.2s ease; }
.hover-lift:hover { transform: translateY(-2px); }

.hover-scale { transition: transform 0.2s ease; }
.hover-scale:hover { transform: scale(1.05); }

.hover-glow { transition: box-shadow 0.3s ease; }
.hover-glow:hover { box-shadow: 0 0 20px rgba(37, 99, 235, 0.4); }

.click-ripple { position: relative; overflow: hidden; }
.click-ripple::after {
    content: '';
    position: absolute; top: 50%; left: 50%;
    width: 0; height: 0; border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}
.click-ripple:active::after { width: 300px; height: 300px; }


/* =============================================================================
   STICKY ELEMENTS
   ============================================================================= */

.sticky-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
    transition: all 0.3s ease;
}
.sticky-header.scrolled { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }


/* =============================================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================================= */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white; border-top: 1px solid #e5e7eb;
    padding: 0.5rem 0; display: none; z-index: 40;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}
.mobile-bottom-nav ul {
    display: flex; justify-content: space-around;
    align-items: center; list-style: none; margin: 0; padding: 0;
}
.mobile-bottom-nav-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.25rem; padding: 0.5rem; min-width: 48px;
    color: #6b7280; transition: color 0.2s;
}
.mobile-bottom-nav-item:hover,
.mobile-bottom-nav-item.active { color: var(--color-primary, #2563eb); }
.mobile-bottom-nav-item i { font-size: 1.25rem; }
.mobile-bottom-nav-item span { font-size: 0.75rem; font-weight: 500; }


/* =============================================================================
   IMPACT METRICS TICKER
   ============================================================================= */

.impact-ticker {
    background: linear-gradient(90deg, #1e40af 0%, #7c3aed 100%);
    color: white; padding: 1rem 0; overflow: hidden;
}
.ticker-content { display: flex; gap: 3rem; align-items: center; }
.ticker-item { display: flex; align-items: center; gap: 0.75rem; white-space: nowrap; }
.ticker-number { font-size: 1.5rem; font-weight: 700; }
.ticker-label { font-size: 0.875rem; opacity: 0.9; }


/* =============================================================================
   GRADIENT BACKGROUNDS
   ============================================================================= */

.bg-gradient-blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.bg-gradient-green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.bg-gradient-orange { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.bg-gradient-purple { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }


/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

/* Ensure all interactive elements have visible keyboard focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-primary, #2563eb);
    outline-offset: 2px;
    border-radius: 2px;
}

.skip-to-content {
    position: absolute; top: -40px; left: 0;
    background: var(--color-primary, #2563eb); color: white;
    padding: 0.5rem 1rem; z-index: 100;
    border-radius: 0 0 0.5rem 0;
}
.skip-to-content:focus { top: 0; }

.high-contrast { filter: contrast(1.2); }
.high-contrast .card { border: 2px solid #1f2937; }
.high-contrast a { text-decoration: underline; }

body.font-size-small { font-size: 14px; }
body.font-size-large { font-size: 18px; }
body.font-size-xlarge { font-size: 20px; }


/* =============================================================================
   IMAGE & LAZY LOADING
   ============================================================================= */

img[data-src],
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    min-height: 200px;
    object-fit: cover;
}
img.loading { opacity: 0.5; filter: blur(5px); }
img.loaded {
    animation: fadeIn 0.4s ease-in;
    opacity: 1; filter: blur(0);
    transition: opacity 0.4s, filter 0.4s;
}
img.error {
    background: #fee; border: 2px dashed #fca5a5;
    position: relative;
}

@supports (loading: lazy) {
    img[loading="lazy"] { background: transparent; animation: none; }
}

.img-container { position: relative; overflow: hidden; background: #f3f4f6; }
.img-container.aspect-video { aspect-ratio: 16 / 9; }
.img-container.aspect-square { aspect-ratio: 1 / 1; }
.img-container.aspect-portrait { aspect-ratio: 3 / 4; }
.img-container img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }


/* =============================================================================
   SCROLL & VISIBILITY PERFORMANCE
   ============================================================================= */

.auto-visibility { content-visibility: auto; contain-intrinsic-size: 500px; }
.will-animate { will-change: transform, opacity; }
.will-animate-complete { will-change: auto; }
.gpu-accelerated { transform: translateZ(0); backface-visibility: hidden; }

.fade-in-on-scroll {
    opacity: 0; transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.fade-in-on-scroll.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
    .fade-in-on-scroll { transition: none; opacity: 1; transform: none; }
}

.infinite-scroll-loader { transition: opacity 0.3s ease; }
.infinite-scroll-loader.hidden { opacity: 0; pointer-events: none; }

.defer-load { opacity: 0; transition: opacity 0.3s ease-in; }
.defer-load.loaded { opacity: 1; }

#page-loader { transition: opacity 0.3s ease-out; }
#page-loader.fade-out { opacity: 0; }


/* =============================================================================
   RESPONSIVE OVERRIDES (for custom components only)
   ============================================================================= */

@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 2rem);
        height: calc(100vh - 8rem);
    }
    .mobile-bottom-nav { display: block; }
    body.has-bottom-nav { padding-bottom: 4rem; }

    /* Larger touch targets on mobile */
    .btn,
    .nav-link,
    .mobile-bottom-nav-item {
        min-height: 44px;
        min-width: 44px;
    }
}

@media (min-width: 1024px) {
    .mobile-only { display: none !important; }
}


/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .no-print,
    .mobile-bottom-nav,
    .chat-widget,
    .navbar {
        display: none !important;
    }
    body { font-size: 12pt; color: #000; background: #fff; }
    .card { page-break-inside: avoid; border: 1px solid #000; }
}
