"use client";

import Link from "next/link";
import { ReactNode, useMemo, useState } from "react";
import { useLanguage } from "@/contexts/LanguageContext";
import {
  isIndexableArticleSlug,
  TYPE_COLORS,
  TYPE_LABELS,
} from "@/data/resources-articles";
import type { ArticleType } from "@/data/resources-articles";
import { CONTENT } from "@/data/resources-content";

type ResourceFilter = "all" | ArticleType;

const FILTER_ORDER: ResourceFilter[] = [
  "all",
  "guide",
  "playbook",
  "template",
];

const TYPE_ICONS: Record<string, ReactNode> = {
  guide: (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
      <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  ),
  playbook: (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
      <path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2" strokeLinecap="round" strokeLinejoin="round" />
      <rect x="9" y="3" width="6" height="4" rx="1" />
      <path d="M9 12h6M9 16h4" strokeLinecap="round" />
    </svg>
  ),
  comparison: (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
      <path d="M16 3h5v5M4 20L21 3M21 16v5h-5M15 15l6 6M4 4l5 5" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  ),
  template: (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
      <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M14 2v6h6M16 13H8M16 17H8M10 9H8" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  ),
};

export default function ResourcesArea() {
  const { language } = useLanguage();
  const lang = language === "ar" ? "ar" : "en";
  const langLink = (path: string) => path.startsWith("http") ? path : `/${lang}${path === "/" ? "" : path}`;
  const content = CONTENT[lang];
  const isArabic = lang === "ar";
  const [activeFilter, setActiveFilter] = useState<ResourceFilter>("all");
  const visibleCards = useMemo(
    () => content.cards.filter((card) => isIndexableArticleSlug(card.articleId)),
    [content.cards],
  );

  const filteredCards = useMemo(() => {
    if (activeFilter === "all") return visibleCards;
    return visibleCards.filter((card) => card.type === activeFilter);
  }, [activeFilter, visibleCards]);

  const q = encodeURIComponent(content.askAiPrompt);
  const aiLinks = [
    {
      name: "ChatGPT",
      href: `https://chatgpt.com/?q=${q}`,
      bg: "#000000",
      svg: (
        <svg viewBox="0 0 24 24" className="ai-svg-icon" aria-hidden="true">
          <path fill="#fff" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.5023-2.6067-1.5023Z" />
        </svg>
      ),
    },
    {
      name: "Claude",
      href: `https://claude.ai/new?q=${q}`,
      bg: "#F0EEE5",
      svg: (
        <svg viewBox="0 0 24 24" className="ai-svg-icon" aria-hidden="true">
          <path fill="#D97757" d="M4.709 15.955l4.72-2.647.079-.23-.079-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.146-.103.018-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.352-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.279-.607-.461-.322-.747.322-1.476.389-1.924.316-1.53.286-1.9.17-.631-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.413.164-.717-.37.067-.66.401-.589 2.388-3.036 1.44-1.882.93-1.087-.006-.158h-.055l-6.34 4.116-1.129.146-.486-.456.06-.746.231-.243 1.908-1.312-.006.005Z" />
        </svg>
      ),
    },
    {
      name: "Perplexity",
      href: `https://www.perplexity.ai/?q=${q}`,
      bg: "#0F1A1F",
      svg: (
        <svg viewBox="0 0 24 24" className="ai-svg-icon" aria-hidden="true">
          <path fill="#20B8CD" d="M22.3977 7.0896h-2.3106V.0676l-7.5094 6.3542V.1577h-1.1554v6.1966L4.4904 0v7.0896H1.6023v10.3976h2.8882V24l6.932-6.3591v6.2005h1.1554v-6.0469l6.9318 6.1807v-6.4879h2.8882V7.0896zm-3.4657-4.531v4.531h-5.355l5.355-4.531zm-13.2862.0676 4.8691 4.4634H5.6458V2.6262zM2.7576 16.332V8.245h7.8476l-6.1149 6.1147v1.9723H2.7576zm2.8882 5.0404v-3.8852h.0001v-2.6488l5.7763-5.7764v7.0111l-5.7764 5.2993zm12.7086.0248-5.7766-5.1509V9.0618l5.7766 5.7766v6.5588zm2.8882-5.0652h-1.733v-1.9723L13.3948 8.245h7.8478v8.087z" />
        </svg>
      ),
    },
    {
      name: "Gemini",
      href: `https://gemini.google.com/app?q=${q}`,
      bg: "#FFFFFF",
      svg: (
        <svg viewBox="0 0 24 24" className="ai-svg-icon" aria-hidden="true">
          <defs>
            <linearGradient id="gem-grad" x1="0" y1="0" x2="24" y2="24" gradientUnits="userSpaceOnUse">
              <stop offset="0" stopColor="#4285F4" />
              <stop offset="0.5" stopColor="#9B72F2" />
              <stop offset="1" stopColor="#D96570" />
            </linearGradient>
          </defs>
          <path fill="url(#gem-grad)" d="M12 24A14.304 14.304 0 0 0 0 12 14.304 14.304 0 0 0 12 0a14.305 14.305 0 0 0 12 12 14.305 14.305 0 0 0-12 12" />
        </svg>
      ),
    },
    {
      name: "Grok",
      href: `https://grok.com/?q=${q}`,
      bg: "#000000",
      svg: (
        <svg viewBox="0 0 34 33" className="ai-svg-icon" aria-hidden="true">
          <path fill="#fff" d="M13.2371 21.0407L24.3186 12.8506C24.8619 12.4491 25.6384 12.6057 25.8973 13.2294C27.2597 16.5185 26.651 20.4712 23.9403 23.1851C21.2297 25.8989 17.4581 26.4941 14.0108 25.1386L10.2449 26.8843C15.6463 30.5806 22.2053 29.6665 26.304 25.5601C29.5551 22.3051 30.562 17.8683 29.6205 13.8673L29.629 13.8758C28.2637 7.99809 29.9647 5.64871 33.449 0.844576C33.5314 0.730667 33.6139 0.616757 33.6964 0.5L29.1113 5.09055V5.07631L13.2343 21.0436" />
          <path fill="#fff" d="M10.9503 23.0313C7.07343 19.3235 7.74185 13.5853 11.0498 10.2763C13.4959 7.82722 17.5036 6.82767 21.0021 8.2971L24.7595 6.55998C24.0826 6.07017 23.215 5.54334 22.2195 5.17313C17.7198 3.31926 12.3326 4.24192 8.67479 7.90126C5.15635 11.4239 4.0499 16.8403 5.94992 21.4622C7.36924 24.9165 5.04257 27.3598 2.69884 29.826C1.86829 30.7002 1.0349 31.5745 0.36364 32.5L10.9474 23.0341" />
        </svg>
      ),
    },
  ];

  return (
    <section className={`resources-page-area ${isArabic ? "resources-page-rtl" : ""}`}>
      <div className="container">
        <header className="page-header" data-aos="fade-up">
          <span className="page-badge">{content.badge}</span>
          <h1>{content.title}</h1>
          <p>{content.subtitle}</p>
          <div className="header-actions">
            <Link className="azzle-default-btn btn2" href={langLink("/contact-us")} data-text={content.primaryCta}>
              <span className="button-wraper">{content.primaryCta}</span>
            </Link>
            <a className="secondary-link" href="https://docs.skylightchat.com" target="_blank" rel="noopener noreferrer">
              {content.secondaryCta}
            </a>
          </div>
        </header>

        <div className="stats-row" data-aos="fade-up" data-aos-delay="50">
          {content.stats.map((stat) => (
            <div className="stat-card" key={stat.label}>
              <strong>{stat.value}</strong>
              <span>{stat.label}</span>
            </div>
          ))}
        </div>

        {/* Ask AI Section */}
        <div className="ask-ai-section" data-aos="fade-up" data-aos-delay="75">
          <div className="ask-ai-box">
            <h2 className="ask-ai-title">{content.askAiTitle}</h2>
            <p className="ask-ai-subtitle">{content.askAiSubtitle}</p>

            <div className="ai-logos-row">
              {aiLinks.map((ai) => (
                <a
                  key={ai.name}
                  href={ai.href}
                  target="_blank"
                  rel="noopener noreferrer"
                  className="ai-logo-btn"
                  aria-label={`${lang === "ar" ? "اسأل" : "Ask"} ${ai.name}`}
                  title={`${lang === "ar" ? "اسأل" : "Ask"} ${ai.name}`}
                  style={{ background: ai.bg }}
                >
                  {ai.svg}
                </a>
              ))}
            </div>
          </div>
        </div>

        <div className="section-header" data-aos="fade-up">
          <h2>{content.sectionsTitle}</h2>
          <p>{content.sectionsSubtitle}</p>
        </div>

        <div className="filter-chips" data-aos="fade-up" data-aos-delay="25" role="tablist" aria-label={content.filterChips.all}>
          {FILTER_ORDER.map((filter) => (
            <button
              key={filter}
              type="button"
              role="tab"
              aria-selected={activeFilter === filter}
              className={`filter-chip${activeFilter === filter ? " active" : ""}`}
              onClick={() => setActiveFilter(filter)}
            >
              {content.filterChips[filter]}
            </button>
          ))}
        </div>

        <div className="resources-grid">
          {filteredCards.length === 0 ? (
            <p className="resources-empty" data-aos="fade-up">
              {lang === "ar" ? "لا توجد موارد في هذه الفئة بعد." : "No resources in this category yet."}
            </p>
          ) : null}
          {filteredCards.map((card, index) => {
            const color = TYPE_COLORS[card.type];
            return (
              <article
                className="resource-card"
                key={card.articleId}
                data-aos="fade-up"
                data-aos-delay={index * 50}
              >
                <Link href={langLink(`/resources/${card.articleId}`)} className="resource-card-link">
                  <div className="card-header">
                    <div className="card-icon" style={{ background: color }}>
                      {TYPE_ICONS[card.type]}
                    </div>
                    <span className="card-type" style={{ color }}>{TYPE_LABELS[lang][card.type]}</span>
                  </div>
                  <h3>{card.title}</h3>
                  <p>{card.description}</p>
                  <span className="card-read">
                    {content.readArticle}
                    <span className="card-arrow" aria-hidden>
                      {isArabic ? "←" : "→"}
                    </span>
                  </span>
                </Link>
              </article>
            );
          })}
        </div>

        <div className="section-header" data-aos="fade-up">
          <h2>{content.productTitle}</h2>
          <p>{content.productSubtitle}</p>
        </div>

        <div className="product-grid" data-aos="fade-up">
          {content.productCards.map((product) => (
            <div className="product-card" key={product.title}>
              <h3>{product.title}</h3>
              <p>{product.description}</p>
              <Link href={langLink(product.href)}>{product.cta} →</Link>
            </div>
          ))}
        </div>

        <div className="funnel-section" data-aos="fade-up">
          <div className="funnel-intro">
            <span className="page-badge">{content.funnelBadge}</span>
            <h2>{content.funnelTitle}</h2>
            <p>{content.funnelSubtitle}</p>
          </div>
          <div className="funnel-steps">
            {content.funnelSteps.map((step, index) => (
              <div className="funnel-step" key={step.title}>
                <span className="step-number">{String(index + 1).padStart(2, "0")}</span>
                <div>
                  <h3>{step.title}</h3>
                  <p>{step.description}</p>
                </div>
              </div>
            ))}
          </div>
        </div>

        <div className="page-cta" data-aos="fade-up">
          <h2>{content.ctaTitle}</h2>
          <p>{content.ctaSubtitle}</p>
          <Link className="azzle-default-btn btn2" href={langLink("/contact-us")} data-text={content.ctaButton}>
            <span className="button-wraper">{content.ctaButton}</span>
          </Link>
        </div>
      </div>

      <style jsx>{`
        .resources-page-area {
          padding: 120px 0 100px;
          background: #000000;
          min-height: 100vh;
        }

        .resources-page-rtl {
          direction: rtl;
        }

        .resources-page-rtl .card-read {
          flex-direction: row-reverse;
        }

        .resources-page-rtl .product-card a {
          direction: rtl;
        }

        .ask-ai-section {
          max-width: 900px;
          margin: 0 auto 72px;
          width: 100%;
        }

        .ask-ai-box {
          padding: 40px 48px;
          background: rgba(255, 255, 255, 0.02);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 20px;
          text-align: center;
          position: relative;
          overflow: hidden;
          box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        }

        .ask-ai-box::before {
          content: "";
          position: absolute;
          top: -20%;
          left: 50%;
          transform: translateX(-50%);
          width: 60%;
          height: 30%;
          background: radial-gradient(circle, rgba(118, 16, 242, 0.15) 0%, transparent 70%);
          pointer-events: none;
          filter: blur(20px);
        }

        .ask-ai-title {
          font-size: 22px;
          font-weight: 700;
          color: #fff;
          margin-bottom: 8px;
          letter-spacing: normal;
          line-height: 1.3;
          position: relative;
        }

        .ask-ai-subtitle {
          font-size: 15px;
          color: #94a3b8;
          margin: 0 auto 28px;
          position: relative;
        }

        .ai-logos-row {
          display: flex;
          justify-content: center;
          align-items: center;
          gap: 14px;
          flex-wrap: wrap;
          position: relative;
        }

        .ai-logo-btn {
          width: 56px;
          height: 56px;
          border-radius: 16px;
          display: flex;
          align-items: center;
          justify-content: center;
          box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
          ring: 1px solid rgba(0, 0, 0, 0.06);
          transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
          text-decoration: none;
        }

        .ai-logo-btn:hover {
          transform: scale(1.06);
          box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
        }

        .ai-svg-icon {
          width: 20px;
          height: 20px;
          display: block;
        }

        .page-header {
          text-align: center;
          margin-bottom: 48px;
        }

        .page-badge {
          display: inline-block;
          padding: 6px 16px;
          background: rgba(255, 255, 255, 0.06);
          border: 1px solid rgba(255, 255, 255, 0.08);
          border-radius: 20px;
          font-size: 13px;
          font-weight: 500;
          color: #94a3b8;
          letter-spacing: 0.5px;
          text-transform: uppercase;
          margin-bottom: 24px;
        }

        .page-header h1 {
          font-size: 48px;
          font-weight: 700;
          margin-bottom: 20px;
          color: #fff;
          letter-spacing: normal;
          line-height: 1.15;
          max-width: 900px;
          margin-left: auto;
          margin-right: auto;
        }

        .page-header > p {
          font-size: 18px;
          color: #94a3b8;
          max-width: 720px;
          margin: 0 auto;
          line-height: 1.7;
        }

        .header-actions {
          display: flex;
          justify-content: center;
          align-items: center;
          gap: 16px;
          flex-wrap: wrap;
          margin-top: 32px;
        }

        .secondary-link {
          color: #e2e8f0;
          text-decoration: none;
          border: 1px solid rgba(255, 255, 255, 0.12);
          border-radius: 999px;
          padding: 12px 24px;
          font-size: 14px;
          font-weight: 500;
          transition: border-color 0.2s ease, background 0.2s ease;
        }

        .secondary-link:hover {
          background: rgba(255, 255, 255, 0.04);
          border-color: rgba(255, 255, 255, 0.2);
          color: #fff;
        }

        .stats-row {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 20px;
          max-width: 900px;
          margin: 0 auto 72px;
        }

        .stat-card {
          padding: 24px;
          background: rgba(255, 255, 255, 0.03);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 16px;
          text-align: center;
        }

        .stat-card strong {
          display: block;
          font-size: 28px;
          font-weight: 700;
          color: #fff;
          margin-bottom: 6px;
        }

        .stat-card span {
          font-size: 14px;
          color: #94a3b8;
          line-height: 1.5;
        }

        .section-header {
          margin-bottom: 32px;
        }

        .section-header h2 {
          font-size: 32px;
          font-weight: 700;
          color: #fff;
          margin-bottom: 12px;
          letter-spacing: normal;
          line-height: 1.25;
          word-spacing: normal;
        }

        .section-header p {
          font-size: 16px;
          color: #94a3b8;
          line-height: 1.7;
          margin: 0;
          width: 100%;
        }

        .filter-chips {
          display: flex;
          flex-wrap: wrap;
          gap: 10px;
          margin-bottom: 28px;
        }

        .filter-chip {
          padding: 8px 16px;
          border-radius: 999px;
          border: 1px solid rgba(255, 255, 255, 0.12);
          background: rgba(255, 255, 255, 0.03);
          color: #94a3b8;
          font-size: 13px;
          font-weight: 500;
          letter-spacing: normal;
          line-height: 1.2;
          cursor: pointer;
          transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
        }

        .filter-chip:hover {
          border-color: rgba(255, 255, 255, 0.2);
          color: #e2e8f0;
          background: rgba(255, 255, 255, 0.05);
        }

        .filter-chip.active {
          border-color: rgba(102, 16, 242, 0.5);
          background: rgba(102, 16, 242, 0.15);
          color: #fff;
        }

        .resources-grid {
          display: grid;
          grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
          gap: 24px;
          margin-bottom: 80px;
        }

        .resources-empty {
          grid-column: 1 / -1;
          text-align: center;
          color: #94a3b8;
          font-size: 15px;
          padding: 32px 16px;
          margin: 0;
        }

        .resource-card {
          padding: 32px;
          background: rgba(255, 255, 255, 0.03);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 16px;
          transition: border-color 0.2s ease, background 0.2s ease;
          overflow: hidden;
        }

        .resource-card:hover {
          border-color: rgba(255, 255, 255, 0.12);
          background: rgba(255, 255, 255, 0.04);
        }

        .resource-card-link {
          display: flex;
          flex-direction: column;
          height: 100%;
          color: inherit;
          text-decoration: none;
        }

        .resource-card-link:hover,
        .resource-card-link:focus-visible {
          color: inherit;
        }

        .card-header {
          display: flex;
          align-items: center;
          gap: 12px;
          margin-bottom: 16px;
        }

        .card-icon {
          width: 40px;
          height: 40px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 10px;
          color: #fff;
          flex-shrink: 0;
        }

        .card-icon :global(svg) {
          width: 20px;
          height: 20px;
        }

        .card-type {
          font-size: 12px;
          font-weight: 600;
          text-transform: uppercase;
          letter-spacing: 0.5px;
        }

        .resource-card h3 {
          font-size: 18px;
          font-weight: 600;
          color: #fff;
          margin: 0 0 12px;
          line-height: 1.45;
          text-align: start;
          word-break: break-word;
        }

        .resource-card p {
          font-size: 14px;
          color: #94a3b8;
          line-height: 1.7;
          margin: 0 0 20px;
          flex-grow: 1;
          text-align: start;
          word-break: break-word;
        }

        .card-read {
          display: inline-flex;
          align-items: center;
          gap: 6px;
          font-size: 14px;
          font-weight: 600;
          color: #e2e8f0;
          margin-top: auto;
          padding-top: 4px;
        }

        .card-arrow {
          color: #94a3b8;
          transition: transform 0.2s ease;
        }

        .resource-card:hover .card-read {
          color: #fff;
        }

        .resource-card:hover .card-arrow {
          color: #fff;
          transform: translateX(2px);
        }

        .resources-page-rtl .resource-card:hover .card-arrow {
          transform: translateX(-2px);
        }

        .product-grid {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 24px;
          margin-bottom: 80px;
        }

        .product-card {
          padding: 32px;
          background: rgba(255, 255, 255, 0.03);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 16px;
        }

        .product-card h3 {
          font-size: 20px;
          font-weight: 600;
          color: #fff;
          margin-bottom: 12px;
          letter-spacing: normal;
          line-height: 1.3;
        }

        .product-card p {
          font-size: 14px;
          color: #94a3b8;
          line-height: 1.65;
          margin-bottom: 20px;
        }

        .product-card a {
          font-size: 14px;
          font-weight: 600;
          color: #6610f2;
          text-decoration: none;
        }

        .product-card a:hover {
          color: #7c3aed;
        }

        .funnel-section {
          display: grid;
          grid-template-columns: 1fr 1.1fr;
          gap: 48px;
          padding: 48px;
          background: rgba(255, 255, 255, 0.03);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 16px;
          margin-bottom: 80px;
        }

        .funnel-intro h2 {
          font-size: 28px;
          font-weight: 700;
          color: #fff;
          margin: 16px 0 12px;
          letter-spacing: normal;
          line-height: 1.25;
        }

        .funnel-intro p {
          font-size: 15px;
          color: #94a3b8;
          line-height: 1.7;
          margin: 0;
        }

        .funnel-steps {
          display: flex;
          flex-direction: column;
          gap: 0;
        }

        .funnel-step {
          display: grid;
          grid-template-columns: 48px 1fr;
          gap: 16px;
          padding: 20px 0;
          border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        }

        .funnel-step:last-child {
          border-bottom: none;
          padding-bottom: 0;
        }

        .step-number {
          font-size: 20px;
          font-weight: 700;
          color: #6610f2;
        }

        .funnel-step h3 {
          font-size: 16px;
          font-weight: 600;
          color: #e2e8f0;
          margin: 0 0 6px;
        }

        .funnel-step p {
          font-size: 14px;
          color: #94a3b8;
          line-height: 1.6;
          margin: 0;
        }

        .page-cta {
          text-align: center;
          padding: 64px 32px;
          background: rgba(255, 255, 255, 0.03);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 16px;
        }

        .page-cta h2 {
          font-size: 32px;
          font-weight: 700;
          color: #fff;
          margin-bottom: 16px;
          letter-spacing: normal;
          line-height: 1.25;
        }

        .page-cta p {
          font-size: 16px;
          color: #94a3b8;
          max-width: 560px;
          margin: 0 auto 28px;
          line-height: 1.7;
        }

        @media (max-width: 991px) {
          .page-header h1 {
            font-size: 36px;
          }

          .stats-row,
          .product-grid {
            grid-template-columns: 1fr;
          }

          .funnel-section {
            grid-template-columns: 1fr;
            padding: 32px 24px;
          }
        }

        @media (max-width: 768px) {
          .resources-page-area {
            padding: 100px 0 80px;
          }

          .resources-grid {
            grid-template-columns: 1fr;
          }

          .resource-card {
            padding: 24px 20px;
          }
        }
      `}</style>
    </section>
  );
}
