/* style.css - واجهة MGD AI Worker */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --dark: #1e293b;
  --light: #f8fafc;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius: 12px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

/* الهيدر */
.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.header h1 {
  color: var(--dark);
  margin-bottom: 10px;
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header p {
  color: var(--secondary);
  font-size: 1.1rem;
}

/* التخطيط الرئيسي */
.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: 75vh;
}

/* الشريط الجانبي */
.sidebar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 25px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow-y: auto;
}

.sidebar-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar h3 {
  color: var(--dark);
  margin-bottom: 15px;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar h3 i {
  color: var(--primary);
}

/* منطقة الدردشة */
.chat-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: var(--light);
}

.message {
  max-width: 75%;
  padding: 15px 20px;
  border-radius: 20px;
  line-height: 1.6;
  position: relative;
  animation: fadeIn 0.3s ease-in;
}

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

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-bottom-right-radius: 5px;
}

.message.assistant {
  align-self: flex-start;
  background: white;
  color: var(--dark);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message-time {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 5px;
  text-align: left;
}

.chat-input-container {
  padding: 20px;
  border-top: 1px solid var(--border);
  background: white;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.chat-input-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 15px 20px;
  border: 2px solid var(--border);
  border-radius: 25px;
  outline: none;
  font-size: 1rem;
  resize: none;
  min-height: 60px;
  max-height: 120px;
  font-family: inherit;
  transition: border-color 0.3s;
}

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

.send-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* الأزرار */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

/* نموذج API Keys */
.api-key-form {
  background: var(--light);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--dark);
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.3s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

/* قائمة API Keys */
.api-key-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-key-item {
  background: var(--light);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: between;
  align-items: center;
}

.api-key-info {
  flex: 1;
}

.api-key-name {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 5px;
}

.api-key-provider {
  color: var(--secondary);
  font-size: 0.9rem;
}

.api-key-actions {
  display: flex;
  gap: 8px;
}

/* التبديل */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--success);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* المصادقة */
.auth-container {
  max-width: 400px;
  margin: 50px auto;
  background: rgba(255, 255, 255, 0.95);
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-tabs {
  display: flex;
  margin-bottom: 25px;
  background: var(--light);
  border-radius: 8px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s;
  font-weight: 500;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

/* التجاوب */
@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .sidebar {
    order: 2;
  }
  
  .chat-container {
    order: 1;
    height: 60vh;
  }
  
  .message {
    max-width: 85%;
  }
  
  .container {
    padding: 10px;
  }
}

/* التحميل */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* الأيقونات */
.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: currentColor;
  mask-size: cover;
}

.icon-send {
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.01 21L23 12 2.01 3 2 10l15 2-15 2z'/%3E%3C/svg%3E");
}

.icon-key {
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 2l-2 2-1.5-1.5L17 4 15 2l-1.5 1.5L15 5l-2 2 1.5 1.5L15 8l2-2 1.5 1.5L19 6l2 2-1.5 1.5L21 9l2-2-1.5-1.5L21 4l-2-2-1.5 1.5L19 3l-2 2-1.5-1.5zM10 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0-6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm0 7c-2.67 0-8 1.34-8 4v3h16v-3c0-2.66-5.33-4-8-4zm6 5H4v-1c0-1.1 2.24-2 5-2 1.5 0 2.76.34 3.68.89-.16.35-.28.72-.33 1.11H10z'/%3E%3C/svg%3E");
}
