/* ==========================================================================
   إعداد المتغيرات والألوان الرئيسية (هوية نباتية: أخضر طبيعي + وردي الزهور)
   ========================================================================== */
:root {
  --primary-color: #15803d; /* أخضر ورقي طبيعي */
  --primary-dark: #14532d;
  --primary-light: #bbf7d0;
  --secondary-color: #ec4899; /* وردي الزهور */
  --secondary-dark: #9d174d;
  --accent-color: #d97706; /* كهرماني دافئ لعناصر ثانوية */
  --bg-color: #f6fbf7; /* خلفية خضراء باهتة جداً */
  --card-bg: #ffffff;
  --text-main: #2d3748;
  --text-muted: #718096;
  --border-color: #e3f0e7;
  --danger-color: #e53e3e;
  --success-color: #38a169;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --transition-speed: 0.25s;
}

/* ==========================================================================
   الهيكل العام والتجاوبية
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Tajawal', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[class^="ph-"], [class*=" ph-"] {
  vertical-align: -2px;
  margin-left: 6px;
  line-height: 1;
}

body {
  direction: rtl;
  background: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   القائمة الجانبية (شريط التنقل)
   ========================================================================== */
.sidebar {
  width: 260px;
  background: var(--card-bg);
  border-left: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  transition: all var(--transition-speed) ease;
}

.logo {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  color: var(--primary-color);
  font-size: 20px;
  text-align: center;
  padding: 12px 8px;
  border-bottom: 2px dashed var(--primary-light);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar nav button {
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 12px 16px;
  text-align: right;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar nav button:hover {
  background: #eafbf0;
  color: var(--primary-color);
  transform: translateX(-4px);
}

.sidebar nav button.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.25);
}

/* ==========================================================================
   مساحة المحتوى
   ========================================================================== */
.content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.page {
  display: none;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  font-family: 'Cairo', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 24px;
  position: relative;
  padding-bottom: 8px;
  display: inline-block;
}

h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 50px;
  height: 4px;
  background: var(--primary-color);
  border-radius: 2px;
}

/* ==========================================================================
   البطاقات ولوحة المعلومات (Dashboard)
   ========================================================================== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
  width: 100%;
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(237, 242, 247, 0.6);
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-value {
  font-family: 'Cairo', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

canvas {
  background: var(--card-bg);
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
  max-height: 350px;
  width: 100% !important;
}

/* ==========================================================================
   النماذج والإدخال (Forms)
   ========================================================================== */
.employee-form, .settings-group {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  max-width: 550px;
  width: 100%;
  margin: 0 auto 24px;
  border: 1px solid rgba(237, 242, 247, 0.6);
}

.employee-form label, .settings-group label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.employee-form input,
.employee-form select,
.settings-group input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  font-size: 14px;
  transition: all var(--transition-speed) ease;
  background: #fcfcfd;
}

.employee-form input:focus,
.employee-form select:focus,
.settings-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.12);
}

/* ==========================================================================
   الأزرار وتفاعلاتها
   ========================================================================== */
button, .primary-btn {
  font-weight: 500;
  transition: all var(--transition-speed) ease;
}

.employee-form button, .settings-group button {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.18);
}

.employee-form button:hover, .settings-group button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(21, 128, 61, 0.3);
}

.secondary-btn {
  background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark)) !important;
  box-shadow: 0 4px 12px rgba(157, 23, 77, 0.18) !important;
}

.danger-btn {
  background: linear-gradient(135deg, var(--danger-color), #c53030) !important;
  box-shadow: 0 4px 12px rgba(229, 62, 98, 0.15) !important;
}

/* ==========================================================================
   مجموعات فئات المنتجات (لوحة الموظف)
   ========================================================================== */
.category-heading {
  font-family: 'Cairo', sans-serif;
  font-size: 17px;
  color: var(--primary-color);
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-light);
}

.category-group:first-child .category-heading {
  margin-top: 0;
}

/* ==========================================================================
   أزرار المنتجات والشبكات (Grid Buttons)
   ========================================================================== */
.flower-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

.flower-btn, .bundle-btn, .service-btn {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 18px 12px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 14px;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.flower-btn:hover, .bundle-btn:hover {
  background: #f0fdf4;
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  color: var(--primary-color);
}

.service-btn {
  background: #f7fafc;
  border: 1px dashed #cbd5e0;
}

.service-btn:hover {
  background: #edf2f7;
  border-color: #a0aec0;
  color: var(--text-main);
  transform: translateY(-3px);
}

/* ==========================================================================
   الفاتورة وتصميم الفواتير
   ========================================================================== */
.invoice-box {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  width: 100%;
}

#invoice-table {
  width: 100%;
  margin-bottom: 20px;
  border-collapse: collapse;
}

#invoice-table th {
  background: #f0fdf4;
  color: var(--primary-color);
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 2px solid var(--primary-light);
}

#invoice-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.invoice-summary {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.invoice-summary div {
  font-size: 15px;
  color: var(--text-muted);
}

.invoice-summary div strong {
  color: var(--text-main);
}

.invoice-final {
  font-family: 'Cairo', sans-serif;
  font-size: 20px !important;
  color: var(--primary-color) !important;
  font-weight: 700;
  margin-top: 6px;
}

/* ==========================================================================
   مودال ونافذة تقفيل الحساب اليومي
   ========================================================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card-bg);
  padding: 32px;
  border-radius: 20px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  text-align: center;
  border: 1px solid var(--border-color);
}

.modal-content h2 {
  color: var(--primary-color);
  margin-bottom: 16px;
}

/* ==========================================================================
   التوافقية وتصميم الهواتف الذكية والتكبير 150%
   ========================================================================== */

/* لتجنب فقدان الأيقونات أو الجزء العلوي عند تكبير الشاشة 150% */
@media (max-width: 1024px) or (max-height: 700px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    padding: 12px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
  }

  .logo {
    border-bottom: none;
    margin-bottom: 0;
    padding: 0;
    font-size: 18px;
  }

  .sidebar nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    width: auto;
    padding: 4px 0;
  }

  .sidebar nav button {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .content {
    padding: 20px 16px;
  }
}

@media (max-width: 600px) {
  .sidebar {
    flex-direction: column;
    gap: 12px;
  }

  .sidebar nav {
    width: 100%;
    justify-content: flex-start;
  }

  .cards {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .card {
    padding: 12px;
  }

  .card-value {
    font-size: 18px;
  }

  .flower-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }

  .flower-btn, .bundle-btn, .service-btn {
    padding: 14px 8px;
    font-size: 13px;
  }
}

/* تنسيق إضافي لحذف العناصر وتعديل حجم المبيعات */
.delete-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--danger-color);
  padding: 4px;
}

.settings-msg {
  text-align: center;
  font-weight: bold;
  margin-top: 8px;
}

/* التبويبات الأفقية لصفحة الإعدادات */
.settings-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 24px;
  width: 100%;
  overflow-x: auto;
}

.settings-tabs .tab-btn {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition-speed) ease;
  white-space: nowrap;
}

.settings-tabs .tab-btn:hover {
  background: #f7fafc;
  color: var(--text-main);
}

.settings-tabs .tab-btn.active {
  background: #f0fdf4;
  color: var(--primary-color);
  font-weight: 700;
}

/* محتوى التبويبات */
.tab-content {
  display: none;
  width: 100%;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

/* تنسيق قائمة إدارة المنتجات المضافة */
.products-list-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.product-list-item span {
  font-size: 15px;
}

/* ==========================================================================
   صفحة التكاليف والمصروفات
   ========================================================================== */

.costs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.costs-table thead {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
}

.costs-table th,
.costs-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}

.costs-table tbody tr:hover {
  background: var(--bg-color);
}

.cost-calc-hint {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(21, 128, 61, 0.1);
  margin: 6px 0 10px;
  min-height: 24px;
}

/* بطاقة الربح / الخسارة */
.profit-card {
  border-radius: 16px;
  padding: 24px 28px;
  text-align: center;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  margin: 16px 0;
}

.profit-positive {
  background: linear-gradient(135deg, #f0fff4, #c6f6d5);
  border-color: #2f855a;
}

.profit-negative {
  background: linear-gradient(135deg, #fff5f5, #fed7d7);
  border-color: #c53030;
}

.profit-card .profit-label {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.profit-card .profit-value {
  font-family: 'Cairo', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: inherit;
}

.profit-positive .profit-value { color: #2f855a; }
.profit-negative .profit-value { color: #c53030; }

/* بطاقات ملونة */
.card.card-green .card-value { color: #2f855a; }
.card.card-red .card-value { color: #c53030; }

/* زر صغير في الجداول */
.small-btn {
  padding: 4px 10px !important;
  font-size: 12px !important;
  width: auto !important;
  margin: 0 !important;
}

/* ==========================================================================
   صفحة الحضور والراتب
   ========================================================================== */

/* طبقة قفل الجهاز */
#device-lock-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-lock-box {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 40px 36px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.device-lock-box h2 {
  margin: 16px 0 12px;
  font-size: 1.3rem;
  color: var(--text-main);
}

.device-lock-box p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* شارة حالة الجهاز */
.device-status-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(47, 133, 90, 0.1);
  margin-bottom: 4px;
}

/* صفوف تقرير الراتب */
.salary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.salary-row.salary-deduction {
  color: #c53030;
}

.salary-row.salary-deduction strong {
  color: #c53030;
}

/* تبويبات الحضور */
.att-tab-btn { }

/* ==========================================================================
   تبويبات إعدادات الموظف والجهاز
   ========================================================================== */

#tab-employee-salary .summary-box,
#tab-device .summary-box {
  font-size: 14px;
}

#tab-device code {
  word-break: break-all;
}

