/* =============================================
   דגלי יאיר ישראל — עיצוב יום העצמאות
   גרסה 3.0
   ============================================= */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --blue:       #0038b8;
  --blue-light: #1e5eff;
  --blue-dark:  #002299;
  --white:      #ffffff;
  --gold:       #f5c518;
  --green:      #006400;
  --green-light:#009900;
  --orange:     #b85000;
  --bg:         #eef2ff;
  --card-bg:    #ffffff;
  --text:       #1a1a2e;
  --text-muted: #666;
  --border:     #dde4ff;
  --shadow:     rgba(0,56,184,0.12);
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  font-family: 'Segoe UI', Arial, sans-serif;
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
}

/* ===== CONFETTI CANVAS ===== */
#confettiCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===== HEADER ===== */
.app-header {
  background: linear-gradient(135deg, #0038b8 0%, #003399 50%, #002277 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 3px 16px rgba(0,56,184,0.4);
}

/* Star of David decoration in header */
.app-header::after {
  content: '✡ ✡ ✡';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  font-size: 8px;
  text-align: center;
  opacity: 0.25;
  letter-spacing: 6px;
  padding-bottom: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flag-emoji { font-size: 26px; line-height: 1; }

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.header-sub {
  font-size: 11px;
  opacity: 0.75;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-btn, .dark-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.settings-btn:active, .dark-btn:active { background: rgba(255,255,255,0.3); }

/* ===== INDEPENDENCE DAY BANNER ===== */
.id-banner {
  background: linear-gradient(90deg, #0038b8, #003399, #0038b8);
  background-size: 200% 100%;
  animation: bannerScroll 4s linear infinite;
  color: white;
  text-align: center;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  letter-spacing: 0.5px;
  border-bottom: 3px solid var(--gold);
}

@keyframes bannerScroll {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

.id-flag { font-size: 18px; animation: flagWave 1.5s ease-in-out infinite alternate; }
.id-flag:last-child { animation-delay: 0.75s; }

@keyframes flagWave {
  from { transform: rotate(-8deg); }
  to   { transform: rotate(8deg); }
}

/* ===== STATS SECTION ===== */
.stats-section { padding: 14px 14px 0; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.stat-card {
  border-radius: 20px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 4px 18px var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '✡';
  position: absolute;
  top: 6px; left: 10px;
  font-size: 12px;
  opacity: 0.2;
}

.stock-card {
  background: linear-gradient(145deg, #0038b8, #1e5eff);
  color: white;
}

.money-card {
  background: linear-gradient(145deg, #005c00, #007a00);
  color: white;
}

.stat-label { font-size: 11px; opacity: 0.85; margin-bottom: 4px; font-weight: 600; letter-spacing: 0.3px; }
.stat-value { font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: -2px; }
.stat-sub   { font-size: 13px; opacity: 0.75; margin-top: 3px; }

/* ===== PROFIT BAR ===== */
.profit-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #e8fce8, #d0f5d0);
  border: 1.5px solid #7ddf7d;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  color: #1a4d1a;
  margin-bottom: 8px;
  font-weight: 600;
}
.profit-bar strong { font-size: 17px; font-weight: 900; color: #006600; }

/* ===== SOLD BAR ===== */
.sold-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 8px;
  color: var(--text-muted);
}
.sold-bar strong { color: var(--blue); font-weight: 700; }

/* ===== GOAL ROW ===== */
.goal-row {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 9px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.goal-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.goal-label span:first-child strong { color: var(--blue); }

.goal-bar-wrap {
  background: #dde4ff;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

.goal-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #ffaa00);
  border-radius: 99px;
  transition: width 0.5s ease;
  width: 0%;
}

.goal-bar.done {
  background: linear-gradient(90deg, #00cc44, #00ff66);
}

/* ===== STOCK PROGRESS ===== */
.progress-wrap {
  background: #dde4ff;
  border-radius: 99px;
  height: 7px;
  overflow: hidden;
  margin-bottom: 3px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  border-radius: 99px;
  transition: width 0.5s ease;
  width: 100%;
}

.progress-label {
  text-align: center;
  font-size: 11px;
  color: #888;
  margin-top: 3px;
  margin-bottom: 4px;
}

/* ===== SELL SECTION ===== */
.sell-section { padding: 16px 14px 6px; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.quick-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.sell-btn {
  border: none;
  border-radius: 22px;
  padding: 22px 10px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 5px 18px rgba(0,0,0,0.18);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* shimmer effect on sell buttons */
.sell-btn::after {
  content: '';
  position: absolute;
  top: -50%; left: -60%;
  width: 40%; height: 200%;
  background: rgba(255,255,255,0.15);
  transform: skewX(-20deg);
  transition: left 0.4s;
}
.sell-btn:active::after { left: 120%; }
.sell-btn:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.sell-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.sell-btn:disabled:active { transform: none; }

.btn-blue   { background: linear-gradient(145deg, #0038b8, #1e5eff); color: white; }
.btn-green  { background: linear-gradient(145deg, #006400, #009900); color: white; }
.btn-orange { background: linear-gradient(145deg, #b85000, #e06a00); color: white; }
.btn-whatsapp { background: linear-gradient(145deg, #128c7e, #25d366); color: white; }

.btn-count { font-size: 38px; font-weight: 900; line-height: 1; }
.btn-label { font-size: 12px; opacity: 0.9; font-weight: 600; }
.btn-price {
  font-size: 15px; font-weight: 700;
  background: rgba(255,255,255,0.22);
  padding: 3px 14px;
  border-radius: 99px;
  margin-top: 4px;
}

/* ===== UNDO BUTTON ===== */
.undo-btn {
  width: 100%;
  padding: 14px;
  border: 2px solid #f88;
  border-radius: 14px;
  background: var(--card-bg);
  font-size: 15px;
  font-weight: 700;
  color: #c00;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.undo-btn:not(:disabled):active { background: #fff3f3; border-color: #e00; }
.undo-btn:disabled { opacity: 0.35; cursor: default; border-color: #ddd; color: #aaa; }

/* ===== OUT OF STOCK ===== */
.out-of-stock-msg {
  margin: 0 14px 12px;
  background: linear-gradient(135deg, #fff0f0, #ffe0e0);
  border: 2px solid #f88;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #c00;
  animation: pulseRed 1.5s infinite;
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200,0,0,0.2); }
  50%       { box-shadow: 0 0 0 8px rgba(200,0,0,0); }
}

/* ===== HISTORY SECTION ===== */
.history-section { padding: 10px 14px 100px; }

.history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
}

.history-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.htab {
  flex: 1;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.htab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.clear-today-btn {
  background: #ff6b35;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.clear-today-btn:active { opacity: 0.8; }

/* ===== DAILY SUMMARY ===== */
.daily-summary {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border-radius: 14px;
  padding: 10px 6px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border-top: 3px solid var(--blue);
}

.summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.summary-item span { font-size: 10px; color: #888; }
.summary-item strong { font-size: 18px; font-weight: 800; color: var(--blue); }
.summary-divider { width: 1px; height: 32px; background: #eee; flex-shrink: 0; }

/* ===== HISTORY LIST ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-history {
  text-align: center;
  color: #aaa;
  font-size: 14px;
  padding: 30px 20px;
  background: var(--card-bg);
  border-radius: 14px;
  line-height: 1.8;
}
.empty-history small { font-size: 12px; }

.history-item {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  animation: slideIn 0.25s ease;
  border-right: 4px solid var(--blue);
}

.history-item.deal { border-right-color: var(--green); }
.history-item.undone { opacity: 0.38; text-decoration: line-through; background: #f5f5f5; border-right-color: #ccc; }
.history-item.other-day { border-right-color: #aaa; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.history-left { display: flex; flex-direction: column; gap: 2px; }
.history-time { font-size: 11px; color: #999; }
.history-date { font-size: 10px; color: #bbb; }
.history-desc { font-size: 15px; font-weight: 700; color: var(--text); }

.history-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.history-amount { font-size: 20px; font-weight: 900; color: #006600; }
.history-flags  { font-size: 11px; color: #888; }
.history-profit { font-size: 11px; color: #44aa44; font-weight: 600; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.modal-box {
  background: var(--card-bg);
  border-radius: 28px 28px 0 0;
  padding: 22px 18px 30px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-title {
  font-size: 20px; font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
  color: var(--text);
}

.modal-field { margin-bottom: 18px; }

.modal-field label {
  display: block;
  font-size: 13px; font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  direction: rtl;
}
.text-input:focus { border-color: var(--blue); }

.number-input-wrap {
  display: flex; align-items: center; gap: 10px; justify-content: center;
}

.num-btn {
  width: 52px; height: 52px;
  border: none; border-radius: 14px;
  background: #e8eeff;
  font-size: 26px; font-weight: 700;
  color: var(--blue); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.num-btn:active { background: #c0cfff; }

.number-input-wrap input {
  width: 100px; height: 52px;
  border: 2px solid var(--border);
  border-radius: 14px;
  text-align: center;
  font-size: 26px; font-weight: 700;
  color: var(--text); outline: none;
  background: var(--card-bg);
  -moz-appearance: textfield;
}
.number-input-wrap input::-webkit-outer-spin-button,
.number-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.number-input-wrap input:focus { border-color: var(--blue); }

.field-hint { font-size: 11px; color: #aaa; text-align: center; margin-top: 5px; }

.price-presets { display: flex; gap: 8px; margin-bottom: 12px; }

.preset-btn {
  flex: 1; padding: 10px 8px;
  border: 2px solid var(--border);
  border-radius: 12px; background: var(--card-bg);
  font-size: 14px; font-weight: 700;
  color: var(--blue); cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:active { background: var(--blue); color: white; border-color: var(--blue); }
.preset-deal { border-color: var(--green); color: var(--green); }
.preset-deal:active { background: var(--green); color: white; border-color: var(--green); }

.total-preview {
  text-align: center; font-size: 20px; font-weight: 800;
  color: var(--green);
  margin-top: 12px; padding: 12px;
  background: #f0fff0; border-radius: 14px;
}

.modal-actions { display: flex; gap: 12px; margin-top: 12px; }

.modal-cancel {
  flex: 1; padding: 16px;
  border: 2px solid #ddd; border-radius: 14px;
  background: var(--card-bg);
  font-size: 17px; font-weight: 700;
  color: var(--text-muted); cursor: pointer;
}
.modal-cancel:active { background: #f5f5f5; }

.modal-confirm {
  flex: 2; padding: 16px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  font-size: 18px; font-weight: 800;
  color: white; cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,56,184,0.35);
}
.modal-confirm:active { opacity: 0.85; }
.modal-confirm.danger { background: linear-gradient(135deg, #c00, #e00); box-shadow: 0 4px 15px rgba(200,0,0,0.3); }

.settings-toggles { margin-bottom: 16px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600;
  color: var(--text); cursor: pointer;
}
.toggle-row input[type=checkbox] { width: 20px; height: 20px; cursor: pointer; }

.danger-zone { margin-top: 16px; padding-top: 14px; border-top: 1px solid #eee; display: flex; gap: 8px; justify-content: center; }

.danger-btn {
  background: none; border: 2px solid #e00;
  color: #c00; border-radius: 12px;
  padding: 12px 20px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.danger-btn:active { background: #fff0f0; }

.export-btn {
  background: none; border: 2px solid var(--blue);
  color: var(--blue); border-radius: 12px;
  padding: 12px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.export-btn:active { background: #eef2ff; }
.import-lbl { cursor: pointer; }

.confirm-msg {
  text-align: center; font-size: 15px;
  color: var(--text-muted); margin-bottom: 20px; line-height: 1.7;
  white-space: pre-line;
}

/* ===== GOAL REACHED OVERLAY ===== */
.goal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,56,0.75);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.goal-popup {
  background: white;
  border-radius: 28px;
  padding: 32px 24px;
  text-align: center;
  max-width: 320px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.goal-popup-emoji { font-size: 52px; margin-bottom: 12px; }
.goal-popup-title { font-size: 26px; font-weight: 900; color: var(--blue); margin-bottom: 8px; }
.goal-popup-msg   { font-size: 16px; color: var(--text-muted); margin-bottom: 22px; line-height: 1.6; }

.goal-close-btn {
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  color: white; border: none; border-radius: 16px;
  padding: 16px 36px; font-size: 18px; font-weight: 800;
  cursor: pointer; width: 100%;
  box-shadow: 0 4px 15px rgba(0,56,184,0.35);
}

/* ===== TOAST ===== */
.toast-wrap {
  position: fixed;
  bottom: 24px; left: 12px; right: 12px;
  z-index: 900;
  display: flex; align-items: center; gap: 8px;
  animation: toastUp 0.3s ease;
}

@keyframes toastUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast {
  flex: 1;
  background: #1a1a2e;
  color: white;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}

.toast-undo {
  background: #ff4444;
  color: white; border: none; border-radius: 14px;
  padding: 14px 16px; font-size: 14px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(200,0,0,0.3);
}
.toast-undo:active { opacity: 0.85; }

/* ===== LOW STOCK WARNING ===== */
.stat-card.low-stock {
  background: linear-gradient(145deg, #c84b00, #e05500) !important;
  animation: pulseStat 1.5s infinite;
}

@keyframes pulseStat {
  0%, 100% { box-shadow: 0 4px 15px rgba(200,75,0,0.3); }
  50%       { box-shadow: 0 4px 28px rgba(200,75,0,0.7); }
}

/* ===== SAFE AREA ===== */
body { padding-bottom: env(safe-area-inset-bottom, 0); }

/* =============================================
   DARK MODE
   ============================================= */
body.dark {
  --bg:       #0a0a1a;
  --card-bg:  #141428;
  --text:     #e0e8ff;
  --text-muted: #7788bb;
  --border:   #1e2255;
  --shadow:   rgba(0,0,0,0.4);
}

body.dark .app-header { background: linear-gradient(135deg, #001044, #000c33); }
body.dark .id-banner  { background: linear-gradient(90deg, #001044, #000c33, #001044); }

body.dark .stock-card { background: linear-gradient(145deg, #001044, #001a77); }
body.dark .money-card { background: linear-gradient(145deg, #002200, #003300); }

body.dark .profit-bar { background: linear-gradient(135deg, #0a2a0a, #102010); border-color: #3a7a3a; color: #88dd88; }
body.dark .profit-bar strong { color: #66ff66; }

body.dark .sold-bar strong { color: #88aaff; }
body.dark .goal-bar-wrap { background: #1a1a3a; }
body.dark .progress-wrap  { background: #1a1a3a; }
body.dark .progress-label { color: #556; }

body.dark .daily-summary { border-top-color: #334; }
body.dark .summary-item span   { color: #556; }
body.dark .summary-item strong { color: #88aaff; }
body.dark .summary-divider     { background: #222; }

body.dark .history-item { box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
body.dark .history-item.undone { background: #0d0d1e; }
body.dark .history-desc  { color: #ccd; }
body.dark .history-time  { color: #445; }
body.dark .history-flags { color: #445; }
body.dark .history-amount { color: #44cc44; }
body.dark .history-profit { color: #55dd55; }
body.dark .empty-history  { color: #334; }

body.dark .num-btn { background: #0d0d3a; color: #88aaff; }
body.dark .number-input-wrap input { background: #0d0d2e; border-color: var(--border); color: var(--text); }
body.dark .text-input { background: #0d0d2e; border-color: var(--border); color: var(--text); }
body.dark .preset-btn { background: #0d0d3a; border-color: var(--border); color: #88aaff; }
body.dark .total-preview { background: #0d2a0d; color: #55ee55; }
body.dark .modal-cancel   { background: #0d0d2e; border-color: #223; color: #7788bb; }
body.dark .toggle-row { color: var(--text); border-color: var(--border); }
body.dark .goal-popup { background: #141428; }
body.dark .goal-popup-msg { color: #7788bb; }
body.dark .undo-btn { background: #1a0505; border-color: #553; color: #dd4444; }
body.dark .undo-btn:disabled { background: var(--card-bg); border-color: #222; color: #333; }
body.dark .htab { background: var(--card-bg); color: var(--text-muted); border-color: var(--border); }
body.dark .field-hint { color: #445; }
