/* ============================================================
   MGIOT Release Polish — v1.0
   Page transitions · card animations · button improvements
   Quote modal · finance buttons · sessions · general UX
   ============================================================ */

/* ── 1. PAGE TRANSITIONS ─────────────────────────────────── */
/* Override the old fadeIn with a smoother slide-up animation */
.view.active {
  display: block;
  animation: mg-page-in 0.28s cubic-bezier(0.22,0.61,0.36,1) both;
}
@keyframes mg-page-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 2. CARD ANIMATIONS ──────────────────────────────────── */
.mg-card {
  animation: mg-card-in 0.22s ease both;
}
@keyframes mg-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger card children */
.mg-stat-grid > *:nth-child(1) { animation-delay: 0.04s; }
.mg-stat-grid > *:nth-child(2) { animation-delay: 0.08s; }
.mg-stat-grid > *:nth-child(3) { animation-delay: 0.12s; }
.mg-stat-grid > *:nth-child(4) { animation-delay: 0.16s; }
.mg-stat-grid > *:nth-child(5) { animation-delay: 0.20s; }

.mg-stat {
  animation: mg-card-in 0.22s ease both;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.mg-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

/* ── 3. BUTTON ENHANCEMENTS ──────────────────────────────── */
.mg-btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, opacity 0.14s ease;
}
.mg-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.mg-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
}
.mg-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Ripple effect on click */
.mg-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.25);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s;
}
.mg-btn:active::after { opacity: 1; }

/* Primary button glow */
.mg-btn--primary {
  background: linear-gradient(135deg, #0F4D96 0%, #1565C0 100%);
  color: #fff;
  border: none;
  font-weight: 600;
}
.mg-btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0d4085 0%, #1255a8 100%);
  box-shadow: 0 4px 14px rgba(15,77,150,0.4);
}

/* Refresh / transfer buttons */
.mg-btn[onclick*="refresh"],
.mg-btn[onclick*="render"],
.mg-btn[onclick*="Refresh"],
button[title*="تحديث"],
button[title*="refresh"] {
  background: var(--mg-surface-soft, #f0f4fa);
  border: 1px solid var(--mg-border-soft, #d0d8e8);
  color: var(--mg-primary, #0F4D96);
  font-weight: 600;
}
.mg-btn[onclick*="refresh"]:hover,
.mg-btn[onclick*="render"]:hover,
button[title*="تحديث"]:hover {
  background: var(--mg-primary, #0F4D96);
  color: #fff;
}

/* ── 4. IMPROVED QUOTE MODAL ─────────────────────────────── */
#quoteModal .modal-card {
  max-width: 720px;
  border-radius: 16px;
  overflow: hidden;
}
#quoteModal .modal-hd {
  background: linear-gradient(135deg, #0F4D96, #1976D2);
  color: #fff;
  padding: 18px 24px;
  border-radius: 0;
}
#quoteModal .modal-hd h3 { color: #fff; font-size: 17px; margin: 0; }
#quoteModal .modal-x { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.1); border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 18px; }
#quoteModal .modal-x:hover { background: rgba(255,255,255,0.25); color: #fff; }

/* Quote form fields */
.quote-field-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.quote-label {
  font-size: 13px;
  font-weight: 700;
  color: #0F4D96;
  white-space: nowrap;
}
.quote-select,
.quote-input {
  border: 1.5px solid #d0d8e8;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.quote-select:focus,
.quote-input:focus {
  outline: none;
  border-color: #0F4D96;
  box-shadow: 0 0 0 3px rgba(15,77,150,0.12);
}

/* Quote item rows */
.quote-items-wrap { margin: 8px 0; }
.quote-items-hdr {
  display: grid;
  grid-template-columns: 3fr 80px 100px 90px 36px;
  gap: 6px;
  padding: 6px 8px;
  background: #EEF3FB;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #0F4D96;
  margin-bottom: 2px;
}
.quote-item-row {
  display: grid;
  grid-template-columns: 3fr 80px 100px 90px 36px;
  gap: 6px;
  align-items: center;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid #e8eef8;
  border-radius: 6px;
  margin-bottom: 4px;
  animation: mg-card-in 0.18s ease both;
  transition: background 0.15s;
}
.quote-item-row:hover { background: #f8fafe; }
.quote-item-row input,
.quote-item-row select {
  border: 1px solid #d0d8e8;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.quote-item-row input:focus,
.quote-item-row select:focus {
  outline: none;
  border-color: #0F4D96;
}
.quote-item-row .btn-danger,
.quote-item-row .btn-sm.btn-danger {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  transition: background 0.15s;
}
.quote-item-row .btn-danger:hover { background: #fca5a5; }

/* Quote add buttons */
.quote-btn-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.quote-btn-row .btn {
  border-radius: 8px;
  font-size: 13px;
  padding: 8px 14px;
  font-weight: 600;
  transition: all 0.15s;
}

/* Quote summary */
.quote-summary {
  background: linear-gradient(135deg, #f0f6ff, #e8f0fe);
  border: 1.5px solid #c7d9f5;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 12px 0;
}
.quote-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
  color: #444;
}
.quote-summary-grand {
  font-size: 17px;
  font-weight: 900;
  color: #0F4D96;
  padding-top: 10px;
  margin-top: 8px;
  border-top: 2px solid #c7d9f5;
}
.quote-stock-warn {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #e65100;
  margin: 8px 0;
}
.quote-divider { border: none; border-top: 1px solid #eef; margin: 10px 0; }

/* Save button in quote modal */
#quoteSaveBtn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 10px;
  background: linear-gradient(135deg, #0F4D96, #1976D2);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.18s;
}
#quoteSaveBtn:hover { background: linear-gradient(135deg, #0d4085, #1255a8); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(15,77,150,0.35); }

/* ── 5. FINANCE / TRANSFER BUTTONS ───────────────────────── */
/* Transfer button group */
.fin-action-row,
.mg-card-head .mg-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Transfer specific button */
.mg-btn[onclick*="Transfer"],
.mg-btn[onclick*="transfer"],
.mg-btn[onclick*="تحويل"] {
  background: linear-gradient(135deg, #1B5E20, #2E7D32);
  color: #fff;
  border: none;
  font-weight: 700;
}
.mg-btn[onclick*="Transfer"]:hover,
.mg-btn[onclick*="transfer"]:hover {
  background: linear-gradient(135deg, #154b18, #245f26);
  box-shadow: 0 4px 14px rgba(46,125,50,0.4);
}

/* ── 6. ACTIVE SESSIONS IMPROVEMENTS ────────────────────── */
.session-card {
  background: #fff;
  border: 1.5px solid #e0e8f5;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: mg-card-in 0.22s ease both;
  transition: box-shadow 0.18s;
}
.session-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.session-card-icon {
  font-size: 28px;
  min-width: 44px;
  text-align: center;
  background: #EEF3FB;
  border-radius: 10px;
  padding: 8px;
}
.session-card-info { flex: 1; min-width: 0; }
.session-card-user { font-weight: 700; font-size: 15px; color: #0F4D96; }
.session-card-meta { font-size: 12px; color: #888; margin-top: 2px; }
.session-card-actions { display: flex; gap: 6px; }

/* ── 7. TABLE ROW HOVER ANIMATION ───────────────────────── */
.mg-table tbody tr {
  transition: background 0.15s;
}
.mg-table tbody tr:hover { background: #f0f6ff; }

/* ── 8. BADGE ANIMATIONS ─────────────────────────────────── */
.mg-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  letter-spacing: 0.3px;
  animation: mg-badge-in 0.2s ease both;
}
@keyframes mg-badge-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── 9. LOADING ANIMATION IMPROVEMENT ───────────────────── */
.mg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: #0F4D96;
  font-weight: 600;
  font-size: 14px;
}
.mg-loading::before {
  content: '';
  width: 22px;
  height: 22px;
  border: 3px solid #c7d9f5;
  border-top-color: #0F4D96;
  border-radius: 50%;
  animation: mg-spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes mg-spin {
  to { transform: rotate(360deg); }
}

/* ── 10. TOAST IMPROVEMENTS ──────────────────────────────── */
.mg-toast {
  animation: mg-toast-in 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes mg-toast-in {
  from { opacity: 0; transform: translateX(60px) scale(0.92); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
.mg-toast--leaving {
  animation: mg-toast-out 0.2s ease both;
}
@keyframes mg-toast-out {
  to { opacity: 0; transform: translateX(60px); }
}

/* ── 11. MODAL ENTRANCE ANIMATION ────────────────────────── */
.modal-bg.show .modal-card,
.mg-modal-overlay .mg-modal {
  animation: mg-modal-in 0.25s cubic-bezier(0.34,1.2,0.64,1) both;
}
@keyframes mg-modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(-16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── 12. REQUESTS PAGE ───────────────────────────────────── */
.req-card {
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid #e0e8f5;
  padding: 14px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s;
  animation: mg-card-in 0.22s ease both;
}
.req-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.09);
  transform: translateY(-1px);
}
.req-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.req-card-type { font-size: 14px; font-weight: 700; color: #0F4D96; }
.req-card-user { font-size: 12px; color: #888; }
.req-card-body { font-size: 13px; color: #555; }
.req-card-line { margin-bottom: 3px; }
.req-card-note {
  margin-top: 8px;
  background: #f0f6ff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: #0F4D96;
}
.req-card-by { font-size: 11px; color: #999; margin-top: 4px; }
.req-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e8eef8;
}
.req-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s;
}
.req-btn--success { background: #e8f5e9; color: #2e7d32; }
.req-btn--success:hover { background: #2e7d32; color: #fff; }
.req-btn--danger { background: #fee2e2; color: #c62828; }
.req-btn--danger:hover { background: #c62828; color: #fff; }

/* ── 13. ASSIGNMENT HISTORY CARDS ────────────────────────── */
.asgnHist-card {
  background: #fff;
  border: 1.5px solid #e0e8f5;
  border-radius: 12px;
  padding: 16px;
  animation: mg-card-in 0.22s ease both;
  transition: box-shadow 0.18s;
}
.asgnHist-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

/* ── 14. SIDEBAR NAV ITEM HOVER ──────────────────────────── */
.nav-item {
  transition: background 0.15s, color 0.15s, padding-inline-start 0.15s;
  border-radius: 8px;
}
.nav-item:hover {
  background: rgba(15,77,150,0.08);
  padding-inline-start: 20px;
}
.nav-top-item {
  transition: background 0.15s, color 0.15s;
  border-radius: 8px;
}
.nav-top-item:hover { background: rgba(15,77,150,0.08); }

/* ── 15. OVERVIEW CARDS ──────────────────────────────────── */
.mg-info-box {
  transition: transform 0.18s, box-shadow 0.18s;
}
.mg-info-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

/* ── 16. SEARCH INPUT ────────────────────────────────────── */
.mg-search-input {
  transition: border-color 0.18s, box-shadow 0.18s;
}
.mg-search-input:focus {
  border-color: #0F4D96;
  box-shadow: 0 0 0 3px rgba(15,77,150,0.12);
  outline: none;
}

/* ── 17. PAYROLL TABLE ROW ───────────────────────────────── */
#viewPayroll .mg-table tbody tr:hover { background: #f0f6ff; }

/* ── 18. STOCK TRANSFER BUTTONS ──────────────────────────── */
.st-action-btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 14px;
  transition: all 0.15s;
  border: 1.5px solid currentColor;
}

/* ── 19. EMPTY STATE ANIMATION ───────────────────────────── */
.mg-empty {
  animation: mg-card-in 0.3s ease both;
}
.mg-empty-icon {
  font-size: 52px;
  display: block;
  text-align: center;
  margin-bottom: 12px;
  animation: mg-bounce 1.4s ease infinite;
}
@keyframes mg-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ── 20. SCROLLBAR STYLING ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7d9f5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #0F4D96; }

/* ── 21. FINANCE SUMMARY CARDS ───────────────────────────── */
.fin-summary-card {
  background: linear-gradient(135deg, #0F4D96 0%, #1976D2 100%);
  color: #fff;
  border-radius: 14px;
  padding: 20px 24px;
  animation: mg-card-in 0.25s ease both;
}
.fin-summary-card .mg-stat-value { color: #fff; font-size: 22px; }
.fin-summary-card .mg-stat-label { color: rgba(255,255,255,0.8); }

/* ── 22. RELEASE: GENERAL POLISH ────────────────────────── */
/* Smooth color transitions across the board */
* { scroll-behavior: smooth; }
input, select, textarea, button { font-family: inherit; }

/* Focus visible ring for accessibility */
:focus-visible {
  outline: 2px solid #0F4D96;
  outline-offset: 2px;
}

/* Better disabled state */
[disabled], .disabled { opacity: 0.5; pointer-events: none; }

/* Print improvements */
@media print {
  .sidebar, .main-header, .mg-btn, .nav-item { display: none !important; }
  .view.active { display: block !important; padding: 0 !important; }
}
