:root {
  --bg: #ffffff;
  --text: #333333;
  --primary: #6200ee;
  --surface: #f5f5f5;
  --surface-hover: #e0e0e0;
  --shadow: rgba(0,0,0,0.1);
  --bg-color: #ffffff;
  --border-color: #dddddd;
  --text-color: #333333;
  --hover-color: #f5f5f5;
  --primary-color: #6200ee;
}

.dark-mode {
  --bg: #121212;
  --text: #ffffff;
  --primary: #bb86fc;
  --surface: #2d2d2d;
  --surface-hover: #3d3d3d;
  --shadow: rgba(255,255,255,0.1);
  --bg-color: #121212;
  --border-color: #333333;
  --text-color: #ffffff;
  --hover-color: #2d2d2d;
  --primary-color: #bb86fc;
}

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

html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap');

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.container {
  width: 100%;
  height: 90vh;
  max-width: 1200px;
  margin: 2rem auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  overflow-y: auto;
  position: relative;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 4px 6px var(--shadow);
}

.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px var(--shadow);
}

.nav-tabs {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.nav-tab {
  flex: 1;
  text-align: center;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 150px;
  max-width: 200px;
}

.section {
  display: none;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.section.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  height: calc(90vh - 200px);
  overflow-y: auto;
  align-items: center;
  justify-content: center;
}

.generated-content {
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
  background: var(--bg);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 1rem;
  color: var(--text);
  border: 1px solid var(--border-color);
}

.editor-container {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}

.text-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  position: relative;
}

.textarea {
  width: 100%;
  flex: 1;
  min-height: 200px;
  padding: 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.5;
  resize: none;
}

.notification-container {
  position: relative;
  width: 100%;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}

.notification {
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  font-size: 0.95rem;
  text-align: center;
  animation: slideIn 0.3s ease-out forwards;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(-10px);
  width: 100%;
}

.notification.success {
  background-color: var(--success-bg, #e8f5e9);
  color: var(--success-text, #2e7d32);
  border: 1px solid var(--success-border, #a5d6a7);
}

.notification.error {
  background-color: var(--error-bg, #ffebee);
  color: var(--error-text, #c62828);
  border: 1px solid var(--error-border, #ef9a9a);
}

.text-options {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tone-select,
.format-select {
  flex: 1;
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tone-select:hover,
.format-select:hover {
  background: var(--surface-hover);
}

.tone-select:focus,
.format-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-color, #6200ee25);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.action-buttons {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.share-buttons {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.theme-toggle, .autocomplete-toggle {
  background: var(--surface);
  border: none;
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: transform 0.2s, background-color 0.3s;
}

.theme-toggle:hover, .autocomplete-toggle:hover {
  background: var(--surface-hover);
  transform: scale(1.1);
}

.nav-tab.active {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.image-generation {
  margin-top: 2rem;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px var(--shadow);
}

#generation-section .editor-container {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}

#generation-section .prompt-textarea {
  width: 100%;
  flex: 1;
  min-height: 200px;
  padding: 1rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.5;
  resize: none;
  outline: none;
}

#generation-section .generated-content {
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
  background-color: var(--success-bg, #e8f5e9);
  border: 1px solid var(--success-border, #66bb6a);
  border-radius: 8px;
  color: var(--success-text, #2e7d32);
  font-size: 1.1rem;
  line-height: 1.5;
  min-height: 100px;
  display: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#generation-section .generated-content.show {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

/* Mobile Styles */
@media (max-width: 768px) {
  #generation-section .prompt-textarea {
    min-height: 150px;
    font-size: 1rem;
  }

  #generation-section .generated-content {
    min-height: 80px;
    font-size: 1rem;
    padding: 0.8rem;
  }

  /* Chat Styles */
  .chat-container {
    position: relative;
    height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
  }

  .chat-messages {
    max-height: 50vh;
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 80px;
    margin-bottom: 60px;
  }

  .chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    z-index: 9999;
    display: flex;
    gap: 0.8rem;
    align-items: center;
  }

  .chat-input {
    flex: 1;
    max-height: 100px;
    padding: 0.8rem 1rem;
    border-radius: 22px;
    font-size: 1rem;
    line-height: 1.4;
    background: var(--surface);
    border: none;
    resize: none;
  }

  .send-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .send-button .material-icons {
    font-size: 20px;
  }

  .message {
    margin-bottom: 1rem;
  }
}

.generated-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  max-height: calc(100vh - 300px);
  overflow-y: auto;
}

.generated-image {
  position: relative;
  width: 100%;
  height: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--background-light);
}

.generated-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.generated-image .loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.generated-image .error {
  color: var(--error);
  padding: 20px;
  text-align: center;
}

.action-button {
  background: var(--bg);
  border: none;
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  color: var(--text);
  position: relative;
}

.action-button:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.action-button::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px var(--shadow);
  z-index: 100;
}

.action-button:hover::after {
  opacity: 1;
  visibility: visible;
  bottom: -45px;
}

.progress-bar {
  display: none;
  width: 100%;
  height: 4px;
  background-color: var(--surface);
  border-radius: 4px;
  margin: 1rem 0;
  position: relative;
  overflow: hidden;
}

.progress-bar.active {
  display: block;
}

.progress-bar .progress {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background-color: var(--primary);
  animation: progressAnimation 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.progress-bar .progress-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.5rem;
  opacity: 0.8;
}

@keyframes progressAnimation {
  0% {
    width: 0%;
    opacity: 1;
  }
  50% {
    width: 100%;
    opacity: 0.5;
  }
  100% {
    width: 0%;
    opacity: 1;
  }
}

.button-with-progress {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.button-with-progress .progress-bar {
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 100%;
  height: 3px;
  margin: 0;
  border-radius: 2px;
}

.button-with-progress .progress-bar .progress {
  height: 100%;
  background-color: var(--primary);
}

.suggestions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 5px;
  min-height: 40px;
  width: 100%;
  position: relative;
  background: transparent;
}

.suggestion-item {
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  display: inline-block;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 0.3s forwards;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestion-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  filter: brightness(1.1);
}

.suggestion-text {
  white-space: nowrap;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .suggestions-container {
    gap: 6px;
    padding: 4px;
  }

  .suggestion-item {
    padding: 6px 12px;
    font-size: 0.9rem;
  }
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 70vh;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-messages {
  max-height: 50vh;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  font-size: 16px;
  line-height: 1.5;
  margin: 8px 0;
  border-radius: 8px;
  max-width: 85%;
  word-wrap: break-word;
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.message.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.ai {
  align-self: flex-start;
  background: var(--surface-hover);
  color: var(--text);
  border-bottom-left-radius: 4px;
  opacity: 0;
  transform: translateX(-20px);
  animation: slideInMessage 0.5s ease forwards;
}

.message.ai.lang-ar {
  font-family: 'DM Sans', sans-serif;
  background: linear-gradient(135deg, var(--surface-hover) 0%, #c34e4e 100%);
  border-right: 3px solid #2196F3;
  direction: rtl;
  text-align: right;
  padding: 12px 15px;
}

.message.ai.lang-en {
  background: linear-gradient(135deg, var(--surface-hover) 0%, #baf5bf 100%);
  border-right: 3px solid #4CAF50;
}

@keyframes slideInMessage {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.chat-input-container {
  padding: 16px;
  background: var(--surface-hover);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  max-height: 120px;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  resize: none;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

.send-button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.send-button:hover {
  transform: scale(1.05);
  background: var(--primary-hover);
}

.send-button:active {
  transform: scale(0.95);
}

.send-button .material-icons {
  font-size: 20px;
}

/* تنسيق شريط التمرير */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* تنسيقات خاصة بالموبايل */
@media (max-width: 768px) {
  body {
    align-items: flex-start;
  }

  .container {
    height: 95vh;
    margin: 1rem auto;
    padding: 1rem;
  }

  .section.active {
    height: calc(95vh - 180px);
  }

  .header {
    padding: 0.8rem;
    margin-bottom: 0.5rem;
  }

  .nav-tabs {
    padding: 0.3rem;
  }

  .nav-tab {
    min-width: calc(50% - 0.5rem);
    max-width: none;
    padding: 0.8rem;
  }
}

/* Touch Device Optimizations */
@media (hover: none) {
  * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }

  input, textarea {
    user-select: text;
  }
}
