/* ============================================
   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;
  /* dense: ממלא חורים בפריסה אוטומטית כשיש ווידג'טים בגדלים שונים —
     מבטיח שהגדלים תמיד "נפרסים" יפה בלי רווחים מיותרים */
  grid-auto-flow: dense;
}

/* ── 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 ── */
.db-ctrls {
  position: absolute; top: 7px; left: 7px; z-index: 30;
  display: flex; gap: 4px;
}
.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: .6rem .85rem .4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.db-hdr h3 {
  margin: 0; font-size: .82rem; font-weight: 700;
  color: var(--primary);
  display: flex; align-items: center; gap: .35rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

/* ── Data elements ── */
.db-stat { font-size: 1.85rem; font-weight: 800; text-align: center; line-height: 1.1; }
.db-sub  { font-size: .72rem; color: var(--text-secondary); text-align: center; margin-top: .18rem; }
.db-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .22rem .4rem; background: var(--bg-primary);
  border-radius: 7px; margin-bottom: .25rem;
}
.db-row span { font-size: .73rem; color: var(--text-secondary); }
.db-row strong { font-size: .78rem; }
.db-prog { height: 7px; border-radius: 99px; background: var(--bg-primary); overflow: hidden; margin: .35rem 0; }
.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: .4rem; cursor: pointer;
  height: 100%; border-radius: 10px; transition: background .18s;
}
.db-launch:hover { background: var(--bg-primary); }
.db-launch i { font-size: 2rem; color: var(--primary); opacity: .55; }
.db-launch span { font-size: .78rem; font-weight: 600; color: var(--text-secondary); }

/* ── 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: 1.8rem; text-align: center; margin-bottom: .2rem; }
.db-greeting-text {
  font-size: .95rem; font-weight: 800; text-align: center; color: var(--text-primary); line-height: 1.3;
}
.db-greeting-name { color: var(--primary); }
.db-greeting-sub  { font-size: .7rem; color: var(--text-secondary); text-align: center; margin-top: .18rem; }

/* ── Weather widget ── */
.db-weather-temp { font-size: 2rem; font-weight: 800; text-align: center; }
.db-weather-desc { font-size: .72rem; color: var(--text-secondary); text-align: center; margin-top: .1rem; }
.db-weather-icon { font-size: 1.8rem; text-align: center; }

/* ── Quote widget ── */
.db-quote-text {
  font-size: .78rem; font-style: italic; color: var(--text-primary); line-height: 1.55;
  text-align: center; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 4; -webkit-box-orient: vertical;
}
.db-quote-author {
  font-size: .65rem; color: var(--text-secondary); text-align: center; margin-top: .35rem; font-weight: 600;
}

/* ── 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; }
  .dsp-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px)  { #dashboardGrid { grid-template-columns: repeat(2,1fr); grid-auto-rows: 120px; gap: 8px; } }

/* ── 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; }
