/* ============================================================
   دفتر عمليات هيّاتك — التنسيقات (RTL، Mobile-First)
   ============================================================ */

/* ----------------------------- المتغيّرات ----------------------------- */
:root {
  --primary:        #0E7C86;
  --primary-dark:   #0A5F67;
  --primary-soft:   rgba(14, 124, 134, .10);

  --bg:             #F4F6F8;
  --surface:        #FFFFFF;
  --surface-2:      #FAFBFC;
  --border:         #E3E8EC;
  --text:           #17232B;
  --text-muted:     #64757F;

  --install:        #2563EB;
  --activate:       #16A34A;
  --deactivate:     #DC2626;
  --general:        #D97706;

  --danger:         #DC2626;
  --ok:             #16A34A;

  --radius:         14px;
  --radius-sm:      10px;
  --shadow:         0 1px 2px rgba(16,32,44,.06), 0 6px 18px rgba(16,32,44,.07);
  --shadow-lg:      0 8px 30px rgba(16,32,44,.16);

  --header-h:       58px;
  --font:           'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}

[data-theme="dark"] {
  --primary:        #22B3BE;
  --primary-dark:   #1A8F98;
  --primary-soft:   rgba(34, 179, 190, .14);

  --bg:             #0F171C;
  --surface:        #17222A;
  --surface-2:      #1D2A33;
  --border:         #2A3A45;
  --text:           #E7EEF2;
  --text-muted:     #94A7B3;

  --install:        #60A5FA;
  --activate:       #4ADE80;
  --deactivate:     #F87171;
  --general:        #FBBF24;

  --danger:         #F87171;
  --ok:             #4ADE80;

  --shadow:         0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  --shadow-lg:      0 8px 30px rgba(0,0,0,.5);
}

/* ----------------------------- أساسيات ----------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.35; }
p { margin: 0; }

a { color: var(--primary); text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ----------------------------- أزرار ----------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;               /* هدف لمس كبير */
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(14,124,134,.28);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-block { width: 100%; }

.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: 9px; }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: rgba(220,38,38,.10); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: 18px;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }

/* ----------------------------- تنبيهات ----------------------------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-err { background: rgba(220,38,38,.10); color: var(--danger); border-color: rgba(220,38,38,.25); }
.alert-ok  { background: rgba(22,163,74,.10);  color: var(--ok);     border-color: rgba(22,163,74,.25); }

/* ============================================================
   صفحة الدخول / الإعداد
   ============================================================ */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1000px 500px at 100% -10%, var(--primary-soft), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 30px 24px 22px;
}

.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo {
  width: 62px; height: 62px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  font-size: 30px;
  border-radius: 18px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
}
.auth-brand h1 { font-size: 21px; }
.auth-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

.auth-form { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   التطبيق
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.app-header .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 16px;
  margin-inline-end: auto;
  min-width: 0;
}
.app-header .brand .dot {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  flex: none;
}
.app-header .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.who {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 14px 90px;
}

/* ----------------------------- شريط الإحصائيات ----------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat .lbl { font-size: 11.5px; color: var(--text-muted); }
.stat.is-today .num { color: var(--primary); }

/* ----------------------------- لوحة الإدخال ----------------------------- */
.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.mic-btn {
  width: 100%;
  min-height: 62px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(14,124,134,.32);
  transition: transform .1s ease, filter .15s ease;
}
.mic-btn:active { transform: scale(.99); }
.mic-btn[disabled] { filter: grayscale(.6); opacity: .7; cursor: not-allowed; box-shadow: none; }

.mic-btn.is-recording {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  box-shadow: 0 6px 20px rgba(220,38,38,.35);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(220,38,38,.35); }
  50%      { box-shadow: 0 6px 30px rgba(220,38,38,.65); }
}
@media (prefers-reduced-motion: reduce) {
  .mic-btn.is-recording { animation: none; }
}

.mic-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 20px;
}
.mic-hint.is-error { color: var(--danger); }

.composer textarea {
  margin-top: 12px;
  min-height: 92px;
  resize: vertical;
  line-height: 1.7;
}

.composer-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.composer-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}
.composer-actions .btn-primary { flex: 1; }

/* ----------------------------- البحث والفلاتر ----------------------------- */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 14px;
}
.toolbar .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.toolbar .row + .row { margin-top: 10px; }

.search-wrap { position: relative; }
.search-wrap .input { padding-inline-start: 38px; }
.search-wrap::before {
  content: "🔍";
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: .6;
  pointer-events: none;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.tab .count {
  font-size: 11.5px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 20px;
  padding: 1px 7px;
  font-weight: 700;
}

/* ----------------------------- بطاقات النوتات ----------------------------- */
.notes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.note {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 5px solid var(--type-color, var(--general));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 15px 12px;
  transition: box-shadow .15s ease, transform .1s ease;
}
.note:hover { box-shadow: var(--shadow-lg); }

.note[data-type="install"]    { --type-color: var(--install); }
.note[data-type="activate"]   { --type-color: var(--activate); }
.note[data-type="deactivate"] { --type-color: var(--deactivate); }
.note[data-type="general"]    { --type-color: var(--general); }

.note.is-done { opacity: .72; }
.note.is-done .note-text { text-decoration: line-through; text-decoration-thickness: 1px; }

.note.is-today {
  box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow);
  background:
    linear-gradient(180deg, var(--primary-soft), transparent 60px),
    var(--surface);
}

.note-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.note-client {
  font-weight: 700;
  font-size: 15.5px;
  margin-inline-end: auto;
  word-break: break-word;
}
.note-client.is-empty { color: var(--text-muted); font-weight: 600; }

.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  color: #fff;
  background: var(--type-color, var(--general));
  white-space: nowrap;
}
.badge-today {
  background: var(--primary);
  color: #fff;
}
.badge-done {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.note-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 9px;
}
.note-meta .m { display: inline-flex; align-items: center; gap: 4px; }

.note-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ----------------------------- حالات فارغة ----------------------------- */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty .emo { font-size: 42px; display: block; margin-bottom: 10px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 13.5px; }

.loading {
  text-align: center;
  padding: 34px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ----------------------------- إشعار عائم ----------------------------- */
.toast {
  position: fixed;
  bottom: 18px;
  inset-inline-start: 50%;
  transform: translateX(50%) translateY(140%);
  background: var(--text);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: transform .25s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.is-show { transform: translateX(50%) translateY(0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ----------------------------- نافذة تأكيد ----------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 14, 20, .55);
}
.modal.is-open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.modal-card h3 { font-size: 17px; margin-bottom: 8px; }
.modal-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ----------------------------- شاشات أكبر ----------------------------- */
@media (min-width: 700px) {
  .composer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
  .toolbar .row  { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .stats         { gap: 12px; }
  .notes         { grid-template-columns: repeat(2, 1fr); }
  .container     { padding: 20px 20px 90px; }
}

@media (min-width: 1024px) {
  .notes { grid-template-columns: repeat(3, 1fr); }
}
