/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #1a1a1a;
  --color-accent: #4dd7e0;
  --color-background: #f5f5f5;
  --color-background-light: #ffffff;
  --color-text: #333333;
  --color-text-light: #666666;
  --color-border: #e0e0e0;
  --color-success: #4caf50;
  --color-danger: #f44336;
  --color-warning: #ff9800;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--color-background);
  color: var(--color-text);
  line-height: 1.6;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-primary) 0%, #2a2a2a 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--color-background-light);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 28px;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--color-text-light);
  font-size: 14px;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--color-text);
  font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(77, 215, 224, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* Button Styles */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-primary);
}

.btn-primary:hover {
  background-color: #3bc0c9;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--color-background);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

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

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

.btn-danger:hover {
  background-color: #e53935;
}

.btn-text {
  background: none;
  color: var(--color-text-light);
  padding: 8px 12px;
}

.btn-text:hover {
  color: var(--color-text);
}

.btn-full {
  width: 100%;
}

/* Error Messages */
.error-message {
  background-color: #ffebee;
  color: #c62828;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 15px;
  font-size: 14px;
  border-left: 4px solid var(--color-danger);
}

.success-message {
  background-color: #e8f5e9;
  color: #2e7d32;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 15px;
  font-size: 14px;
  border-left: 4px solid var(--color-success);
}

/* Admin App Layout */
.admin-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  background: var(--color-primary);
  color: white;
  padding: 15px 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.last-saved {
  font-size: 12px;
  opacity: 0.8;
}

/* Admin Container */
.admin-container {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--color-background-light);
  border-right: 1px solid var(--color-border);
  padding: 20px 0;
  flex-shrink: 0;
}

.nav-menu {
  list-style: none;
}

.nav-item {
  display: block;
  padding: 12px 20px;
  color: var(--color-text-light);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  font-size: 14px;
}

.nav-item:hover {
  background-color: var(--color-background);
  color: var(--color-text);
}

.nav-item.active {
  background-color: rgba(77, 215, 224, 0.1);
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: 500;
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.page-content {
  display: none;
}

.page-content.active {
  display: block;
  animation: fadeIn 0.2s;
}

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

/* Projects List */
#projectsList {
  display: grid;
  gap: 15px;
}

.project-card {
  background: var(--color-background-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.project-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

.project-card-info h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.project-card-info p {
  font-size: 12px;
  color: var(--color-text-light);
}

.project-card-actions {
  display: flex;
  gap: 10px;
}

.add-project-btn {
  margin-bottom: 20px;
}

/* Form Sections */
.form-section {
  margin-bottom: 30px;
}

.form-section h3 {
  font-size: 16px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-primary);
}

.form-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

/* Image Upload */
.image-upload {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#imagePreview {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: none;
}

#imagePreview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: flex-start;
  padding-top: 40px;
}

.modal-content {
  background: var(--color-background-light);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 900px;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--color-text-light);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  padding: 30px;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-footer > div {
  display: flex;
  gap: 10px;
}

/* Editor Sections */
.editor-section {
  background: var(--color-background-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-primary);
  user-select: none;
  background: #fafafa;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.section-header:hover {
  background: #f0f0f0;
}

.chevron {
  font-size: 12px;
  transition: transform 0.2s;
}

.chevron.rotated {
  transform: rotate(-90deg);
}

.section-body {
  padding: 18px;
  border-top: 1px solid var(--color-border);
}

.section-body.collapsed {
  display: none;
}

/* Bilingual columns */
.bilingual-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bilingual-row {
  margin-bottom: 14px;
}

.bilingual-row > label {
  margin-bottom: 6px;
}

.lang-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-light);
  text-transform: uppercase;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.ar-col input,
.ar-col textarea {
  direction: rtl;
  text-align: right;
}

.sub-item {
  padding: 12px;
  margin: 10px 0;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: var(--radius-sm);
}

.sub-item > strong {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--color-text-light);
}

/* Save bar */
.save-bar {
  position: sticky;
  top: 60px;
  z-index: 50;
  background: var(--color-background);
  padding: 12px 0;
  margin-bottom: 16px;
  text-align: right;
}

.save-btn {
  min-width: 180px;
}

/* Toast */
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  margin-bottom: 12px;
}

.toast.visible {
  opacity: 1;
}

.toast-success {
  background: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid var(--color-success);
}

.toast-error {
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid var(--color-danger);
}

/* Responsive Design */
@media (max-width: 900px) {
  .form-columns,
  .bilingual-columns {
    grid-template-columns: 1fr;
  }

  .admin-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-menu {
    display: flex;
    flex-wrap: wrap;
  }

  .nav-item {
    flex: 1;
    min-width: 150px;
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .nav-item.active {
    border-left: none;
    border-bottom-color: var(--color-accent);
  }
}

@media (max-width: 600px) {
  .header-content {
    flex-direction: column;
    gap: 10px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .content-area {
    padding: 15px;
  }

  .modal-content {
    width: 100%;
    margin: 0;
    border-radius: 0;
    max-height: 100%;
  }

  .modal-body {
    padding: 15px;
  }

  .project-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .project-card-actions {
    width: 100%;
    margin-top: 10px;
  }
}
