/* ——— الأساسيات ——— */
:root{
  --primary:#0d6efd;
  --success:#198754;
  --danger:#dc3545;
  --border:#ddd;
  --card-shadow:0 0 6px rgba(0,0,0,0.06);
  --bottom-bar-h:70px; /* ارتفاع الشريط السفلي */
}

*,
*::before,
*::after{ box-sizing: border-box; }

body {
  background-color: #f2f2f2;
  padding-top: 70px; /* مساحة لتفادي تغطية الـ header الثابت */
  /* لا padding-bottom افتراضيًا — نفعّله فقط عند ظهور الشريط */
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* يُفعَّل عند ظهور الشريط السفلي (أضف الكلاس من JS) */
body.has-bottom-nav{
  padding-bottom: calc(var(--bottom-bar-h) + env(safe-area-inset-bottom, 0px));
}

/* روابط عامة */
a {
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s ease;
}
a:hover { opacity: 0.9; }
a:focus-visible,
button:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ✅ كروت العملاء */
a.client-card-link { text-decoration: none; color: inherit; }

.client-card {
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: #fff;
  box-shadow: 0 0 5px #ccc;
  margin-bottom: 15px;
  padding: 15px;
  transition: transform .2s ease, background-color .2s ease;
}
.client-card:hover { transform: scale(1.02); background-color: #f9f9f9; }

.client-name {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 10px;
}
.card-header-title {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--primary);
}
.balance-value { font-weight: bold; font-size: 1.4rem; }
.last-date { font-size: 0.85rem; color: #555; margin-top: 5px; }

/* ✅ كروت الدفعات */
.payment-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: #fff;
  box-shadow: var(--card-shadow);
  margin-bottom: 15px;
  padding: 10px 15px;
  text-decoration: none !important;
  color: inherit;
  display: block;
  transition: transform .2s ease, background-color .2s ease;
}
.payment-card:hover { background-color: #f9f9f9; transform: scale(1.01); cursor: pointer; }

.payment-card .row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 0;
  border-bottom: 1px solid #eee; /* أضفنا الحد */
}
.payment-card .row-item:last-child { border-bottom: none; }

.payment-card .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.payment-card .row-item.text-center {
  justify-content: center;
}

/* ✅ كرت التعديل */
.edit-card {
  background-color: #fff;
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0 0 10px #ccc;
  max-width: 600px;
  margin: auto;
}
.edit-title {
  text-align: center;
  font-weight: bold;
  margin-bottom: 25px;
  color: var(--primary);
}

/* ✅ نمط النماذج */
label { font-weight: bold; }
.form-control, .form-select { font-size: 1rem; }
.btn { font-size: 1rem; }
.btn-sm { font-size: 0.85rem; padding: 4px 10px; }

/* ✅ الجداول */
table {
  background-color: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

/* ✅ التنبيهات */
.alert { font-size: 0.95rem; border-radius: 8px; }

/* ✅ الألوان */
.text-success { color: green !important; }
.text-danger  { color: red !important; }
.text-center  { text-align: center !important; }

/* ——— الشريط السفلي الثابت ——— */
.fixed-bottom-buttons {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  padding: 10px 15px calc(10px + env(safe-area-inset-bottom, 0px)); /* دعم النوتش */
  border-top: 1px solid #ccc;
  box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
  z-index: 1030; /* تحت المودال/الأوفرلاي وفوق المحتوى */
  display: flex;
  justify-content: space-between; /* توزيع الأزرار */
  gap: 10px;
  flex-wrap: nowrap; /* منع التفاف الأزرار لصف جديد */
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
}
.fixed-bottom-buttons .btn {
  flex: 1 1 0;       /* يجعل كل زر يتوسع بنفس العرض */
  min-width: 0;      /* يمنع تجاوز الحد الأدنى */
  max-width: 33%;    /* أقصى عرض لثلاثة أزرار */
  white-space: nowrap;
  text-align: center;
}

/* لجعل الأزرار لا تلتصق جدًا على الشاشات الصغيرة */
@media (max-width: 576px) {
  .fixed-bottom-buttons { padding: 8px 10px; gap: 8px; }
  .fixed-bottom-buttons .btn {
    font-size: 0.9rem;
    padding-left: 0.5rem; padding-right: 0.5rem;
  }
}

/* ✅ Lightbox لتكبير الصورة */
.lightbox-overlay {
  display: none;
  position: fixed;
  z-index: 12000; /* أعلى من الهيدر */
  inset: 0;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
}
.lightbox-overlay img {
  max-width: 90%; max-height: 90%;
  border-radius: 12px;
  box-shadow: 0 0 10px #000;
}
.lightbox-overlay .close-btn {
  position: absolute;
  top: 20px; right: 30px;
  font-size: 32px; color: #fff; cursor: pointer;
}

/* ✅ Result Overlay (Success & Error Messages) */
#resultOverlay {
  animation: fadeIn 0.4s ease;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  display: none; /* افتراضيًا مخفي */
  justify-content: center;
  align-items: center;
  z-index: 13000; /* فوق كل شيء */
  font-size: 1.5rem;
  text-align: center;
  padding: 30px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#resultMessage {
  background: #28a745;
  padding: 30px 40px;
  border-radius: 12px;
  box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

/* Error Message Style */
.error-style { background: #dc3545 !important; }

/* ✅ keyboard */
.keyboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 300px;
  margin-top: 10px;
  margin-inline: auto;
  padding: 10px;
  background-color: #f9f9f9;
  border-radius: 10px;
}
.keyboard button {
  padding: 15px;
  font-size: 20px;
  border-radius: 10px;
  border: 1px solid #ccc;
  background-color: #ffffff;
  transition: background .2s ease;
}
.keyboard button:hover { background-color: #e9ecef; }

/* ✅ الهيدر العلوي */
.fixed-top-bar {
  position: fixed;
  top: 0; left: 0; width: 100%;
  background: #fff;
  padding: 6px 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 10000;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.btn-group { display: flex; gap: 6px; }
.btn {
  font-size: 14px;
  padding: 5px 10px;
  border-radius: 6px;
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus { background-color: var(--primary); color: #fff; }
.btn-danger {
  font-size: 14px;
  padding: 5px 12px;
  border-radius: 6px;
  color: #fff;
  background-color: var(--danger);
  border: none;
  white-space: nowrap;
}
.btn-danger:hover, .btn-danger:focus { background-color: #bb2d3b; }
.user-logout-group {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px; min-width: 70px;
}
.user-name {
  font-weight: 700; color: #333;
  white-space: nowrap; font-size: 14px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .fixed-top-bar { padding: 6px 8px; font-size: 13px; gap: 6px; }
  .btn { padding: 5px 8px; font-size: 13px; }
  .btn-danger { padding: 5px 10px; font-size: 13px; }
  .user-logout-group { min-width: 60px; }
  .user-name {
    font-size: 13px; max-width: 100px;
    overflow: hidden; text-overflow: ellipsis; text-align: center;
  }
}

#refresh-indicator{
  display: none;
  position: fixed;
  top: 100px; left: 50%;
  transform: translateX(-50%);
  background: #eee;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
  z-index: 1010;
}

/* ✅  كارت الادخال اليومي */
.summary-card {
  font-size: 1.2rem;
  font-weight: bold;
  background-color: #e9f9f1;
  color: var(--success);
  padding: 1rem;
  border: 1px solid var(--success);
  border-radius: 0.5rem;
}
.summary2-card {
  font-size: 1.2rem;
  font-weight: bold;
  background-color: #fdecea;
  color: var(--danger);
  padding: 1rem;
  border: 1px solid var(--danger);
  border-radius: 0.5rem;
}

.op-machine { color: black; }
.op-withdraw { color: red; font-weight: bold; }
.op-transfer { color: green; font-weight: bold; }
.op-default { color: black; }

.machine-card {
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  padding: 15px;
  transition: box-shadow .3s ease;
}
.machine-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.machine-card .top-info { font-size: 1rem; font-weight: 600; color: var(--primary); }
.machine-card .btn-action { border-radius: 50px; padding: 4px 10px; font-size: 0.85rem; font-weight: 500; }
.machine-card .machine-name { font-size: 1.1rem; font-weight: bold; margin-top: 10px; }
.machine-card .daily-total { font-size: 1.2rem; font-weight: bold; color: var(--success); margin-top: 15px; }

/* تقليل الحركة للمستخدمين اللي مفاعلين Reduce Motion */
@media (prefers-reduced-motion: reduce){
  .client-card, .payment-card { transition: none; }
}
