"use client";

import React from "react";
import { useLanguage } from "./LanguageContext";

export function Logo({ centerOnMobile = true }: { centerOnMobile?: boolean }) {
  const { tr } = useLanguage();

  return (
    <div
      id="app-logo-bar"
      data-nodrag="true"
      style={{
        position: "fixed",
        top: "calc(env(safe-area-inset-top, 0px) + 8px)",
        left: 0,
        right: 0,
        zIndex: 99999,
        isolation: "isolate",
        display: "flex",
        alignItems: "center",
        justifyContent: centerOnMobile ? "center" : "flex-start",
        padding: "0 24px",
        pointerEvents: "none",
      }}
    >
      <div style={{ pointerEvents: "auto", position: "relative", zIndex: 2 }}>
        <button
          type="button"
          data-nodrag="true"
          onClick={() => {
            window.location.href = "https://alawaly.sa/en";
          }}
          aria-label="Go to home"
          title={tr("Home")}
          style={{
            background: "transparent",
            border: "none",
            borderRadius: "8px",
            padding: "16px 8px",
            display: "flex",
            alignItems: "center",
            cursor: "pointer",
            transition: "transform 200ms ease, filter 200ms ease",
          }}
          onMouseEnter={(e) => (e.currentTarget.style.transform = "scale(1.035)")}
          onMouseLeave={(e) => (e.currentTarget.style.transform = "scale(1)")}
        >
          <svg
            xmlns="http://www.w3.org/2000/svg"
            viewBox="0 0 297.95 97.11"
            role="img"
            aria-label="Brand logo"
            style={{
              height: "55px",
              width: "auto",
              display: "block",
              userSelect: "none",
              color: "white",
              filter: `
                drop-shadow(0 2px 2px rgba(0,0,0,0.68))
                drop-shadow(0 4px 6px rgba(0,0,0,0.48))
                drop-shadow(0 8px 16px rgba(0,0,0,0.30))
              `,
              transition: "filter 200ms ease",
            }}
          >
            <g id="Layer_1-2" data-name="Layer 1">
              <g id="Alawaly">
                <g fill="#ffffff">
                  <path d="M261.16,97.11l-2.07-97.11c1,1.21,4.16,2.58,4.95,3.51.71.85.48,6.33.43,7.87-.67,23.65-1.48,47.39-2.1,71.04-.1,3.89.53,9.23.04,12.85-.12.86-.35,1.51-1.26,1.84Z" />
                  <path d="M269.42,90.91l-2.06-84.71c1.6,1.22,5.11,2.61,5.39,4.73-.51,26.5-1.23,52.84-2.16,79.29l-1.17.69Z" />
                  <path d="M278.92,84.71l-.83-.61c-1.02-23.92-1.44-47.79-2.48-71.7l5.18,3.29c1.43,1.6.22,4.16.17,5.99-.2,8.43-.57,16.82-.83,25.21-.39,12.59-.31,25.27-1.23,37.83Z" />
                  <path d="M289.57,21.99l-1.17,28.61c-.3,7.34-.31,14.62-.81,21.92-.14,2.08.81,5.34-1.24,6.4l-2.07-60.33,5.28,3.39Z" />
                  <path d="M295.04,72.73l-2.48-48.35,4.98,3.48.41,1.25c-.9,13.18-.63,26.56-1.68,39.68-.08,1.04-.27,3.42-1.23,3.93Z" />
                  <path d="M252.89.42c-.29,19.63-.21,39.26-.39,58.9,0,.98-.44,1.88-.45,2.86-.1,9.71.28,19.46-.19,29.15l-1.05-88.66c-.32-.79,1.66-2.74,2.09-2.25Z" />
                  <path d="M244.62,6.61l-1.03,73.56c-.18,0-.61-3-.64-3.5-1.26-20.85.1-43.42-.38-64.5-.05-2.41-1.74-4.91,2.05-5.56Z" />
                  <path d="M235.12,82.64c-.72.1-.39-.94-.41-1.44-.29-7.14.12-14.36.02-21.51-.15-11.06-.67-22.37-.86-33.44-.03-1.84-.23-11.87.23-12.62.1-.16,1.79-1.33,1.85-1.24l-.83,70.24Z" />
                  <path d="M227.68,18.6l-1.03,58.27c-.71-18.62-.9-37.33-1.05-56.02-.32-.79,1.66-2.74,2.09-2.25Z" />
                  <path d="M219.42,24.8c-.83,5.88-.29,12.01-.39,17.99-.12,6.82-.82,13.77-.41,20.66l-.84,5.97c-.11-6.4.12-12.83.01-19.23s-.27-12.41-.41-18.59c-.06-2.53-1.91-6.28,2.05-6.8Z" />
                </g>
                <g fill="#ffffff">
                  <path d="M165.5,36.44h-49.17c-.69,3.39-3.05,6.64-6.32,7.93-1.7.67-4.96,1.67-5.25-.91,4.27.26,6.67-3.23,7.44-7.03h-8.88c-5.02,0-10.33-4.76-10.9-9.76-1.15-9.99,8.43-16.21,17.46-12.5,7.63,3.13,7.68,13.24,7.05,20.22.3.41.81.35,1.25.41,1.05.13,13.62.12,13.44-.63l-6.6-20.46h26.03l-6.2,21.07h15.7s0-25.82,0-25.82l.68-.55c.38-.12.77-.05,1.15-.09,1.03-.09,2.48-.2,3.12.64v27.48ZM102.07,34.37c2.88.51,7.08-.38,10.12,0v-12.19c0-.76-1.46-4.13-2.06-4.85-2.6-3.09-8.54-3.07-11.17,0-3.39,3.94-3.12,15.93,3.11,17.04ZM130.37,15.78c.97,2.44,5.02,18.1,6.19,18.81.89.55,3.12,0,3.66-.91l5.44-18.32c-.15-.2-.53.41-.62.41h-14.67Z" />
                  <path d="M70.45,36.44h-24.79v-12.19c0-2.27-2.09-5.85-3.93-7.23-1.39-1.04-4.49-2.52-5.99-1.45v20.87H3.93v-11.78c0-.73.89-3.69,1.23-4.56,1.34-3.38,4.33-5.59,7.44-7.22.82,2-1.62,3.35-2.55,5.5-.54,1.25-1.57,5.06-1.57,6.28v9.5l.62.62h22.31l.62-.62V13.3h6.4c2.23,0,6.38,1.55,8.07,3.09,1.4,1.28,3.71,5.2,3.71,7.03v10.74l.67.59c1.7-.72,2.93,0,4.48.05,2.6.08,6.68.29,9.13,0,.6-.07,1.06-.05,1.43-.64V8.34c1.48.19,3.46-.56,4.55.62v27.48Z" />
                  <path d="M88.96,81.65c1.02.16.62-.09.83-.56,2.45-5.43,4.03-11.4,6.32-16.92l7.34,17.47,7.7-19.62,2.03-.23-10.11,26.62-.8.38c-.83-.2-5.35-13.75-6.47-15.77-.25-.45.03-.67-.88-.51l-5.54,15.31c-.75,1.99-2.05.69-2.47-.74l-9.86-25.28,4.57.39,7.35,19.46Z" />
                  <path d="M126.22,61.47l12.37,26.93-4.7-.06-3.69-8.62-11.9.19c-1.15,1.54-2.72,7.21-3.73,8.1-.66.59-1.41.4-2.19.39l12.27-26.75,1.57-.18ZM119.53,77.68h9.53l-4.57-9.93c-.69-.2-1.13,1.44-1.33,1.85-1.25,2.67-2.49,5.37-3.63,8.08Z" />
                  <path d="M141.52,61.47h4.92v22.75h16.2v4.18h-21.12v-26.93Z" />
                  <path d="M187.97,61.47l12.37,26.93-4.7-.06-3.69-8.62-11.9.19c-1.15,1.54-2.72,7.21-3.73,8.1-.66.59-1.41.4-2.19.39l12.27-26.75,1.57-.18ZM181.28,77.68h9.53l-4.57-9.93c-.69-.2-1.13,1.44-1.33,1.85-1.25,2.67-2.49,5.37-3.63,8.08Z" />
                  <path d="M219.48,61.47l-6.84,17.72-7.23-17.72h-5.21l10.02,23.36v7.76h4.92v-7.76l9.96-23.36h-5.62Z" />
                  <path d="M57.65,61.47l12.37,26.93-4.7-.06-3.69-8.62-11.9.19c-1.15,1.54-2.72,7.21-3.73,8.1-.66.59-1.41.4-2.19.39l12.27-26.75,1.57-.18ZM50.96,77.68h9.53l-4.57-9.93c-.69-.2-1.13,1.44-1.33,1.85-1.25,2.67-2.49,5.37-3.63,8.08Z" />
                  <path d="M37.7,88.4h-5.02v-26.93h5.02v26.93Z" />
                </g>
              </g>
            </g>
          </svg>
        </button>
      </div>
    </div>
  );
}
