/* --------------------------------------------- */
/* 1. Reset + الأساسيات */
/* --------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&display=swap');

:root {
  --main-color: #0b3d91;
  --light-bg: #f7f9fb;
  --dark-bg: #1a1a1a;
  --dark-text: #eeeeee;
  --transition: 0.3s ease-in-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}


body {
  font-family: 'Amiri', serif;
  margin: 0;
  direction: rtl;
  background-color: var(--light-bg);
  color: #1a1a1a;
  transition: var(--transition);
  width: 100vw;
  max-width: 100vw;
  overflow-x: hidden;
  padding: 0;
}

/* --------------------------------------------- */
/* 2. الوضع الليلي */
/* --------------------------------------------- */
body.dark-mode {
  background-color: var(--dark-bg);
  color: var(--dark-text);
}

body.dark-mode aside,
body.dark-mode #editor,
body.dark-mode button,
body.dark-mode input,
body.dark-mode textarea {
  background-color: #202020;
  color: var(--dark-text);
}

body.dark-mode .file-tree li:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode button:hover {
  background-color: #082d6b;
}

body.dark-mode.show-sidebar aside {
  background-color: #2c2c2c;
}

body.dark-mode.show-sidebar aside input,
body.dark-mode.show-sidebar aside button {
  background-color: #1f1f1f;
  border-color: #444;
}

body.dark-mode #resizer {
  background-color: #444;
}

/* --------------------------------------------- */
/* 3. التخطيط العام */
/* --------------------------------------------- */



main {
  background-color: #044547; /* لون خلفية ناعم */
  padding: 20px;             /* تباعد داخلي مريح */
  min-height: calc(100vh - 70px); /* ارتفاع مناسب مع أخذ مساحة رأس الصفحة */
  box-sizing: border-box;    /* لضبط الحشو داخل العرض */
  border-radius: 8px;        /* زوايا مستديرة بسيطة */
  box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* ظل خفيف لجمالية */
}



.header-actions {
  display: flex;
  gap: 10px;
}

.theme-toggle {
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  background-color: var(--main-color);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
}

.toggle-sidebar {
  font-size: 14px;
  padding: 6px 10px;
  border: 2px solid var(--main-color); /* ← إضافة */
  border-radius: 6px;
  cursor: pointer;
  background-color: var(--main-color); /* ← نفس لون باقي الأزرار */
  color: white;
  transition: background-color 0.3s, border 0.3s;
  font-family: 'Amiri', serif;
  display: none;
}


.theme-toggle:hover,
.toggle-sidebar:hover {
  border-color: #d8dbdf;
  background: #014346;
}

.dark-mode .theme-toggle,
.dark-mode .toggle-sidebar {
  background-color: #333;
  color: white;
  border: 2px solid #444;
}

.dark-mode .theme-toggle:hover,
.dark-mode .toggle-sidebar:hover {
  background-color: #555;
  border-color: #555;
}



aside {
  width: 280px;
  min-width: 240px;
  background-color: #e9f0f9;
  border-left: 2px solid var(--main-color);
  padding: 1rem;
  overflow-y: auto;
  max-height: 100%;
  flex-shrink: 0;
  transition: var(--transition);
  box-sizing: border-box;
}

#editor {
  flex: 1;
  padding: 1.5rem;
  background-color: white;
  display: flex;
  flex-direction: column;
  overflow: auto;
  max-height: 100%;
  transition: var(--transition);
  box-sizing: border-box;
  margin-top: 0;
}

/* --------------------------------------------- */
/* 4. المحتوى الداخلي (buttons, inputs, lists) */
/* --------------------------------------------- */
aside input,
aside button,
#editor button,
button {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  font-size: 0.95rem;
  border-radius: 6px;
  border: none;
  font-weight: bold;
  cursor: pointer;
  font-family: 'Amiri', serif;
}

aside input {
  border: 1px solid #ccc;
}

aside button,
#editor button,
button {
  background-color: var(--main-color);
  color: white;
  border: 2px solid var(--main-color); /* ← إضافة حواف ملونة */
  transition: background 0.3s, border 0.3s;
}

aside button:hover,
#editor button:hover,
button:hover {
  background-color: #082d6b;
  border-color: #082d6b; /* ← تطابق لون الحافة مع الخلفية عند التحويم */
}

button:active {
  transform: scale(0.98);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--main-color);
  box-shadow: 0 0 5px rgba(11, 61, 145, 0.5);
}

.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.dialog-box {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  animation: fadeIn 0.3s ease;
}

.dialog-box h3 {
  margin-top: 0;
}

.dialog-box code {
  background: #eee;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.dialog-actions {
  margin-top: 20px;
  text-align: right;
}

.dialog-actions button {
  margin-left: 10px;
  padding: 8px 16px;
  cursor: pointer;
  border: none;
  border-radius: 6px;
}

.dialog-actions button:hover {
  opacity: 0.9;
}

.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.action-menu {
  position: relative;
  display: inline-block;
}

.action-menu-button {
  background: none;
  border: none;
  font-size: 18px;
  color: black;             /* ⬅️ الزر لونه أسود */
  cursor: pointer;
  float: left;             /* ⬅️ محاذاة لأقصى اليسار */
}


.action-menu-content {
  display: none;
  position: absolute;
  left: 100%;              /* 👈 تُعرض على يمين الزر */
  margin-left: 4px;        /* 👈 مسافة بسيطة من الزر */
  top: 0;   
  background-color: white;
  border: 1px solid #ccc;
  z-index: 1000;
  min-width: 120px;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  overflow: hidden;
}

.action-menu-content button {
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: right;
  cursor: pointer;
  font-size: 14px;
  font-family: 'Amiri', serif;     /* ⬅️ خط أميري */
  color: #1e3a8a;                  /* ⬅️ لون أيود (أزرق داكن) */
}


.action-menu-content button:hover {
  background-color: #f0f0f0;
}

.show-menu .action-menu-content {
  display: block;
}

.file-row,
.folder-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.projects-list {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 20px;
  justify-content: center;
}
.project-card {
  background: #fff;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  width: 250px;
  text-align: center;
  transition: transform 0.2s;
}
.project-card:hover {
  transform: translateY(-5px);
}
.project-actions button {
  margin: 5px;
  padding: 8px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.open-btn {
  background: #4CAF50;
  color: white;
}
.delete-btn {
  background: #f44336;
  color: white;
}


/* حاوية العمل الرئيسية */
#workspace {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 140px); /* تقريبًا لتناسب الشاشة مع وجود form */
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
  background: #f9f9f9;
}

/* الشجرة */
#fileList {
  flex-shrink: 0;    /* لا ينكمش */
  width: 300px;      /* عرض ثابت */
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  overflow-y: auto;
  padding: 8px;
  box-sizing: border-box;
  height: 100%;
}

/* المحرر */
#editor {
  flex-grow: 1;       /* يأخذ المساحة المتبقية */
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  display: flex;
  flex-direction: column;
  padding: 8px;
  box-sizing: border-box;
  height: 100%;
}
/*
main {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  margin-top: 56px;  نفس ارتفاع الشريط 
  height: calc(100vh - 70px);
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
*/
/* textarea CodeMirror تمديد ليملأ القسم */
.CodeMirror {
  flex-grow: 1;
  height: auto !important;
}

/* بعض التنسيقات العامة */
#createForm {
  margin: 10px;
  padding: 10px;
  background: white;
  border-radius: 6px;
  border: 1px solid #ddd;
  max-width: 650px;
  margin-left: auto;
  margin-right: auto;
  display: none;
}



    /* 🎨 تنسيقات خاصة بصفحة الترقية فقط */
    .upgrade-box {
      max-width: 700px;
      margin: auto;
      background: #fff;
      padding: 25px;
      border-radius: 12px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
      text-align: center;
    }
    .upgrade-box h2 {
      color: #f44336;
    }
    .upgrade-projects {
      margin-top: 20px;
    }
    .upgrade-project-card {
      background: #fafafa;
      border-radius: 8px;
      padding: 15px;
      margin-bottom: 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    }
    .upgrade-actions button {
      margin-left: 5px;
      padding: 6px 10px;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-size: 14px;
    }
    .btn-open {
      background: #4CAF50;
      color: white;
    }
    .btn-delete {
      background: #f44336;
      color: white;
    }
    .btn-upgrade {
      background: #2196F3;
      color: white;
      padding: 10px 20px;
      border-radius: 6px;
      text-decoration: none;
      display: inline-block;
      margin-top: 15px;
    }

  
  .folder > .children {
    display: none;
  }
  .folder.open > .children {
    display: block;
  }
  .folder-label,
  .file-label {
    flex: 1;
    padding-right: 8px;
    user-select: none;
  }
  .action-menu {
    position: relative;
  }
  .action-menu-content button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
  }
  .action-menu.show > .action-menu-content {
    display: block;
  }




main {
  border: 2px solid red;
}

aside {
  border: 2px solid green;
}

#editor {
  border: 2px solid blue;
}




  /* Editor */
  #editor-area {
    width: 100%;
    height: 60vh;
  }
  .editor-actions {
    margin-top: 8px;
  }

/* --------------------------------------------- */
/* 5. الشجرة */
/* --------------------------------------------- */
.file-tree {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 100%;
  overflow-y: auto;
  font-weight: bold;
}

.file-tree ul {
  list-style: none;
  padding-right: 16px;
  margin: 0;
}

.file-tree li {
  margin: 6px 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.file-tree li:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.folder-label::before { content: "\1F4C1  "; }
.file-label::before { content: "\1F4C4  "; }

.folder-label.selected-folder {
  background: var(--main-color);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
}


/* --------------------------------------------- */
/* 6. CodeMirror */
/* --------------------------------------------- */
.CodeMirror {
  height: 60vh !important;
  max-height: 80vh;
  min-height: 300px;
  font-size: 14px;
  direction: ltr;
  width: 100% !important;
  box-sizing: border-box;
}

#editor-area {
  height: 40vh;
}

/* --------------------------------------------- */
/* 7. الزخارف */
/* --------------------------------------------- */
.islamic-pattern {
  background-image: url('https://www.transparenttextures.com/patterns/arabesque.png');
  background-repeat: repeat;
  opacity: 0.04;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none;
  z-index: 0;
}

/* --------------------------------------------- */
/* 8. Resizer */
/* --------------------------------------------- */
#resizer {
  background-color: #ccc;
  position: relative;
  z-index: 10;
  width: 6px;
  cursor: col-resize;
}
/* New Edit */

main.container#maiin {
  background-color: #f0f0f0;
  padding: 20px;
  border: 2px solid #ccc;
  display: flex;           /* تفعيل flexbox */
  flex-direction: column;     /* ترتيب العناصر أفقيًا من اليسار إلى اليمين */
  gap: 10px;               /* مسافة بين العناصر (اختياري) */
}

#main-header {
  background-color: #0b3d91;
  padding: 15px 25px;
  color: white;
  font-family: 'Amiri', serif;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* الشريط العلوي */
#topBar {
  position: sticky;     /* 👈 مهم */
  top: 0;
  z-index: 9999;        /* 👈 أعلى من أي حاجة */
  display: flex;
  align-items: right;
  justify-content: space-between;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 16px;
  height: 56px;
}

#topBar #backBtn {
  background: none;
  border: none;
  width: 0;
  font-size: 22px;
  cursor: pointer;
  color: #0f766e;
}

.project-info {
  display: flex;          /* 👈 أهم سطر */
  align-items: center;    /* محاذاة رأسية */
  gap: 8px;               /* مسافة بين الاسم واللغة */
  white-space: nowrap;    /* 👈 يمنع النزول لسطر جديد */
  flex: 1;                /* ياخد المساحة المتبقية */
  justify-content: center;
}



#projectName {
  font-weight: bold;
  font-size: 16px;
  color: #064e3b;
}

#projectLang {
  font-size: 13px;
  color: #047857;
  opacity: 0.85;
}


