/* ============================================
   FinBot Dashboard Pro v4 — Stylesheet
   css/dashboard.css
   (קובץ CSS אמיתי — לא תבנית string בתוך JS)
   ============================================ */

/* ── Grid ── */
#dashboardGrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 148px;
  gap: 12px;
  /* אין grid-auto-flow:dense — ווידג'טים יושבים במיקום מפורש col/row שנקבע
     על-ידי המשתמש, לא נארזים אוטומטית על-ידי הדפדפן */
  position: relative;
}

/* ── Ghost תצוגת שחרור drag — כחול=פנוי, אדום=תפוס ── */
.db-drop-preview {
  border-radius: 14px; pointer-events: none; z-index: 50;
  transition: background .1s, border-color .1s;
}
.db-drop-ok  { border: 2.5px dashed #07747e; background: rgba(7,116,126,.1); animation: dbDropOkPulse 1.1s ease-in-out infinite; }
.db-drop-bad { border: 2.5px dashed #dc2626; background: rgba(220,38,38,.08); }
@keyframes dbDropOkPulse {
  0%,100% { background: rgba(7,116,126,.07); }
  50%      { background: rgba(7,116,126,.18); }
}

/* ── Widget card ── */
.db-w {
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
  transition: box-shadow .22s ease, border-color .22s ease, transform .18s ease;
  box-sizing: border-box;
  will-change: transform;
}
.db-w:hover { box-shadow: 0 8px 28px rgba(0,0,0,.12); transform: translateY(-1px); }
.db-w.db-edit { border-color: var(--primary); border-style: dashed; cursor: grab; }
.db-w.db-dragging { opacity: .22; transform: scale(.94); box-shadow: none; transition: none; }
.db-w.db-drop-target { border-color: var(--primary); background: rgba(7,116,126,.06); }

/* ── Icon-only size ── */
.db-w.db-icon-only {
  cursor: pointer;
  align-items: center; justify-content: center;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  overflow: visible;
}
.db-w.db-icon-only:not(.db-edit) { overflow: hidden; }
.db-icon-only-inner {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .45rem; width: 100%; height: 100%;
  padding: .5rem; box-sizing: border-box;
}
.db-icon-only-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.12);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.db-w.db-icon-only:hover .db-icon-only-icon {
  transform: scale(1.13) translateY(-2px);
  box-shadow: 0 10px 26px rgba(0,0,0,.28), 0 4px 10px rgba(0,0,0,.14);
}
.db-icon-only-label {
  font-size: .64rem; font-weight: 700;
  color: var(--text-primary);
  text-align: center; width: 100%; max-width: 80px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.2; letter-spacing: -.01em;
}

/* ── Locked widget (אין הרשאה) ── */
.db-w.db-locked {
  background: repeating-linear-gradient(135deg, var(--bg-secondary), var(--bg-secondary) 10px, var(--bg-primary) 10px, var(--bg-primary) 20px);
  border-style: dashed;
  opacity: .85;
}
.db-locked-inner {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .3rem; padding: .6rem; text-align: center;
}
.db-locked-inner i.fa-lock { font-size: 1.3rem; color: var(--text-secondary); opacity: .55; }
.db-locked-label { font-size: .76rem; font-weight: 700; color: var(--text-secondary); }
.db-locked-sub   { font-size: .62rem; color: var(--text-secondary); opacity: .8; }
.db-locked-remove {
  margin-top: .15rem; font-size: .64rem; font-weight: 700; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-primary); color: var(--danger,#dc2626);
  border-radius: 7px; padding: .18rem .55rem;
}

/* ── Ghost (drag placeholder) ── */
.db-ghost {
  border-radius: 16px;
  border: 2px dashed var(--primary);
  background: rgba(7,116,126,.08);
  animation: dGhostPulse 1.1s ease-in-out infinite;
}
@keyframes dGhostPulse {
  0%,100%{ background:rgba(7,116,126,.05); }
  50%{ background:rgba(7,116,126,.18); }
}

/* ── Edit controls ── */
/* ── Edit controls bar — תמיד ב-DOM, נראות נשלטת ב-CSS לפי .db-edit ── */
.db-ctrls {
  display: none;           /* מוסתר כברירת מחדל */
  gap: 5px; padding: 6px 8px 2px; flex-shrink: 0; align-items: center;
}
.db-w.db-edit > .db-ctrls,
.db-w.db-edit > .db-ctrls-sm { display: flex; } /* נראה רק כשיש .db-edit על הווידג'ט */
.db-btn {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .72rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: transform .14s, box-shadow .14s;
  backdrop-filter: blur(4px);
}
.db-btn:hover { transform: scale(1.16); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.db-btn-mv { background: rgba(255,255,255,.9); color: var(--primary); cursor: grab; }
.db-btn-sz { background: var(--primary); color: #fff; }
.db-btn-dl { background: #dc2626; color: #fff; }

/* ── Widget header ── */
.db-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .9rem .55rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.db-hdr h3 {
  margin: 0; font-size: .8rem; font-weight: 800;
  color: var(--primary);
  display: flex; align-items: center; gap: .4rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.005em;
}
.db-hdr h3 i {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7,116,126,.1); color: var(--primary); font-size: .72rem;
}

/* ── Widget body ── */
.db-body {
  flex: 1; padding: .7rem .9rem;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
}

/* ── Data elements ── */
.db-stat {
  font-size: 2rem; font-weight: 800; text-align: center; line-height: 1.1;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -.02em;
}
.db-sub  { font-size: .72rem; color: var(--text-secondary); text-align: center; margin-top: .3rem; font-weight: 600; }
.db-row {
  display: flex; justify-content: space-between; align-items: center;
  position: relative;
  padding: .5rem .65rem .5rem .8rem;
  background: var(--bg-primary);
  border-radius: 9px; margin-bottom: .35rem;
  transition: transform .14s ease, box-shadow .14s ease;
}
.db-row:last-child { margin-bottom: 0; }
.db-row::before {
  content: ''; position: absolute; top: .35rem; bottom: .35rem;
  inset-inline-start: .3rem; width: 3px; border-radius: 99px;
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  opacity: .55;
}
.db-row:hover { transform: translateX(-2px); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.db-row span { font-size: .74rem; color: var(--text-secondary); font-weight: 600; }
.db-row strong { font-size: .85rem; font-weight: 800; color: var(--text-primary); }
.db-prog { height: 8px; border-radius: 99px; background: var(--bg-primary); overflow: hidden; margin: .5rem 0; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.db-prog-f { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-hover)); transition: width .6s cubic-bezier(.4,0,.2,1); }
.db-launch {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .55rem; cursor: pointer;
  height: 100%; border-radius: 12px; transition: background .18s, transform .18s;
}
.db-launch:hover { background: var(--bg-primary); transform: translateY(-1px); }
.db-launch i {
  font-size: 1.5rem; color: #fff; opacity: 1;
  width: 46px; height: 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  box-shadow: 0 5px 14px rgba(7,116,126,.28);
}
.db-launch span { font-size: .78rem; font-weight: 700; color: var(--text-primary); }

/* ── Size picker ── */
.dsp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.dsp-card {
  border: 2px solid var(--border); border-radius: 12px; padding: .65rem .5rem;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .4rem;
  transition: all .18s; background: var(--bg-secondary);
}
.dsp-card:hover, .dsp-card.dsp-active {
  border-color: var(--primary); background: rgba(7,116,126,.07);
  transform: translateY(-2px); box-shadow: 0 5px 18px rgba(7,116,126,.14);
}
.dsp-prev {
  width: 100%; background: var(--bg-primary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.dsp-lbl  { font-size: .74rem; font-weight: 700; color: var(--text-primary); }
.dsp-hint { font-size: .64rem; color: var(--text-secondary); }

/* ── Quick calculator ── */
.qc-g { display: grid; grid-template-columns: repeat(4, 1fr); gap: .2rem; }
.qc-b {
  padding: .32rem 0; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-primary); cursor: pointer; font-size: .76rem; font-weight: 700;
  transition: all .12s;
}
.qc-b:hover { background: var(--primary); color: #fff; transform: scale(1.05); }

/* ── Clock widget ── */
.db-clock-time {
  font-size: 2.2rem; font-weight: 800; text-align: center; line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -.02em;
}
.db-clock-date {
  font-size: .72rem; color: var(--text-secondary); text-align: center; margin-top: .22rem; font-weight: 600;
}
.db-clock-day {
  font-size: .65rem; color: var(--text-secondary); text-align: center; margin-top: .08rem; opacity: .7;
}

/* ── Greeting widget ── */
.db-greeting-icon {
  font-size: 2.1rem; text-align: center; margin-bottom: .3rem; line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.08));
}
.db-greeting-text {
  font-size: .98rem; font-weight: 800; text-align: center; color: var(--text-primary); line-height: 1.35;
}
.db-greeting-name { color: var(--primary); font-weight: 900; }
.db-greeting-sub  { font-size: .72rem; color: var(--text-secondary); text-align: center; margin-top: .3rem; font-weight: 600; }

/* ── Weather widget ── */
.db-weather-temp {
  font-size: 2.1rem; font-weight: 800; text-align: center; line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.db-weather-desc { font-size: .74rem; color: var(--text-secondary); text-align: center; margin-top: .25rem; font-weight: 600; }
.db-weather-icon { font-size: 2rem; text-align: center; filter: drop-shadow(0 4px 10px rgba(0,0,0,.08)); }

/* ── Quote widget ── */
.db-quote-wrap { position: relative; padding: 0 .35rem; }
.db-quote-wrap::before {
  content: '\201C'; position: absolute; top: -1.1rem; inset-inline-start: -.3rem;
  font-size: 3.2rem; font-family: Georgia, 'Times New Roman', serif; font-weight: 800;
  color: var(--primary); opacity: .14; line-height: 1; pointer-events: none;
}
.db-quote-text {
  font-size: .82rem; font-style: italic; font-weight: 600; color: var(--text-primary); line-height: 1.6;
  text-align: center; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  position: relative;
}
.db-quote-author {
  font-size: .68rem; color: var(--primary); text-align: center; margin-top: .45rem; font-weight: 700;
}

/* ── Mini Calendar ── */
.db-cal-header { display: flex; justify-content: center; font-size: .72rem; font-weight: 700; margin-bottom: .25rem; color: var(--primary); }
.db-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.db-cal-cell {
  font-size: .6rem; text-align: center; padding: .18rem .05rem; border-radius: 4px;
  font-weight: 500; color: var(--text-secondary);
}
.db-cal-cell.db-cal-head { font-weight: 700; color: var(--primary); font-size: .56rem; }
.db-cal-cell.db-cal-today {
  background: var(--primary); color: #fff; border-radius: 50%;
  font-weight: 800;
}
.db-cal-cell.db-cal-other { opacity: .35; }

/* ── Widget library modal ── */
.dlib-cat {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-secondary); margin: .9rem 0 .4rem; padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.dlib-cat:first-child { margin-top: 0; }
.dlib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.dlib-item {
  border: 1.5px solid var(--border); border-radius: 11px; padding: .7rem .5rem;
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  cursor: pointer; transition: all .16s; background: var(--bg-secondary); text-align: center;
}
.dlib-item:hover { border-color: var(--primary); background: rgba(7,116,126,.06); transform: translateY(-2px); }
.dlib-item i { font-size: 1.2rem; color: var(--primary); }
.dlib-item span { font-size: .68rem; font-weight: 600; color: var(--text-primary); }

/* ── Responsive ── */
@media (max-width: 1100px) { #dashboardGrid { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 768px)  {
  #dashboardGrid {
    grid-template-columns: repeat(2,1fr); grid-auto-rows: 130px; gap: 10px;
    grid-auto-flow: dense;
  }
  .dsp-grid { grid-template-columns: repeat(2, 1fr); }
  .db-hdr { padding: .45rem .6rem .35rem; }
  .db-hdr h3 { font-size: .72rem; }
  .db-body { padding: .45rem .6rem; }
  .db-stat { font-size: 1.45rem; }
  .db-clock-time { font-size: 1.65rem; }
  .db-row { padding: .35rem .5rem .35rem .65rem; }
  .db-quote-text { font-size: .72rem; }
}
@media (max-width: 480px)  { #dashboardGrid { grid-template-columns: repeat(2,1fr); grid-auto-rows: 120px; gap: 8px; grid-auto-flow: dense; } }

/* ── Fade-in on add ── */
@keyframes dbFadeIn {
  from { opacity: 0; transform: scale(.93) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.db-w { animation: dbFadeIn .28s ease both; }
