/* =====================================================
   نظام الطيبات - Manual Planner (Drag & Drop) v1
   إضافة لـ weekly-plan - الوضع اليدوي
   ===================================================== */

/* ===== Mode Toggle ===== */
.wp-mode-toggle {
  display: flex;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto 32px;
  background: rgba(255, 255, 255, 0.6);
  padding: 6px;
  border-radius: 100px;
  border: 1px solid rgba(201, 168, 76, 0.25);
}

.wp-mode-btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  background: transparent;
  border-radius: 100px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #5a6a5a;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.wp-mode-btn:hover {
  color: #1a3d2b;
}

.wp-mode-btn.active {
  background: linear-gradient(135deg, #1a3d2b, #2d5a3f);
  color: #faf8f2;
  box-shadow: 0 4px 12px rgba(26, 61, 43, 0.25);
}

.wp-mode-btn-icon {
  font-size: 1.1rem;
}

/* ===== Manual Builder Section ===== */
.wp-manual-section {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ===== Stats Bar ===== */
.wp-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.wp-stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  text-align: center;
  transition: all 0.3s;
}

.wp-stat-card.complete {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(22, 163, 74, 0.12));
  border-color: rgba(34, 197, 94, 0.3);
}

.wp-stat-card.warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(217, 119, 6, 0.12));
  border-color: rgba(245, 158, 11, 0.3);
}

.wp-stat-label {
  font-size: 0.8rem;
  color: #6a7a6a;
  margin-bottom: 6px;
  font-weight: 600;
}

.wp-stat-value {
  font-size: 1.6rem;
  font-weight: 900;
  font-family: 'Tajawal', sans-serif;
  color: #1a3d2b;
  line-height: 1;
}

.wp-stat-card.complete .wp-stat-value {
  color: #15803d;
}

.wp-stat-card.warning .wp-stat-value {
  color: #d97706;
}

.wp-stat-check {
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ===== Action Buttons ===== */
.wp-manual-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  justify-content: center;
}

.wp-mact-btn {
  padding: 12px 22px;
  border-radius: 12px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  color: #1a3d2b;
}

.wp-mact-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.wp-mact-btn-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  border-color: transparent;
}

.wp-mact-btn-ai {
  background: linear-gradient(135deg, #c9a84c, #b8973c);
  color: #fff;
  border-color: transparent;
}

/* ===== Builder Layout ===== */
.wp-builder-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

/* ===== Weekly Grid ===== */
.wp-grid {
  background: #f7f5f0;
  border-radius: 20px;
  padding: 8px;
  overflow-x: auto;
}

.wp-grid-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  min-width: 700px;
}

.wp-grid-th {
  background: linear-gradient(135deg, #1a3d2b, #2d5a3f);
  color: #faf8f2;
  padding: 12px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  border-radius: 8px;
  font-family: 'Tajawal', sans-serif;
}

.wp-grid-day-label {
  background: #fff;
  padding: 10px 8px;
  text-align: center;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1a3d2b;
  min-width: 90px;
  vertical-align: middle;
}

.wp-grid-day-tag {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 100px;
}

.wp-grid-day-tag.protein {
  background: rgba(217, 119, 6, 0.15);
  color: #b45309;
}

.wp-grid-day-tag.rest {
  background: rgba(21, 128, 61, 0.15);
  color: #15803d;
}

.wp-grid-day-tag.fasting {
  background: rgba(201, 168, 76, 0.2);
  color: #92710e;
}

.wp-grid-cell {
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  min-height: 90px;
  vertical-align: top;
  border: 1.5px dashed transparent;
  transition: all 0.2s;
}

.wp-grid-cell.drag-over {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.06);
}

.wp-grid-cell-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 78px;
  color: #b8b5ac;
  font-size: 0.75rem;
  text-align: center;
  cursor: pointer;
}

/* ===== Placed Item ===== */
.wp-placed {
  background: linear-gradient(135deg, #f0f9eb, #e3f5d6);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  position: relative;
  cursor: grab;
  transition: all 0.2s;
}

.wp-placed:active {
  cursor: grabbing;
}

.wp-placed.protein {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: rgba(217, 119, 6, 0.3);
}

.wp-placed-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #173404;
  margin-bottom: 2px;
  line-height: 1.3;
}

.wp-placed.protein .wp-placed-name {
  color: #78350f;
}

.wp-placed-meta {
  font-size: 0.65rem;
  color: #639922;
}

.wp-placed.protein .wp-placed-meta {
  color: #92710e;
}

.wp-placed-remove {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  color: #555;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.wp-placed:hover .wp-placed-remove {
  opacity: 1;
}

.wp-placed-remove:hover {
  background: #ef4444;
  color: #fff;
}

/* ===== Smart Alert ===== */
.wp-smart-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.06), rgba(22, 163, 74, 0.1));
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: #15803d;
}

.wp-smart-alert.warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(217, 119, 6, 0.1));
  border-color: rgba(245, 158, 11, 0.25);
  color: #b45309;
}

.wp-smart-alert-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ===== Recipe Library Sidebar ===== */
.wp-library {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 20px;
}

.wp-library-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #1a3d2b;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wp-library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.wp-lib-filter {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  color: #5a6a5a;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Tajawal', sans-serif;
}

.wp-lib-filter:hover {
  border-color: #1a3d2b;
}

.wp-lib-filter.active {
  background: #1a3d2b;
  color: #fff;
  border-color: #1a3d2b;
}

.wp-library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 600px;
  overflow-y: auto;
  padding-left: 4px;
}

.wp-lib-item {
  background: #f7f5f0;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: grab;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.wp-lib-item:hover {
  background: #fff;
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateX(-2px);
}

.wp-lib-item:active {
  cursor: grabbing;
}

.wp-lib-item-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a3d2b;
  margin-bottom: 4px;
}

.wp-lib-item-meta {
  display: flex;
  gap: 10px;
  font-size: 0.7rem;
  color: #7a8a7a;
}

.wp-lib-item-tag {
  padding: 1px 8px;
  border-radius: 100px;
  font-weight: 600;
}

.wp-lib-item-tag.protein {
  background: rgba(217, 119, 6, 0.15);
  color: #b45309;
}

.wp-lib-item-tag.rest {
  background: rgba(21, 128, 61, 0.15);
  color: #15803d;
}

/* ===== Empty State ===== */
.wp-manual-empty {
  text-align: center;
  padding: 40px 20px;
  color: #8a9a8a;
}

/* ===== Mobile ===== */
@media (max-width: 980px) {
  .wp-builder-layout {
    grid-template-columns: 1fr;
  }

  .wp-library {
    position: relative;
    top: 0;
    order: -1;
  }

  .wp-library-list {
    max-height: 280px;
  }
}

@media (max-width: 600px) {
  .wp-stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  .wp-mode-btn {
    padding: 12px 14px;
    font-size: 0.85rem;
  }

  .wp-mact-btn {
    padding: 10px 16px;
    font-size: 0.82rem;
  }
}

/* ===== Print (Manual mode) ===== */
@media print {
  .wp-mode-toggle,
  .wp-manual-actions,
  .wp-library,
  .wp-smart-alert {
    display: none !important;
  }

  .wp-builder-layout {
    grid-template-columns: 1fr;
  }
}
