/* ============================================================
   style.css — فورماب | نظام إدارة الأحداث والمهام
   Colors: #55cdcb (teal) | #984ea7 (purple) | #fbb531 (orange)
   ============================================================ */

/* === Variables ============================================= */
:root {
  --primary:       #55cdcb;
  --primary-dark:  #3abab8;
  --primary-light: #e0f9f9;
  --secondary:     #984ea7;
  --secondary-dark:#7a3a88;
  --secondary-light:#f0e8f5;
  --accent:        #fbb531;
  --accent-dark:   #e09f1a;
  --accent-light:  #fff4e0;
  --dark:          #1e293b;
  --dark-alt:      #273449;
  --body-bg:       #f0f4f8;
  --card-bg:       #ffffff;
  --text-main:     #1a202c;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --sidebar-w:     260px;
  --navbar-h:      60px;
  --radius:        10px;
  --shadow:        0 1px 4px rgba(0,0,0,.07);
  --shadow-md:     0 4px 16px rgba(0,0,0,.09);
}

/* === Reset & Base ========================================== */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif;
  background: var(--body-bg);
  color: var(--text-main);
  direction: rtl;
  margin: 0;
  overflow-x: hidden;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--secondary); }
img { max-width: 100%; }
h1,h2,h3,h4,h5,h6 { font-weight: 600; }

/* === Layout ================================================ */
.wrapper { display: flex; min-height: 100vh; }

/* === Sidebar =============================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1050;
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* Logo area */
.sidebar-logo {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-logo img { height: 36px; }
.sidebar-logo-text { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.3; }
.sidebar-logo-text small { color: rgba(255,255,255,.5); font-weight: 400; font-size: 11px; display: block; }

/* Nav groups */
.nav-group { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 20px 4px;
}
.nav-item { list-style: none; margin: 1px 10px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: rgba(255,255,255,.65);
  border-radius: 8px;
  font-size: 13px;
  transition: all .18s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.nav-link.active {
  color: var(--primary);
  background: rgba(85,205,203,.12);
  font-weight: 600;
}
.nav-link.active i { color: var(--primary); }
.nav-link i { font-size: 16px; flex-shrink: 0; opacity: .8; }
.nav-link .nav-badge {
  margin-right: auto;
  background: var(--accent);
  color: #1a202c;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.45); }

/* === Main Content ========================================== */
.main-content {
  margin-right: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Navbar ================================================ */
.topbar {
  height: var(--navbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-title small { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.btn-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-hamburger:hover { background: var(--body-bg); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  position: relative;
  transition: .15s;
}
.topbar-icon-btn:hover { background: var(--body-bg); color: var(--text-main); }
.notif-dot {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* === Page Content ========================================== */
.page-content {
  padding: 24px 20px;
  flex: 1;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 1.4rem;
  margin: 0;
  color: var(--text-main);
}
.page-header p {
  color: var(--text-muted);
  margin: 3px 0 0;
  font-size: 13px;
}

/* === Cards ================================================= */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
}
.card-header h5 { margin: 0; font-size: 14px; font-weight: 600; }
.card-header i { color: var(--primary); font-size: 18px; }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: transparent;
}

/* === Stat Cards =========================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  border-right: 4px solid;
  box-shadow: var(--shadow);
  transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.clr-primary   { border-right-color: var(--primary); }
.stat-card.clr-secondary { border-right-color: var(--secondary); }
.stat-card.clr-accent    { border-right-color: var(--accent); }
.stat-card.clr-dark      { border-right-color: var(--dark); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text-main); }
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  float: left;
  margin-right: 0;
  margin-left: 0;
}
.stat-card.clr-primary   .stat-icon { background: var(--primary-light); color: var(--primary-dark); }
.stat-card.clr-secondary .stat-icon { background: var(--secondary-light); color: var(--secondary-dark); }
.stat-card.clr-accent    .stat-icon { background: var(--accent-light); color: var(--accent-dark); }

/* === Buttons =============================================== */
.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  font-size: 13px;
  border-radius: 8px;
  padding: 7px 18px;
}
.btn-primary:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
.btn-secondary {
  background: var(--secondary) !important;
  border-color: var(--secondary) !important;
  color: #fff !important;
  font-size: 13px;
  border-radius: 8px;
}
.btn-accent {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #1a202c !important;
  font-size: 13px;
  border-radius: 8px;
  font-weight: 600;
}
.btn-outline-primary {
  border-color: var(--primary) !important;
  color: var(--primary-dark) !important;
  border-radius: 8px;
  font-size: 13px;
}
.btn-outline-primary:hover {
  background: var(--primary) !important;
  color: #fff !important;
}
.btn-sm { padding: 4px 12px !important; font-size: 12px !important; border-radius: 6px !important; }

/* === Tables ================================================ */
.table th {
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  padding: 10px 14px;
}
.table td { vertical-align: middle; padding: 10px 14px; font-size: 13px; }
.table-hover tbody tr:hover { background: #f8fdfd; }

/* === Forms ================================================= */
.form-label { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 5px; }
.form-control, .form-select {
  border-color: var(--border);
  border-radius: 8px;
  font-size: 13px;
  padding: 8px 12px;
  transition: border-color .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(85,205,203,.15);
}
.input-group-text {
  background: #f8fafc;
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 14px;
}
textarea.form-control { min-height: 100px; resize: vertical; }

/* === Badges ================================================ */
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.badge-role { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.badge-clr-primary   { background: var(--primary-light);   color: #077777; }
.badge-clr-secondary { background: var(--secondary-light); color: #5a1870; }
.badge-clr-accent    { background: var(--accent-light);    color: #8c5a00; }

/* === Avatars =============================================== */
.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  object-fit: cover;
}
.avatar-32  { width: 32px;  height: 32px;  font-size: 12px; }
.avatar-36  { width: 36px;  height: 36px;  font-size: 13px; }
.avatar-44  { width: 44px;  height: 44px;  font-size: 16px; }
.avatar-56  { width: 56px;  height: 56px;  font-size: 20px; }
.avatar-80  { width: 80px;  height: 80px;  font-size: 28px; }

/* === Priority & Status ==================================== */
.priority-high   { color: #dc3545; font-weight: 600; font-size: 12px; }
.priority-medium { color: #f59f0b; font-weight: 600; font-size: 12px; }
.priority-low    { color: #10b981; font-weight: 600; font-size: 12px; }
.overdue { color: #dc3545 !important; font-weight: 600; }

/* === Empty State =========================================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: .25; margin-bottom: 12px; display: block; }
.empty-state h5 { font-size: 15px; color: var(--text-muted); }

/* === Login Page =========================================== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #e0f9f9 0%, #f0e8f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
  overflow: hidden;
}
.login-header {
  padding: 32px 32px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.login-header img { height: 52px; margin-bottom: 12px; }
.login-header h2 { font-size: 1.2rem; margin: 0; color: var(--text-main); }
.login-header p { color: var(--text-muted); font-size: 13px; margin: 6px 0 0; }
.login-body { padding: 28px 32px 32px; }

/* === Sidebar overlay mobile ================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1049;
}

/* === Alerts ================================================ */
.alert { font-size: 13px; border-radius: var(--radius); }
.alert-success { background: var(--primary-light); border-color: var(--primary); color: #077777; }

/* === Responsive =========================================== */

/* ── Tablet (≤991px) ──────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(110%); /* يختبئ خارج الشاشة يميناً */
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -8px 0 32px rgba(0,0,0,.3);
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-right: 0; }
  .btn-hamburger { display: flex; align-items: center; justify-content: center; }
  .page-content { padding: 16px 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: 14px; }
  .topbar-title small { font-size: 10px; }
}

/* ── Mobile (≤767px) ──────────────────────────────────── */
@media (max-width: 767px) {
  /* Typography */
  html { font-size: 13px; }

  /* Layout */
  .page-content { padding: 12px 10px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h2 { font-size: 1.1rem; margin-bottom: 2px; }
  .page-header p { font-size: 12px; margin: 0; }
  .page-header > a,
  .page-header > .btn { align-self: flex-start; }

  /* Cards */
  .card { border-radius: 10px; }
  .card-body { padding: 14px 12px; }
  .card-header { padding: 11px 12px; }
  .card-header h5 { font-size: 13px; }
  .card-footer { padding: 10px 12px; }

  /* Stats */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 12px; border-radius: 10px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }
  .stat-icon { width: 34px; height: 34px; font-size: 16px; }

  /* Tables */
  .table th { font-size: 11px; padding: 8px 10px; white-space: nowrap; }
  .table td { font-size: 12px; padding: 8px 10px; }
  .table .btn-sm { padding: 3px 8px !important; font-size: 11px !important; }

  /* Forms */
  .form-label { font-size: 12px; margin-bottom: 4px; }
  .form-control, .form-select { font-size: 13px; padding: 8px 10px; min-height: 40px; }
  textarea.form-control { min-height: 80px; }

  /* Buttons — touch-friendly */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 30px !important; }

  /* Sidebar */
  .sidebar-logo { padding: 14px 16px; }
  .nav-link { padding: 10px 12px; font-size: 13px; }
  .sidebar-user-name { font-size: 12px; }

  /* Login */
  .login-wrap { padding: 12px; }
  .login-card { border-radius: 14px; max-width: 100%; }
  .login-body { padding: 20px 20px 24px; }
  .login-header { padding: 22px 20px 18px; }
  .login-header img { height: 44px; }
  .logo-ring { width: 68px; height: 68px; font-size: 26px; }

  /* First-login */
  .card-wrap { border-radius: 14px; }

  /* Topbar */
  .topbar { padding: 0 12px; height: 54px; }
  .topbar-title { font-size: 13px; }
  .topbar-title small { display: none; }

  /* Avatars */
  .avatar-80 { width: 64px; height: 64px; font-size: 22px; }

  /* Empty state */
  .empty-state { padding: 32px 16px; }
  .empty-state i { font-size: 36px; }

  /* Alerts */
  .alert { font-size: 12px; padding: 10px 12px; }

  /* Badge */
  .badge { font-size: 10px; padding: 2px 7px; }

  /* File widget */
  .file-widget .file-row { flex-wrap: wrap; }
  .file-widget .file-row input { font-size: 12px; }
}

/* ── Small phones (≤480px) ────────────────────────────── */
@media (max-width: 480px) {
  /* Layout */
  .page-content { padding: 10px 8px; }

  /* Stats — 2 per row, compact */
  .stat-grid { gap: 6px; }
  .stat-card { padding: 10px; border-radius: 8px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }

  /* Cards */
  .card-body { padding: 12px 10px; }
  .card-header { padding: 10px; gap: 6px; }
  .card-header h5 { font-size: 12px; }
  .card { border-radius: 8px; }

  /* Tables — compact */
  .table th { font-size: 10px; padding: 6px 8px; }
  .table td { font-size: 11px; padding: 6px 8px; }
  .table-responsive { -webkit-overflow-scrolling: touch; }

  /* Page header */
  .page-header h2 { font-size: 1rem; }
  .page-header > .btn { font-size: 12px; padding: 6px 12px; }

  /* Topbar */
  .topbar { padding: 0 10px; height: 50px; }
  .topbar-title { font-size: 12px; }

  /* Nav */
  .nav-link { padding: 9px 10px; font-size: 12px; }
  .nav-group-label { font-size: 9px; padding: 6px 16px 2px; }

  /* Login */
  .login-header { padding: 18px 16px 14px; }
  .login-body { padding: 16px 16px 20px; }
  .login-header h2 { font-size: 1rem; }
  .logo-ring { width: 58px; height: 58px; font-size: 22px; }

  /* Avatars */
  .avatar-56 { width: 48px; height: 48px; font-size: 18px; }
  .avatar-80 { width: 56px; height: 56px; font-size: 20px; }

  /* Sidebar */
  .sidebar-logo-text small { display: none; }
  .sidebar-footer { padding: 12px 14px; }

  /* Forms */
  .form-control, .form-select { padding: 7px 10px; font-size: 12px; }
  .form-text { font-size: 11px; }
  .input-group-text { font-size: 13px; padding: 6px 10px; }

  /* Action button groups in tables */
  .d-flex.gap-1.justify-content-center { gap: 3px !important; }

  /* Member selection cards in task form */
  .member-card { padding: 6px !important; }
  .member-card .fs-12 { font-size: 10px !important; }
  .member-card .fs-11 { font-size: 10px !important; }
}

/* ── Touch devices ────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets */
  .btn { min-height: 42px; }
  .btn-sm { min-height: 34px !important; }
  .nav-link { min-height: 44px; }
  .form-control, .form-select { min-height: 42px; }
  .form-check-input { width: 18px; height: 18px; }

  /* Remove hover effects on touch */
  .stat-card:hover { transform: none; box-shadow: var(--shadow); }
  .table-hover tbody tr:hover { background: transparent; }
}

/* ── Print ────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .page-header .btn { display: none !important; }
  .main-content { margin-right: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { border: 1px solid #ddd !important; box-shadow: none !important; }
}

/* === Utilities ============================================= */
.text-primary-brand { color: var(--primary-dark); }
.text-secondary-brand { color: var(--secondary); }
.text-accent-brand { color: var(--accent-dark); }
.bg-primary-brand { background: var(--primary); }
.border-primary { border-color: var(--primary) !important; }
.rounded-xl { border-radius: 12px !important; }
.gap-8 { gap: 8px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }