/* CSS Variables for Theme Management */
:root {
  /* Light Theme Colors */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --warning-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);

  --bg-primary: #f8fafc;

  /* Tool card catalog styles */
  --card-min-width: 280px;
  --card-gap: 1.5rem;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-heavy: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Animation Variables */
  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease;
  --bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.95);
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-heavy: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Theme-based images (brand and footer only) */
.theme-img {
  transition: opacity var(--transition-medium);
}

/* Dark theme images */
[data-theme="dark"] img#brandLogo.theme-img,
[data-theme="dark"] .footer-logo img.theme-img {
  content: url("./assets/dr.png");
}

/* Light theme images */
[data-theme="light"] img#brandLogo.theme-img,
[data-theme="light"] .footer-logo img.theme-img {
  content: url("./assets/li.png");
}

/* Tool icon theme switching - Only apply to specific images */
[data-theme="dark"] .footer-logo img.theme-img {
  content: url("./assets/dr.png");
}

[data-theme="light"] .footer-logo img.theme-img {
  content: url("./assets/li.png");
}

/* Tool images for light and dark themes */
[data-theme="dark"] body .tool-card[data-tool="interchange"] .tool-icon-img {
  content: url("./assets/T11.png") !important;
}

[data-theme="light"] body .tool-card[data-tool="interchange"] .tool-icon-img {
  content: url("./assets/T1.png") !important;
}

[data-theme="dark"] body .tool-card[data-tool="workhours"] .tool-icon-img {
  content: url("./assets/T22.png") !important;
}

[data-theme="light"] body .tool-card[data-tool="workhours"] .tool-icon-img {
  content: url("./assets/T2.png") !important;
}

[data-theme="dark"] body .tool-card[data-tool="merchant"] .tool-icon-img {
  content: url("./assets/T33.png") !important;
}

[data-theme="light"] body .tool-card[data-tool="merchant"] .tool-icon-img {
  content: url("./assets/T3.png") !important;
}

[data-theme="dark"] body .tool-card[data-tool="erp"] .tool-icon-img {
  content: url("./assets/T44.png") !important;
}

[data-theme="light"] body .tool-card[data-tool="erp"] .tool-icon-img {
  content: url("./assets/T4.png") !important;
}

/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: all var(--transition-medium);
  overflow-x: hidden;
}

/* RTL Support for Arabic */
[dir="rtl"] body {
  font-family: 'Cairo', sans-serif;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
  z-index: -1;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(-20px) translateY(-10px); }
  50% { transform: translateX(20px) translateY(10px); }
  75% { transform: translateX(-10px) translateY(20px); }
}

/* App Container */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: #667eea;
  color: #667eea;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Hero Section */
.hero-section {
  text-align: center;
  padding: 2rem 0;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto;
}

/* Tools Section */
.tools-section {
  padding: 1rem 0;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--text-primary);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
  gap: var(--card-gap);
  perspective: 1000px;
  justify-items: center;
  width: 100%;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all var(--transition-medium);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  height: 100%;
  box-shadow: var(--shadow-light);
  transform-style: preserve-3d;
  transform: translateZ(0);
  width: 100%;
  max-width: 340px;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
  border-radius: 16px 16px 0 0;
}

.tool-card:hover {
  transform: translateY(-8px) translateZ(20px);
  box-shadow: var(--shadow-heavy);
  border-color: #667eea;
}

.tool-icon {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  box-shadow: var(--shadow-light);
  transition: all var(--transition-medium);
}

.tool-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-medium);
}

.tool-card:hover .tool-icon {
  transform: scale(1.05);
  box-shadow: var(--shadow-medium);
}

.tool-card:hover .tool-icon-img {
  transform: scale(1.1);
}

.tool-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tool-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.tool-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1rem;
}

.tool-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.tool-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #667eea;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(102, 126, 234, 0.1);
}

.tool-link:hover {
  gap: 0.75rem;
  background: rgba(102, 126, 234, 0.2);
  transform: translateY(-2px);
}

.tool-detail-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 36px;
  height: 36px;
}

.tool-detail-btn:hover {
  color: #667eea;
  background: rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

/* Tool Detail Modal Styles */
.tool-detail-content h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.tool-detail-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.tool-detail-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.tool-detail-content ul {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.tool-detail-content li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.tool-detail-actions {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

[dir="rtl"] .tool-detail-content ul {
  padding-right: 1.5rem;
  padding-left: 0;
}

/* Add Tool Section */
.add-tool-section {
  padding: 1rem 0;
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 1.5rem;
}

.add-tool-content {
  text-align: center;
}

.add-tool-description {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: #667eea;
}

.footer-copyright {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition-medium);
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-heavy);
  position: relative;
  transform: translateY(20px);
  transition: transform var(--transition-medium);
}

.modal.show .modal-content {
  transform: translateY(0);
}

.close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.close:hover {
  color: var(--text-primary);
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Instructions Content */
.instructions-content ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.instructions-content li {
  margin-bottom: 0.75rem;
}

.instructions-content pre {
  background: var(--bg-primary);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5rem 0;
}

/* About Content */
.about-content p {
  margin-bottom: 1rem;
}

.about-content ul {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.about-content li {
  margin-bottom: 0.5rem;
}

/* Contact Content */
.contact-form {
  margin-bottom: 1.5rem;
}

.contact-info {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (min-width: 768px) {
  .app-container {
    padding: 2rem;
  }

  .hero-title {
    font-size: 3rem;
  }

  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
  }

  /* Medium screen card adjustments */
  .tool-card {
    padding: 1.4rem;
  }

  .tool-icon {
    width: 65px;
    height: 65px;
    margin-bottom: 1rem;
  }

  .tool-title {
    font-size: 1.15rem;
  }

  .tool-description {
    font-size: 0.9rem;
  }

  .footer-content {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Mobile Optimizations */
@media (max-width: 767px) {
  .app-header {
    padding: 0.75rem 0;
    margin-bottom: 1.5rem;
  }

  .app-title {
    font-size: 1.25rem;
  }

  .hero-section {
    padding: 1.5rem 0;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-description {
    font-size: 1rem;
  }

  .section-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    justify-items: stretch;
  }

  .tool-card {
    max-width: none;
    width: 100%;
  }

  /* Add mobile-specific card styles */
  .tool-card {
    padding: 1.25rem;
    min-height: 220px;
  }

  .tool-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 0.75rem;
  }

  .tool-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .tool-description {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    -webkit-line-clamp: 2;
  }

  .tool-actions {
    padding-top: 0.75rem;
  }

  .tool-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .tool-detail-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .tool-card {
    padding: 1rem;
    height: auto;
    min-height: 200px;
  }

  .tool-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 0.5rem;
  }

  .tool-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
  }

  .tool-description {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    -webkit-line-clamp: 2;
  }

  .tool-actions {
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  .tool-link {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0.4rem 0;
  }

  .tool-detail-btn {
    font-size: 0.9rem;
    padding: 0.3rem;
  }

  /* Mobile hover effects */
  .tool-card:hover {
    transform: translateY(-5px);
  }

  .tool-card:hover .tool-icon {
    transform: scale(1.03);
  }

  .tool-card:hover .tool-icon-img {
    transform: scale(1.05);
  }

  .app-footer {
    padding: 1.5rem 0;
  }

  .footer-content {
    gap: 0.75rem;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  .footer-copyright {
    font-size: 0.8rem;
  }
}

/* RTL Support */
[dir="rtl"] .app-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .brand {
  flex-direction: row-reverse;
}

[dir="rtl"] .header-actions {
  flex-direction: row-reverse;
}

[dir="rtl"] .tool-link {
  flex-direction: row-reverse;
}

[dir="rtl"] .tool-actions {
  flex-direction: row-reverse;
}

[dir="rtl"] .tool-detail-btn {
  transform: rotate(180deg);
}

[dir="rtl"] .instructions-content ol {
  padding-right: 1.5rem;
  padding-left: 0;
}

[dir="rtl"] .about-content ul {
  padding-right: 1.5rem;
  padding-left: 0;
}
