/* --- GLOBAL STYLES & VARIABLES --- */
:root {
  --color-bg: #000000;
  --color-text: #e5e7eb;
  --color-text-muted: #9ca3af;
  --color-surface: #111827;
  --color-primary: #ffffff;
  --font-display: 'Teko', sans-serif;
  --font-body: 'Tajawal', sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app-main {
  flex-grow: 1;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--color-primary);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- HEADER --- */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  transition: background-color 0.3s ease, backdrop-filter 0.3s ease;
}
#app-header.scrolled {
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.header-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Desktop Nav */
.header-nav {
  display: none;
}
@media (min-width: 1024px) {
  .header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
  }
}
.nav-link {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 0.375rem;
  transition: background-color 0.3s ease;
}
.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.lang-toggle {
  border: 1px solid rgba(255, 255, 255, 0.5);
}
/* Dropdown */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-content {
  position: absolute;
  top: 100%;
  margin-top: 0.5rem;
  width: 12rem;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  border-radius: 0.375rem;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  padding: 0.5rem 0;
}
html[dir="ltr"] .nav-dropdown-content { left: 0; }
html[dir="rtl"] .nav-dropdown-content { right: 0; }
.nav-dropdown:hover .nav-dropdown-content {
  opacity: 1;
  visibility: visible;
}
.nav-dropdown-link {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}
.nav-dropdown-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Nav */
.mobile-menu-toggle {
  display: block;
  z-index: 60;
  position: relative;
}
@media (min-width: 1024px) {
  .mobile-menu-toggle {
    display: none;
  }
}
.mobile-nav {
  position: fixed;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  z-index: 55;
}
html[dir="ltr"] .mobile-nav {
  left: 0;
  transform: translateX(-100%);
}
html[dir="rtl"] .mobile-nav {
  right: 0;
  transform: translateX(100%);
}
.mobile-nav.open {
  transform: translateX(0);
}
.mobile-nav .nav-link {
  font-size: 1.25rem;
}
.mobile-nav .materials-title {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.875rem;
}

/* --- HERO SECTION (HOME PAGE) --- */
.hero-section {
  height: 100vh;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-primary);
  background-color: var(--color-bg);
}
.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.4;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
}
.hero-content {
  position: relative;
  z-index: 10;
  padding: 1.5rem;
}
.hero-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.hero-subtitle {
  margin-top: 1rem;
  font-size: 1.25rem;
  font-weight: 300;
  letter-spacing: 0.1em;
}
@media (min-width: 768px) {
  .hero-title { font-size: 4rem; }
  .hero-subtitle { font-size: 1.5rem; }
}

/* --- CATEGORY PREVIEW (HOME PAGE) --- */
.category-preview-section {
  height: 100vh;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  overflow: hidden;
}
.category-preview-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.7;
  transform: scale(1.1);
  transition: transform 1s cubic-bezier(0.19, 1, 0.22, 1);
}
.category-preview-section:hover .category-preview-bg {
  transform: scale(1);
}
.category-preview-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
}
.category-preview-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 1.5rem;
}
.category-preview-title {
  font-size: 2.5rem;
  font-weight: 600;
}
@media (min-width: 768px) {
  .category-preview-title { font-size: 4rem; }
}
.view-collection-btn {
  margin-top: 1.5rem;
  display: inline-block;
  border: 2px solid var(--color-primary);
  padding: 0.75rem 2rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.view-collection-btn:hover {
  background-color: var(--color-primary);
  color: var(--color-bg);
}

/* --- CATEGORY PAGE --- */
.category-page {
  background-color: #f3f4f6;
  color: #111827;
  min-height: 100vh;
}
.category-header {
  position: relative;
  height: 24rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-primary);
}
.category-header-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.5;
}
.category-header-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
}
.category-header-title {
  position: relative;
  z-index: 10;
  font-size: 2.5rem;
  font-weight: 700;
}
@media (min-width: 768px) {
  .category-header-title { font-size: 4rem; }
}
.stone-grid {
  padding-top: 3rem;
  padding-bottom: 3rem;
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
}
@media (min-width: 640px) {
  .stone-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .stone-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- STONE CARD --- */
.stone-card {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  aspect-ratio: 1 / 1;
}
.stone-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}
.stone-card:hover .stone-card-img {
  transform: scale(1.1);
}
.stone-card-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  transition: background-color 0.3s ease;
}
.stone-card:hover .stone-card-overlay {
  background-color: rgba(0, 0, 0, 0.2);
}
.stone-card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}
.stone-card-title {
  color: var(--color-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

/* --- STONE DETAIL PAGE --- */
.stone-detail-page {
  padding-top: 8rem;
  padding-bottom: 4rem;
  background-color: white;
  color: #1f2937;
}
.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  color: #6b7280;
}
.back-link:hover {
  color: #111827;
}
.stone-detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4rem;
}
@media (min-width: 1024px) {
  .stone-detail-layout { grid-template-columns: 1fr 1fr; }
}
.stone-gallery .main-image {
  aspect-ratio: 3 / 2;
  border-radius: 0.5rem;
  overflow: hidden;
  background-color: #f3f4f6;
}
.stone-gallery .main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stone-gallery .thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}
.stone-gallery .thumbnail {
  aspect-ratio: 3 / 2;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
}
.stone-gallery .thumbnail.active {
  border-color: var(--color-bg);
}
.stone-gallery .thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stone-details h1 {
  font-size: 2.25rem;
  font-weight: 700;
}
.specifications {
  margin-top: 2rem;
}
.specifications h2 {
  font-size: 1.25rem;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.spec-label {
  font-weight: 500;
  color: #6b7280;
}

/* --- FOOTER --- */
#app-footer {
  background-color: var(--color-bg);
  color: var(--color-text-muted);
  padding: 3rem 1.5rem;
  border-top: 1px solid #1f2937;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 768px) {
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
}
.footer-section h4 {
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.footer-section .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
}
.footer-section p, .footer-section a, .footer-section li {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}
.footer-section .icon-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.footer-section .icon-link svg {
  flex-shrink: 0;
}
.footer-section .agencies-list {
  margin-top: 1rem;
}
.footer-section .agency-info {
  font-size: 0.8rem;
  font-style: italic;
  color: #9ca3af;
}
.footer-section .address-item {
  margin-bottom: 1rem;
}
.footer-section .address-item strong {
  display: block;
  color: var(--color-primary);
  font-size: 0.9rem;
}
.footer-section .address-item a {
  font-size: 0.8rem;
  text-decoration: underline;
  color: #9ca3af;
}
.footer-section .address-item a:hover {
  color: var(--color-primary);
}
.footer-section .address-item .map-placeholder {
  font-size: 0.8rem;
  font-style: italic;
}
.footer-section .get-in-touch-header {
  margin-top: 1.5rem;
}

.footer-copyright {
  text-align: center;
  font-size: 0.75rem;
  color: #4b5563;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #1f2937;
}
/* Footer Form */
.footer-form input, .footer-form textarea {
  width: 100%;
  background-color: #1f2937;
  border: 1px solid #374151;
  color: var(--color-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.footer-form input:focus, .footer-form textarea:focus {
  outline: none;
  border-color: #6b7280;
  box-shadow: 0 0 0 2px #374151;
}
.footer-form button {
  width: 100%;
  background-color: #e5e7eb;
  color: var(--color-bg);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.footer-form button:hover {
  background-color: var(--color-primary);
}

/* --- CHATBOT --- */
.chatbot-toggle-btn {
  position: fixed;
  bottom: 1.5rem;
  z-index: 50;
  width: 4rem;
  height: 4rem;
  background-color: var(--color-bg);
  color: var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}
.chatbot-toggle-btn:hover {
  transform: scale(1.1);
}
html[dir="ltr"] .chatbot-toggle-btn { right: 1.5rem; }
html[dir="rtl"] .chatbot-toggle-btn { left: 1.5rem; }

.chatbot-window {
  position: fixed;
  bottom: 6.5rem;
  width: calc(100vw - 3rem);
  max-width: 24rem;
  height: 60vh;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  z-index: 40;
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
}
.chatbot-window.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
html[dir="ltr"] .chatbot-window { right: 1.5rem; }
html[dir="rtl"] .chatbot-window { left: 1.5rem; }

.chatbot-header {
  background-color: #f3f4f6;
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}
.chatbot-header h3 {
  font-weight: 700;
  font-size: 1.125rem;
  color: #1f2937;
}

/* Chatbot Messages */
.chatbot-messages {
  flex-grow: 1;
  padding: 1rem;
  overflow-y: auto;
  background-color: #f9fafb;
}
.message-container {
  display: flex;
  margin-bottom: 1rem;
}
.message-container.user {
  justify-content: flex-end;
}
.message-container.bot {
  justify-content: flex-start;
}
.message-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  color: #1f2937;
  line-height: 1.4;
  word-wrap: break-word;
  font-size: 0.9rem;
}
.message-bubble.user {
  background-color: var(--color-bg);
  color: var(--color-primary);
  border-bottom-right-radius: 0.25rem;
}
html[dir="rtl"] .message-bubble.user {
  border-bottom-right-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
}
.message-bubble.bot {
  background-color: #e5e7eb;
  border-bottom-left-radius: 0.25rem;
}
html[dir="rtl"] .message-bubble.bot {
  border-bottom-left-radius: 1rem;
  border-bottom-right-radius: 0.25rem;
}

/* Chatbot Input Area */
.chatbot-footer {
  padding: 0.5rem;
  border-top: 1px solid #e5e7eb;
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}
.chatbot-disclaimer {
  font-size: 0.75rem;
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}
.chatbot-input-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chatbot-input-form input {
  flex-grow: 1;
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  font-size: 0.9rem;
  color: #1f2937;
}
.chatbot-input-form input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.2);
}
.chatbot-input-form button {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: var(--color-bg);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.chatbot-input-form button:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}
.chatbot-input-form button:hover:not(:disabled) {
  background-color: #374151;
}

/* API Key Form in Chatbot */
.api-key-form {
  padding: 1.5rem;
  color: #1f2937;
  text-align: center;
}
.api-key-form h4 {
  font-weight: 600;
  font-size: 1.1rem;
}
.api-key-form p {
  font-size: 0.9rem;
  color: #4b5563;
  margin: 0.5rem 0 1.5rem;
}
.api-key-form a {
  color: #0056b3;
  text-decoration: underline;
}
.api-key-form input {
  width: 100%;
  text-align: center;
  padding: 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}
.api-key-form button {
  width: 100%;
  padding: 0.7rem;
  background-color: var(--color-bg);
  color: var(--color-primary);
  border: none;
  border-radius: 0.375rem;
  font-weight: 600;
  cursor: pointer;
}

/* Loading dots */
.loading-dots {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    padding: 0.75rem 1rem;
}
.loading-dots span {
    width: 0.5rem;
    height: 0.5rem;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.loading-dots .dot-1 { animation-delay: -0.32s; }
.loading-dots .dot-2 { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}
