/* =====================================================
   MUNSHI – Global Animations
   ===================================================== */

/* --------------------------------------------------
   1. KEYFRAMES
   -------------------------------------------------- */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInSidebar {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60, 141, 188, 0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(60, 141, 188, 0); }
}

@keyframes ripple {
  from { transform: scale(0); opacity: 0.6; }
  to   { transform: scale(4); opacity: 0; }
}

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.3); }
  50%  { opacity: 1; transform: scale(1.05); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes slideInAlert {
  from { opacity: 0; transform: translateY(-12px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0);     max-height: 200px; }
}

@keyframes progressBar {
  from { width: 0%; }
  to   { width: var(--progress-target, 100%); }
}

/* --------------------------------------------------
   2. PAGE / CONTENT ENTRANCE
   -------------------------------------------------- */

/* Whole content wrapper fades in on load */
.content-wrapper {
  animation: fadeIn 0.45s ease both;
}

/* Main content section slides up */
.content-wrapper > .content {
  animation: fadeInUp 0.45s ease 0.05s both;
}

/* Page header fades down */
.content-header {
  animation: fadeInDown 0.4s ease both;
}

/* Auth page main area */
main.py-4 {
  animation: fadeInUp 0.5s ease both;
}

/* --------------------------------------------------
   3. CARDS / BOXES
   -------------------------------------------------- */

.card,
.box,
.info-box,
.small-box {
  animation: fadeInUp 0.5s ease both;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card:hover,
.box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

/* Stagger sibling cards */
.card:nth-child(1), .box:nth-child(1), .small-box:nth-child(1), .info-box:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2), .box:nth-child(2), .small-box:nth-child(2), .info-box:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3), .box:nth-child(3), .small-box:nth-child(3), .info-box:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4), .box:nth-child(4), .small-box:nth-child(4), .info-box:nth-child(4) { animation-delay: 0.20s; }
.card:nth-child(5), .box:nth-child(5), .small-box:nth-child(5), .info-box:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6), .box:nth-child(6), .small-box:nth-child(6), .info-box:nth-child(6) { animation-delay: 0.30s; }

/* Panel (Bootstrap 3 style used in auth views) */
.panel {
  animation: scaleIn 0.4s ease both;
  transition: box-shadow 0.25s ease;
}

/* --------------------------------------------------
   4. NAVBAR / TOPBAR
   -------------------------------------------------- */

.main-header,
.navbar {
  animation: fadeInDown 0.4s ease both;
}

/* Nav link hover underline slide */
.navbar-nav > li > a,
.nav-link {
  position: relative;
  transition: color 0.2s ease;
}

.navbar-nav > li > a::after,
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  right: 50%;
  height: 2px;
  background: currentColor;
  transition: left 0.25s ease, right 0.25s ease;
}

.navbar-nav > li > a:hover::after,
.nav-link:hover::after {
  left: 10%;
  right: 10%;
}

/* --------------------------------------------------
   5. SIDEBAR
   -------------------------------------------------- */

.main-sidebar {
  animation: fadeInLeft 0.4s ease both;
}

/* Sidebar nav items */
.nav-sidebar .nav-item {
  overflow: hidden;
}

.nav-sidebar .nav-link {
  transition: background 0.2s ease, padding-left 0.2s ease, color 0.2s ease;
}

.nav-sidebar .nav-link:hover,
.nav-sidebar .nav-link.active {
  padding-left: 20px !important;
}

/* Sidebar tree-view arrow rotation */
.nav-sidebar .nav-link[data-widget="treeview"] .right {
  transition: transform 0.25s ease;
}

/* Treeview open arrow */
.nav-sidebar .menu-open > .nav-link .right {
  transform: rotate(90deg);
}

/* --------------------------------------------------
   6. BUTTONS
   -------------------------------------------------- */

.btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Ripple span injected by animations.js */
.btn .btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  animation: ripple 0.55s linear;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  margin-left: -20px;
}

/* --------------------------------------------------
   7. TABLE ROWS
   -------------------------------------------------- */

table.dataTable tbody tr,
.table tbody tr {
  transition: background-color 0.2s ease, transform 0.15s ease;
}

table.dataTable tbody tr:hover,
.table tbody tr:hover {
  background-color: rgba(60, 141, 188, 0.07) !important;
  transform: scale(1.002);
}

/* --------------------------------------------------
   8. FORM INPUTS
   -------------------------------------------------- */

.form-control {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  box-shadow: 0 0 0 3px rgba(60, 141, 188, 0.2) !important;
}

/* Input group icon pulse on focus */
.input-group:focus-within .input-group-text,
.input-group:focus-within .input-group-addon {
  border-color: #3c8dbc;
  color: #3c8dbc;
  transition: border-color 0.2s ease, color 0.2s ease;
}

/* --------------------------------------------------
   9. FLASH MESSAGES / CALLOUTS
   -------------------------------------------------- */

.callout,
.alert {
  animation: slideInAlert 0.4s ease both;
  overflow: hidden;
}

/* --------------------------------------------------
   10. BREADCRUMBS
   -------------------------------------------------- */

.breadcrumb {
  animation: fadeInRight 0.45s ease both;
}

.breadcrumb-item {
  transition: color 0.2s ease;
}

/* --------------------------------------------------
   11. SMALL BOX (Dashboard stat boxes)
   -------------------------------------------------- */

.small-box {
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.small-box:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18) !important;
}

.small-box:hover .icon {
  transform: scale(1.15);
  transition: transform 0.3s ease;
}

.small-box .icon {
  transition: transform 0.3s ease;
}

/* --------------------------------------------------
   12. DROPDOWN MENUS
   -------------------------------------------------- */

.dropdown-menu {
  animation: scaleIn 0.2s ease both;
  transform-origin: top center;
}

/* --------------------------------------------------
   13. MODAL
   -------------------------------------------------- */

.modal.fade .modal-dialog {
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform: translateY(-30px);
  opacity: 0;
}

.modal.show .modal-dialog {
  transform: translateY(0);
  opacity: 1;
}

/* --------------------------------------------------
   14. SELECT2 DROPDOWN
   -------------------------------------------------- */

.select2-dropdown {
  animation: fadeInUp 0.2s ease both;
}

/* --------------------------------------------------
   15. SCROLL-REVEAL CLASS (applied by JS)
   -------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------
   16. LOADING OVERLAY (triggered by JS on form submit)
   -------------------------------------------------- */

.page-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease both;
}

.page-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #3c8dbc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* --------------------------------------------------
   17. WELCOME PAGE SPECIFIC
   -------------------------------------------------- */

.welcome-title {
  animation: bounceIn 0.8s ease both;
}

.welcome-links {
  animation: fadeInUp 0.6s ease 0.4s both;
}

.welcome-top-right {
  animation: fadeInRight 0.5s ease 0.2s both;
}

/* --------------------------------------------------
   18. NAVBAR BRAND
   -------------------------------------------------- */

.navbar-brand {
  transition: letter-spacing 0.3s ease, opacity 0.3s ease;
}

.navbar-brand:hover {
  letter-spacing: 0.5px;
  opacity: 0.85;
}

/* --------------------------------------------------
   19. FOOTER
   -------------------------------------------------- */

.main-footer {
  animation: fadeIn 0.5s ease 0.2s both;
}

/* --------------------------------------------------
   20. ICON TRANSITIONS (Font Awesome)
   -------------------------------------------------- */

.fas, .far, .fab, .fa {
  transition: transform 0.2s ease, color 0.2s ease;
}

.btn:hover .fas,
.btn:hover .far,
.btn:hover .fab,
.btn:hover .fa {
  transform: scale(1.15);
}

/* Sidebar icons */
.nav-sidebar .nav-link .nav-icon {
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-sidebar .nav-link:hover .nav-icon {
  transform: scale(1.2) rotate(-5deg);
  color: #fff;
}

/* --------------------------------------------------
   21. DATATABLE – SEARCH & PAGINATION TRANSITIONS
   -------------------------------------------------- */

.dataTables_filter input {
  transition: width 0.3s ease, box-shadow 0.2s ease;
  width: 160px;
}

.dataTables_filter input:focus {
  width: 220px;
  box-shadow: 0 0 0 3px rgba(60, 141, 188, 0.2);
}
