@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

/* Animated Gradient Background */
@keyframes gradient-x {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes gradient-y {
    0%, 100% {
        background-position: 50% 0%;
    }
    50% {
        background-position: 50% 100%;
    }
}

.animate-gradient-x {
    background-size: 200% 200%;
    animation: gradient-x 8s ease infinite;
}

.animate-gradient-y {
    background-size: 200% 200%;
    animation: gradient-y 8s ease infinite;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #a855f7, #ec4899);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #9333ea, #db2777);
}

/* RTL Transition Overlay */
#rtl-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #a855f7, #ec4899, #f97316);
    z-index: 9999;
    transform: translateX(-100%);
    pointer-events: none;
}

.rtl-animating-in {
    animation: slideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.rtl-animating-out {
    animation: slideOut 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideIn {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(0); }
}

@keyframes slideOut {
    0% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mesh Gradient Backgrounds */
.mesh-bg {
    background-color: #f8fafc;
    background-image: 
        radial-gradient(at 40% 20%, hsla(250,100%,94%,1) 0px, transparent 50%),
        radial-gradient(at 80% 0%, hsla(189,100%,96%,1) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(340,100%,96%,1) 0px, transparent 50%);
}

.mesh-bg-dark {
    background-color: #0f172a;
    background-image: 
        radial-gradient(at 40% 20%, hsla(243, 75%, 25%, 0.3) 0px, transparent 50%),
        radial-gradient(at 80% 0%, hsla(189, 87%, 20%, 0.3) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(263, 66%, 20%, 0.3) 0px, transparent 50%);
}

/* Blog mobile refinements */
.filters-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filters-scroll::-webkit-scrollbar {
    display: none;
}

.featured-card__img {
    transition: transform 0.5s ease;
}

.post-card__thumb {
    transition: transform 0.3s ease;
}

.post-card__img {
    transition: transform 0.3s ease;
}

@media (max-width: 640px) {
    body {
        padding-bottom: 2rem;
    }

    .featured-card__img {
        height: 260px;
    }

    .post-card {
        border-radius: 18px;
    }

    .post-card__thumb {
        height: 210px;
    }

    .post-card__body {
        padding: 1.25rem;
    }

    .filters-scroll {
        padding-bottom: 4px;
    }
}

/* 3D Tilted Effect for Hero Image */
.hero-tilt {
    transform: perspective(1000px) rotateY(-12deg) rotateX(2deg) rotateZ(-1deg);
    transition: transform 0.3s ease;
    box-shadow: 20px 20px 60px -10px rgba(0, 0, 0, 0.2);
}
.hero-tilt:hover {
    transform: perspective(1000px) rotateY(-8deg) rotateX(2deg) rotateZ(0deg);
}

/* RTL specific Mirrors */
html[dir="rtl"] .hero-tilt {
    transform: perspective(1000px) rotateY(12deg) rotateX(2deg) rotateZ(1deg);
}

/* Responsive Optimizations */
@media (max-width: 768px) {
    /* Adjust navbar stats for tablets */
    nav .hidden.md\\:flex {
        gap: 0.75rem;
    }
    
    /* Better spacing for mobile hero */
    .hero-tilt {
        transform: none;
        box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.2);
    }
    
    /* Optimize grid layouts */
    .grid.lg\\:grid-cols-2 {
        gap: 2rem;
    }
}

@media (max-width: 640px) {
    /* Mobile-specific adjustments */
    h1 {
        font-size: 2.25rem;
        line-height: 2.5rem;
    }
    
    h2 {
        font-size: 1.875rem;
        line-height: 2.25rem;
    }
    
    /* Mobile navbar adjustments */
    nav .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Better mobile stats */
    .mobile-stats {
        font-size: 0.875rem;
    }
}

/* Desktop enhancements */
@media (min-width: 1024px) {
    /* Enhance desktop navbar */
    nav {
        border-bottom-width: 1px;
    }
    
    /* Better hover states */
    .hover-lift {
        transition: transform 0.2s ease;
    }
    
    .hover-lift:hover {
        transform: translateY(-2px);
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }
}

/* Chart and graph animations */
@keyframes chartGrow {
    from {
        stroke-dashoffset: 100;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.chart-animate {
    animation: chartGrow 1.5s ease-out forwards;
}

/* Progress bar animations */
@keyframes progressFill {
    from {
        width: 0%;
    }
}

.progress-animate {
    animation: progressFill 1s ease-out forwards;
}

/* Loading skeleton for stats */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Mobile menu enhancements */
@media (max-width: 767px) {
    #mobile-menu {
        max-width: 90vw;
    }
    
    #mobile-menu-overlay {
        backdrop-filter: blur(4px);
    }
    
    /* Touch-friendly tap targets */
    button:not([type="submit"]),
    a:not(.block) {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Form submit buttons should remain block */
    button[type="submit"],
    a.block {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better mobile form inputs */
    input,
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    /* Mobile navigation improvements */
    nav {
        position: sticky;
        top: 0;
        z-index: 50;
    }
    
    /* Optimize mobile images */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Mobile typography */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    /* Mobile spacing */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Mobile cards */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Mobile grid adjustments */
    .grid {
        gap: 1rem;
    }
    
    /* Hide horizontal scroll */
    body {
        overflow-x: hidden;
    }
    
    /* Better mobile buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Mobile modal/drawer optimization */
    #mobile-menu {
        touch-action: pan-y;
        overscroll-behavior: contain;
    }
    
    /* Safe area insets for notched devices */
    @supports (padding: env(safe-area-inset-bottom)) {
        body {
            padding-bottom: env(safe-area-inset-bottom);
        }
        
        #mobile-menu {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }
    }
}

/* Dashboard Mobile Optimizations */
@media (max-width: 768px) {
    /* Fix main content padding on tablets and mobile */
    .dashboard-page #main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Ensure proper padding and spacing */
    .dashboard-page main > div {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Optimize KPI cards for mobile */
    .dashboard-page .glass-card {
        padding: 1.25rem !important;
    }
    
    /* Better hero section on mobile */
    .dashboard-page .dashboard-hero {
        padding: 1.5rem !important;
        border-radius: 1rem !important;
    }
    
    /* Improve action button layouts */
    .dashboard-page .dashboard-header-actions {
        width: 100%;
    }
    
    .dashboard-page .dashboard-header-actions button {
        flex: 1;
        min-width: 0;
    }
    
    /* Fix grid layouts on tablets */
    .dashboard-page .dashboard-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }
    
    /* Optimize charts on mobile */
    .dashboard-page .dashboard-chart {
        height: 240px !important;
        min-height: 240px;
    }
    
    /* Better table scrolling */
    .dashboard-page .dashboard-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better font sizes */
    .dashboard-page h1 {
        font-size: 1.5rem !important;
        line-height: 2rem !important;
    }
    
    .dashboard-page h2 {
        font-size: 1.25rem !important;
        line-height: 1.75rem !important;
    }
    
    .dashboard-page h3 {
        font-size: 1rem !important;
        line-height: 1.5rem !important;
    }
}

/* Extra small devices (phones under 480px) */
@media (max-width: 480px) {
    /* Single column layout for very small screens */
    .dashboard-page .dashboard-grid-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* Even tighter padding on small phones */
    .dashboard-page .glass-card {
        padding: 1rem !important;
        border-radius: 0.75rem !important;
    }
    
    .dashboard-page .dashboard-hero {
        padding: 1.25rem !important;
    }
    
    /* Stack action buttons */
    .dashboard-page .dashboard-header-actions {
        flex-direction: column;
    }
    
    .dashboard-page .dashboard-header-actions button {
        width: 100%;
        justify-content: center;
    }
    
    /* Smaller KPI metrics */
    .dashboard-page .glass-card p:first-of-type {
        font-size: 1.5rem !important;
    }
    
    /* Better mobile navigation */
    .dashboard-page main > div {
        padding-left: 1rem;
        padding-right: 1rem;
        gap: 1rem !important;
    }
}

/* Medium devices optimization (tablets 768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Optimize for tablets */
    .dashboard-page .glass-card {
        padding: 1.25rem !important;
    }
    
    /* Better grid spacing on tablets */
    .dashboard-page .dashboard-grid-4 {
        gap: 1rem;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support for stats */
@media (prefers-color-scheme: dark) {
    .auto-dark-stats {
        background: rgba(15, 23, 42, 0.8);
        color: #f1f5f9;
    }
}

/* Advanced Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.8);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rotate360 {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Animation Utility Classes */
.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.6s ease-out forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.6s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease-out forwards;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

.animate-slide-up {
    animation: slideInUp 0.8s ease-out forwards;
}

.animate-rotate {
    animation: rotate360 20s linear infinite;
}

/* Stagger Delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-700 { animation-delay: 0.7s; }
.delay-1000 { animation-delay: 1s; }

/* Scroll Reveal Animations */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
    transition: box-shadow 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

/* Gradient Text Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-text-animated {
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899, #f43f5e);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

/* Card Reveal Animation */
.card-reveal {
    position: relative;
    overflow: hidden;
}

.card-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.card-reveal:hover::before {
    left: 100%;
}

/* Loading Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: rotate360 1s linear infinite;
}

/* Ripple Effect */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s ease-out;
}

/* Parallax Effect */
.parallax {
    transition: transform 0.3s ease-out;
}

/* Smooth Transitions */
.transition-all-smooth {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Background Patterns */
.pattern-dots {
    background-image: radial-gradient(circle, #e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}

.pattern-grid {
    background-image: 
        linear-gradient(#e2e8f0 1px, transparent 1px),
        linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
    background-size: 30px 30px;
}

/* Edge network graph styling */
.network-path {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 10 12;
    opacity: 0.9;
    animation: networkFlow 12s linear infinite;
}

.network-path--fast {
    animation-duration: 10s;
    stroke-dasharray: 8 10;
    opacity: 0.75;
}

.network-path--ghost {
    animation-duration: 14s;
    stroke-dasharray: 6 12;
    opacity: 0.55;
}

.network-node {
    filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.6));
}

.network-node--primary {
    fill: #22d3ee;
}

.network-node--secondary {
    fill: #a855f7;
    filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.6));
}

.network-node-ring {
    fill: none;
    stroke: rgba(34, 211, 238, 0.38);
    stroke-width: 8;
    animation: networkPulse 2.6s ease-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

.network-node-ring--secondary {
    stroke: rgba(168, 85, 247, 0.35);
    animation-delay: 0.6s;
}

@keyframes networkFlow {
    from {
        stroke-dashoffset: 160;
    }
    to {
        stroke-dashoffset: -720;
    }
}

@keyframes networkPulse {
    0% {
        transform: scale(0.65);
        opacity: 0.75;
    }
    70% {
        transform: scale(1.35);
        opacity: 0;
    }
    100% {
        transform: scale(1.45);
        opacity: 0;
    }
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 640px) {
    .animate-fade-in-up,
    .animate-fade-in-down,
    .animate-fade-in-left,
    .animate-fade-in-right {
        animation-duration: 0.4s;
    }
    
    .hover-lift:active {
        transform: translateY(-4px);
    }
}

/* Performance Optimization */
@media (prefers-reduced-motion: reduce) {
    .animate-fade-in-up,
    .animate-fade-in-down,
    .animate-fade-in-left,
    .animate-fade-in-right,
    .animate-scale-in,
    .animate-float,
    .animate-pulse-glow,
    .animate-slide-up,
    .animate-rotate,
    .scroll-reveal,
    .gradient-text-animated {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}
