"use client";

import { useState } from "react";
import { useLanguage } from "@/contexts/LanguageContext";

const industries = [
  {
    id: "education",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M22 10v6M2 10l10-5 10 5-10 5z" strokeLinecap="round" strokeLinejoin="round"/>
        <path d="M6 12v5c3 3 9 3 12 0v-5" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#8B5CF6",
  },
  {
    id: "healthcare",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M22 12h-4l-3 9L9 3l-3 9H2" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#EC4899",
  },
  {
    id: "ecommerce",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <circle cx="9" cy="21" r="1"/>
        <circle cx="20" cy="21" r="1"/>
        <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#F59E0B",
  },
  {
    id: "realestate",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" strokeLinecap="round" strokeLinejoin="round"/>
        <polyline points="9 22 9 12 15 12 15 22" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#10B981",
  },
  {
    id: "tourism",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <circle cx="12" cy="12" r="10"/>
        <path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#06B6D4",
  },
  {
    id: "restaurant",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M18 8h1a4 4 0 0 1 0 8h-1M2 8h16v9a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4V8zM6 1v3M10 1v3M14 1v3" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#EF4444",
  },
  {
    id: "insurance",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#6366F1",
  },
  {
    id: "automotive",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M5 17H3a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h2m14 7h2a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2h-2M5 10l2-5h10l2 5M5 17a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM19 17a2 2 0 1 0 0-4 2 2 0 0 0 0 4z" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#78716C",
  },
  {
    id: "fitness",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5zM16 8L2 22M17.5 15H9" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#84CC16",
  },
  {
    id: "legal",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <circle cx="12" cy="12" r="10"/>
        <path d="M12 6v6l4 2" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#A855F7",
  },
  {
    id: "hr",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
        <circle cx="9" cy="7" r="4"/>
        <path d="M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#F97316",
  },
  {
    id: "logistics",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <rect x="1" y="3" width="15" height="13"/>
        <polygon points="16 8 20 8 23 11 23 16 16 16 16 8" strokeLinecap="round" strokeLinejoin="round"/>
        <circle cx="5.5" cy="18.5" r="2.5"/>
        <circle cx="18.5" cy="18.5" r="2.5"/>
      </svg>
    ),
    color: "#0EA5E9",
  },
  {
    id: "government",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M3 21h18M3 10h18M5 6l7-3 7 3M4 10v11M20 10v11M8 14v3M12 14v3M16 14v3" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#64748B",
  },
  {
    id: "events",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
        <line x1="16" y1="2" x2="16" y2="6" strokeLinecap="round" strokeLinejoin="round"/>
        <line x1="8" y1="2" x2="8" y2="6" strokeLinecap="round" strokeLinejoin="round"/>
        <line x1="3" y1="10" x2="21" y2="10" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#E11D48",
  },
  {
    id: "telecom",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#14B8A6",
  },
  {
    id: "beauty",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#DB2777",
  },
  {
    id: "media",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <polygon points="23 7 16 12 23 17 23 7" strokeLinecap="round" strokeLinejoin="round"/>
        <rect x="1" y="5" width="15" height="14" rx="2" ry="2"/>
      </svg>
    ),
    color: "#DC2626",
  },
  {
    id: "nonprofit",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <path d="M4.318 6.318a4.5 4.5 0 0 0 0 6.364L12 20.364l7.682-7.682a4.5 4.5 0 0 0-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 0 0-6.364 0z" strokeLinecap="round" strokeLinejoin="round"/>
      </svg>
    ),
    color: "#059669",
  },
  {
    id: "gaming",
    icon: (
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
        <line x1="6" y1="12" x2="10" y2="12" strokeLinecap="round" strokeLinejoin="round"/>
        <line x1="8" y1="10" x2="8" y2="14" strokeLinecap="round" strokeLinejoin="round"/>
        <line x1="15" y1="13" x2="15.01" y2="13" strokeLinecap="round" strokeLinejoin="round"/>
        <line x1="18" y1="11" x2="18.01" y2="11" strokeLinecap="round" strokeLinejoin="round"/>
        <rect x="2" y="6" width="20" height="12" rx="2"/>
      </svg>
    ),
    color: "#7C3AED",
  },
];

export default function UseCasesArea() {
  const { t, language } = useLanguage();
  const [activeCategory, setActiveCategory] = useState<string | null>(null);

  return (
    <section className="use-cases-page-area">
      <style jsx>{`
        .use-cases-page-area {
          padding: 120px 0 100px;
          background: #000000;
          min-height: 100vh;
        }

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

        .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: -0.5px;
        }

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

        .industries-grid {
          display: grid;
          grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
          gap: 20px;
        }

        .industry-card {
          background: rgba(255, 255, 255, 0.03);
          border: 1px solid rgba(255, 255, 255, 0.06);
          border-radius: 16px;
          padding: 28px;
          transition: border-color 0.2s ease, background 0.2s ease;
          cursor: pointer;
          position: relative;
        }

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

        .industry-card.active {
          border-color: var(--card-color);
          background: rgba(255, 255, 255, 0.05);
        }

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

        .card-icon {
          width: 44px;
          height: 44px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 10px;
          background: var(--card-color);
          opacity: 0.9;
          color: #fff;
        }

        .card-icon svg {
          width: 24px;
          height: 24px;
        }

        .card-title {
          font-size: 20px;
          font-weight: 600;
          color: #fff;
          margin: 0;
        }

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

        .card-features {
          display: flex;
          flex-direction: column;
          gap: 8px;
          margin-bottom: 20px;
        }

        .feature-item {
          display: flex;
          align-items: flex-start;
          gap: 10px;
          font-size: 14px;
          color: #cbd5e1;
        }

        .feature-check {
          width: 18px;
          height: 18px;
          border-radius: 5px;
          background: rgba(16, 185, 129, 0.12);
          display: flex;
          align-items: center;
          justify-content: center;
          flex-shrink: 0;
          margin-top: 2px;
        }

        .feature-check svg {
          width: 10px;
          height: 10px;
          color: #10b981;
        }

        .card-examples {
          display: flex;
          flex-wrap: wrap;
          gap: 6px;
        }

        .example-tag {
          padding: 5px 12px;
          background: rgba(255, 255, 255, 0.04);
          border: 1px solid rgba(255, 255, 255, 0.07);
          border-radius: 6px;
          font-size: 12px;
          color: #94a3b8;
          transition: border-color 0.2s ease;
        }

        .industry-card:hover .example-tag {
          border-color: rgba(255, 255, 255, 0.12);
        }

        .results-badge {
          display: inline-flex;
          align-items: center;
          gap: 6px;
          padding: 6px 14px;
          background: rgba(255, 255, 255, 0.04);
          border: 1px solid rgba(255, 255, 255, 0.07);
          border-radius: 8px;
          font-size: 13px;
          color: #94a3b8;
          margin-top: 14px;
        }

        .results-badge svg {
          width: 14px;
          height: 14px;
          color: #10b981;
        }

        .cta-section {
          text-align: center;
          margin-top: 72px;
        }

        .cta-section h2 {
          font-size: 32px;
          font-weight: 700;
          color: #fff;
          margin-bottom: 12px;
        }

        .cta-section p {
          font-size: 16px;
          color: #94a3b8;
          margin-bottom: 28px;
        }

        .cta-button {
          display: inline-flex;
          align-items: center;
          gap: 10px;
          padding: 14px 32px;
          background: #6610f2;
          border: none;
          border-radius: 10px;
          font-size: 16px;
          font-weight: 600;
          color: #fff;
          cursor: pointer;
          transition: background 0.2s ease, transform 0.15s ease;
          text-decoration: none;
        }

        .cta-button:hover {
          background: #5a0cd6;
          transform: translateY(-1px);
        }

        @media (max-width: 992px) {
          .industries-grid {
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
          }
        }

        @media (max-width: 768px) {
          .use-cases-page-area {
            padding: 100px 0 60px;
          }

          .page-header h1 {
            font-size: 32px;
          }

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

          .industry-card {
            padding: 24px;
          }

          .card-title {
            font-size: 18px;
          }
        }
      `}</style>

      <div className="container">
        <div className="page-header" data-aos="fade-up">
          <span className="page-badge">{t("useCasesPage.badge")}</span>
          <h1>{t("useCasesPage.title")}</h1>
          <p>{t("useCasesPage.subtitle")}</p>
        </div>

        <div className="industries-grid">
          {industries.map((industry, index) => (
            <div
              key={industry.id}
              className={`industry-card ${activeCategory === industry.id ? "active" : ""}`}
              style={{ "--card-color": industry.color } as React.CSSProperties}
              onClick={() => setActiveCategory(activeCategory === industry.id ? null : industry.id)}
              data-aos="fade-up"
              data-aos-delay={index * 40}
            >
              <div className="card-header">
                <div className="card-icon">{industry.icon}</div>
                <h3 className="card-title">{t(`useCasesPage.${industry.id}.name`)}</h3>
              </div>

              <p className="card-description">{t(`useCasesPage.${industry.id}.description`)}</p>

              <div className="card-features">
                {[1, 2, 3, 4].map((num) => (
                  <div key={num} className="feature-item">
                    <span className="feature-check">
                      <svg viewBox="0 0 12 12" fill="none">
                        <path d="M10 3L4.5 8.5L2 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
                      </svg>
                    </span>
                    <span>{t(`useCasesPage.${industry.id}.benefit${num}`)}</span>
                  </div>
                ))}
              </div>

              <div className="card-examples">
                {[1, 2, 3, 4].map((num) => (
                  <span key={num} className="example-tag">
                    {t(`useCasesPage.${industry.id}.example${num}`)}
                  </span>
                ))}
              </div>

              <div className="results-badge">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
                  <polyline points="23 6 13.5 15.5 8.5 10.5 1 18" strokeLinecap="round" strokeLinejoin="round"/>
                  <polyline points="17 6 23 6 23 12" strokeLinecap="round" strokeLinejoin="round"/>
                </svg>
                {t(`useCasesPage.${industry.id}.results`)}
              </div>
            </div>
          ))}
        </div>

        <div className="cta-section" data-aos="fade-up">
          <h2>{t("useCasesPage.cta.title")}</h2>
          <p>{t("useCasesPage.cta.subtitle")}</p>
          <a href="https://dashboard.skylightchat.com" className="cta-button">
            {t("useCasesPage.cta.button")}
            <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
              <path d="M5 12h14M12 5l7 7-7 7" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
          </a>
        </div>
      </div>
    </section>
  );
}
