/* ============================================
   OmegaPharmacy - Beautiful Animations v2
   ============================================ */

/* ===== KEYFRAMES ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes popIn {
    0%   { opacity: 0; transform: scale(0.5); }
    70%  { transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.06); }
}
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-12px); }
}
@keyframes floatSlow {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50%       { transform: translateY(-18px) rotate(5deg); }
}
@keyframes rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes shimmer {
    0%   { left: -100%; }
    100% { left: 100%; }
}
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes glow {
    0%, 100% { box-shadow: 0 0 8px rgba(102,126,234,0.4); }
    50%       { box-shadow: 0 0 25px rgba(102,126,234,0.9), 0 0 40px rgba(118,75,162,0.5); }
}
@keyframes glowGreen {
    0%, 100% { box-shadow: 0 0 8px rgba(17,153,142,0.4); }
    50%       { box-shadow: 0 0 25px rgba(17,153,142,0.9), 0 0 40px rgba(56,239,125,0.5); }
}
@keyframes rippleOut {
    to { transform: scale(4); opacity: 0; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(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 heartbeat {
    0%, 100% { transform: scale(1); }
    14%       { transform: scale(1.15); }
    28%       { transform: scale(1); }
    42%       { transform: scale(1.15); }
    70%       { transform: scale(1); }
}
@keyframes typewriter {
    from { width: 0; }
    to   { width: 100%; }
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}
@keyframes waveBar {
    0%, 100% { transform: scaleY(0.4); }
    50%       { transform: scaleY(1); }
}
@keyframes particleFly {
    0%   { bottom: -60px; opacity: 0; transform: translateX(0) rotate(0deg); }
    10%  { opacity: 0.6; }
    90%  { opacity: 0.6; }
    100% { bottom: 110%; opacity: 0; transform: translateX(80px) rotate(360deg); }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes progressFill {
    from { width: 0%; }
    to   { width: var(--progress, 100%); }
}
@keyframes borderDance {
    0%   { border-color: #667eea; }
    25%  { border-color: #764ba2; }
    50%  { border-color: #11998e; }
    75%  { border-color: #38ef7d; }
    100% { border-color: #667eea; }
}
@keyframes iconBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    30%       { transform: translateY(-8px) scale(1.1); }
    60%       { transform: translateY(-3px) scale(1.05); }
}
@keyframes slideInModal {
    from { opacity: 0; transform: translateY(-60px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastSlide {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes skeleton {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

/* ===== PAGE LOAD ===== */
body {
    animation: fadeInUp 0.5s ease-out both;
}

/* ===== HEADER ===== */
.main-header {
    animation: fadeInDown 0.6s ease-out both;
    position: relative;
    overflow: hidden;
}
.main-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 3px;
    background: linear-gradient(90deg, #38ef7d, #667eea, #764ba2, #38ef7d);
    background-size: 200% 100%;
    animation: gradientShift 3s linear infinite;
}

/* ===== LOGO ===== */
.logo img {
    animation: float 4s ease-in-out infinite;
    transition: transform 0.3s ease;
}
.logo img:hover {
    animation: heartbeat 0.8s ease-in-out;
}

/* ===== NAV BUTTONS ===== */
.nav-btn {
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
.nav-btn::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    transform: translate(-50%,-50%);
    transition: width 0.5s, height 0.5s;
}
.nav-btn:hover::before { width: 200px; height: 200px; }
.nav-btn:hover { transform: translateY(-2px); }

/* ===== WELCOME SECTION ===== */
.welcome-section {
    animation: fadeInLeft 0.7s ease-out both;
}

/* ===== STAT CARDS ===== */
.stat-card {
    animation: fadeInUp 0.6s ease-out both;
    transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.12s; }
.stat-card:nth-child(3) { animation-delay: 0.19s; }
.stat-card:nth-child(4) { animation-delay: 0.26s; }
.stat-card:nth-child(5) { animation-delay: 0.33s; }
.stat-card:nth-child(6) { animation-delay: 0.40s; }
.stat-card:nth-child(7) { animation-delay: 0.47s; }

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
    transition: left 0.55s ease;
}
.stat-card:hover::before { left: 100%; }
.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 45px rgba(0,0,0,0.18);
}

/* ===== STAT ICONS ===== */
.stat-icon {
    transition: all 0.35s ease;
}
.stat-card:hover .stat-icon {
    animation: iconBounce 0.6s ease;
    transform: scale(1.15) rotate(8deg);
}

/* ===== STAT NUMBERS ===== */
.stat-number, .count-up {
    animation: countUp 0.8s ease-out both;
}

/* ===== ACTION BUTTONS (dashboard grid) ===== */
.action-btn {
    animation: scaleIn 0.5s ease-out both;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
.action-btn:nth-child(1) { animation-delay: 0.1s; }
.action-btn:nth-child(2) { animation-delay: 0.18s; }
.action-btn:nth-child(3) { animation-delay: 0.26s; }
.action-btn:nth-child(4) { animation-delay: 0.34s; }
.action-btn:nth-child(5) { animation-delay: 0.42s; }
.action-btn:nth-child(6) { animation-delay: 0.50s; }

.action-btn::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%,-50%);
    transition: width 0.5s, height 0.5s;
}
.action-btn:hover::after { width: 300px; height: 300px; }
.action-btn:hover {
    transform: translateY(-6px) scale(1.04);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}
.action-btn i {
    transition: transform 0.3s ease;
}
.action-btn:hover i {
    transform: scale(1.25) rotate(-8deg);
}

/* ===== QUICK ACTIONS SECTION ===== */
.quick-actions {
    animation: fadeInUp 0.7s 0.3s ease-out both;
}

/* ===== PAGE HEADER ===== */
.page-header {
    animation: fadeInDown 0.6s ease-out both;
}

/* ===== TABLE ROWS ===== */
table tbody tr {
    animation: fadeInLeft 0.4s ease-out both;
    transition: all 0.25s ease;
}
table tbody tr:nth-child(1)  { animation-delay: 0.05s; }
table tbody tr:nth-child(2)  { animation-delay: 0.10s; }
table tbody tr:nth-child(3)  { animation-delay: 0.15s; }
table tbody tr:nth-child(4)  { animation-delay: 0.20s; }
table tbody tr:nth-child(5)  { animation-delay: 0.25s; }
table tbody tr:nth-child(6)  { animation-delay: 0.30s; }
table tbody tr:nth-child(7)  { animation-delay: 0.35s; }
table tbody tr:nth-child(8)  { animation-delay: 0.40s; }
table tbody tr:nth-child(9)  { animation-delay: 0.45s; }
table tbody tr:nth-child(10) { animation-delay: 0.50s; }

table tbody tr:hover {
    transform: scale(1.01) translateX(4px);
    background: linear-gradient(90deg, #f0f4ff, #f8f9fa) !important;
    box-shadow: 0 3px 12px rgba(102,126,234,0.12);
}

/* ===== BUTTONS (general) ===== */
button, .btn, .btn-primary, .btn-submit, .btn-add, .btn-send {
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
button:hover, .btn:hover, .btn-primary:hover, .btn-submit:hover, .btn-add:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
button:active, .btn:active { transform: translateY(0) scale(0.97); }

/* Ripple on click */
button::after, .btn::after, .btn-primary::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 5px; height: 5px;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    transform: translate(-50%,-50%);
    transition: width 0.5s, height 0.5s, opacity 0.5s;
    opacity: 0;
}
button:active::after, .btn:active::after {
    width: 200px; height: 200px; opacity: 0;
}

/* ===== FLOATING BACK BUTTON ===== */
.btn-back {
    animation: bounceIn 0.8s 0.5s ease-out both;
    transition: all 0.3s ease;
}
.btn-back:hover {
    transform: translateY(-6px) scale(1.12) rotate(-5deg) !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3) !important;
    animation: glow 1.5s infinite;
}

/* ===== FORMS ===== */
.form-group {
    animation: fadeInUp 0.5s ease-out both;
}
.form-group:nth-child(1) { animation-delay: 0.05s; }
.form-group:nth-child(2) { animation-delay: 0.12s; }
.form-group:nth-child(3) { animation-delay: 0.19s; }
.form-group:nth-child(4) { animation-delay: 0.26s; }
.form-group:nth-child(5) { animation-delay: 0.33s; }

input:focus, select:focus, textarea:focus {
    transform: scale(1.01);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.2), 0 4px 12px rgba(102,126,234,0.15) !important;
    transition: all 0.3s ease;
}

/* ===== MODALS ===== */
.modal {
    backdrop-filter: blur(4px);
}
.modal-content {
    animation: slideInModal 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ===== MESSAGES ===== */
.message {
    animation: fadeInUp 0.4s ease-out both;
}
.message.sent .message-bubble {
    animation: fadeInRight 0.35s ease-out both;
}
.message.received .message-bubble {
    animation: fadeInLeft 0.35s ease-out both;
}
.message-bubble {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.message-bubble:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}

/* ===== BADGES ===== */
.badge, .stock-badge, .status-badge, .amount-badge {
    animation: popIn 0.5s ease-out both;
    transition: all 0.25s ease;
}
.badge:hover, .stock-badge:hover, .status-badge:hover {
    transform: scale(1.12);
}

/* ===== SALE ITEMS (history) ===== */
.sale-item {
    animation: fadeInLeft 0.5s ease-out both;
    transition: all 0.3s ease;
}
.sale-item:hover {
    transform: translateX(6px);
    box-shadow: 0 4px 18px rgba(0,0,0,0.1);
    border-left: 4px solid #11998e;
}

/* ===== MEDICINE ROW (sales form) ===== */
.medicine-row {
    animation: fadeInUp 0.4s ease-out both;
    transition: all 0.3s ease;
}
.medicine-row:hover {
    box-shadow: 0 4px 15px rgba(102,126,234,0.15);
    transform: translateY(-2px);
}

/* ===== SUMMARY BOX ===== */
.summary-box, .total-box {
    animation: scaleIn 0.6s ease-out both;
    position: relative;
    overflow: hidden;
}
.summary-box::before, .total-box::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
    animation: rotate 8s linear infinite;
}

/* ===== SUMMARY CARDS (reports) ===== */
.summary-card {
    animation: fadeInUp 0.6s ease-out both;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.summary-card:nth-child(1) { animation-delay: 0.1s; }
.summary-card:nth-child(2) { animation-delay: 0.2s; }
.summary-card:nth-child(3) { animation-delay: 0.3s; }
.summary-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.6s ease;
}
.summary-card:hover::before { left: 100%; }
.summary-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

/* ===== REPORT TABS ===== */
.tab-btn {
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
.tab-btn::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%;
    width: 0; height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: translateX(-50%);
    transition: width 0.3s ease;
    border-radius: 2px;
}
.tab-btn:hover::after, .tab-btn.active::after { width: 80%; }
.tab-btn:hover { transform: translateY(-3px); }
.tab-btn.active { animation: scaleIn 0.3s ease-out; }

/* ===== REPORT CONTENT ===== */
.report-content.active {
    animation: fadeInUp 0.5s ease-out both;
}

/* ===== SETTINGS CARDS ===== */
.settings-card {
    animation: fadeInUp 0.6s ease-out both;
    transition: all 0.3s ease;
}
.settings-card:nth-child(1) { animation-delay: 0.1s; }
.settings-card:nth-child(2) { animation-delay: 0.2s; }
.settings-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.12);
}

/* ===== USER ITEMS (settings) ===== */
.user-item {
    animation: fadeInLeft 0.5s ease-out both;
    transition: all 0.3s ease;
}
.user-item:hover {
    transform: translateX(5px);
    background: linear-gradient(90deg, #f0f4ff, #f8f9fa) !important;
    box-shadow: 0 3px 12px rgba(102,126,234,0.1);
}

/* ===== MESSAGES CONTAINER ===== */
.messages-container {
    animation: scaleIn 0.6s ease-out both;
}
.messages-header {
    animation: fadeInDown 0.5s ease-out both;
    position: relative;
    overflow: hidden;
}
.messages-header::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 60%);
    animation: rotate 10s linear infinite;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    animation: toastSlide 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ===== GRADIENT BACKGROUNDS ===== */
.gradient-admin {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}
.gradient-staff {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}

/* ===== FLOATING PILLS (index/login pages) ===== */
.pill {
    position: absolute;
    font-size: 28px;
    opacity: 0;
    animation: particleFly 14s infinite;
}
.pill:nth-child(1)  { left: 5%;  animation-delay: 0s;   animation-duration: 14s; }
.pill:nth-child(2)  { left: 15%; animation-delay: 2s;   animation-duration: 16s; }
.pill:nth-child(3)  { left: 28%; animation-delay: 4s;   animation-duration: 13s; }
.pill:nth-child(4)  { left: 42%; animation-delay: 1s;   animation-duration: 17s; }
.pill:nth-child(5)  { left: 58%; animation-delay: 3s;   animation-duration: 15s; }
.pill:nth-child(6)  { left: 72%; animation-delay: 5s;   animation-duration: 12s; }
.pill:nth-child(7)  { left: 88%; animation-delay: 2.5s; animation-duration: 18s; }

/* ===== LOGIN BOX ===== */
.login-box {
    animation: slideInModal 0.7s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ===== INDEX WELCOME ===== */
.welcome-container {
    animation: fadeInUp 0.9s ease-out both;
}
.logo-image {
    animation: float 4s ease-in-out infinite;
}
.login-btn {
    transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    overflow: hidden;
}
.login-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102,126,234,0.08), transparent);
    transition: left 0.5s ease;
}
.login-btn:hover::before { left: 100%; }
.login-btn:hover {
    transform: translateY(-10px) scale(1.03) !important;
    box-shadow: 0 20px 45px rgba(0,0,0,0.2) !important;
}

/* ===== SKELETON LOADING ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 400px 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: 6px;
}

/* ===== SCROLL REVEAL ===== */
.scroll-fade-in {
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.scroll-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== WAVE BARS (decorative) ===== */
.wave-bars {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}
.wave-bar {
    width: 4px;
    background: currentColor;
    border-radius: 2px;
    animation: waveBar 1s ease-in-out infinite;
}
.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.30s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }
.wave-bar:nth-child(5) { animation-delay: 0.60s; }

/* ===== RECENT SALES SECTION ===== */
.recent-sales-section {
    animation: fadeInUp 0.7s 0.2s ease-out both;
}
.btn-view-all {
    transition: all 0.3s ease;
}
.btn-view-all:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(17,153,142,0.35);
}

/* ===== SEARCH BOX ===== */
.search-box {
    animation: fadeInDown 0.5s ease-out both;
}
.search-box input:focus {
    box-shadow: 0 0 0 3px rgba(102,126,234,0.2), 0 4px 15px rgba(102,126,234,0.1) !important;
}

/* ===== TABLE CONTAINER ===== */
.table-container {
    animation: fadeInUp 0.6s 0.15s ease-out both;
}

/* ===== SUBMISSIONS CONTAINER ===== */
.submissions-container {
    animation: fadeInUp 0.6s 0.1s ease-out both;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    animation: fadeInUp 0.6s ease-out both;
}
.empty-state i {
    animation: float 3s ease-in-out infinite;
    display: block;
}

/* ===== MOBILE: reduce heavy animations ===== */
@media (max-width: 768px) {
    /* Stop continuous background animations */
    body { animation: none !important; }
    .gradient-admin, .gradient-staff { animation: none !important; }

    /* Stop floating logo */
    .logo img { animation: none !important; }
    .logo-image { animation: none !important; }

    /* Stop rotating radial overlays */
    .summary-box::before, .total-box::before,
    .messages-header::before { animation: none !important; }

    /* Stop gradient shimmer on header */
    .main-header::after { animation: none !important; }

    /* Stop floating pills */
    .pill { animation: none !important; opacity: 0 !important; }

    /* Simplify hover effects */
    .stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }
    .action-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0,0,0,0.15); }
    table tbody tr:hover { transform: none; box-shadow: none; }
    .sale-item:hover { transform: none; }
    .summary-card:hover { transform: translateY(-3px); }
    .settings-card:hover { transform: translateY(-2px); }

    /* Disable tilt (handled in JS but also guard here) */
    .stat-card, .summary-card, .settings-card {
        transform-style: flat !important;
    }

    /* Faster, simpler page load */
    .stat-card { animation-duration: 0.3s !important; }
    .action-btn { animation-duration: 0.3s !important; }
    .form-group { animation: none !important; }
    table tbody tr { animation: none !important; }

    /* No ripple expansion on mobile */
    .nav-btn::before { display: none !important; }
    .action-btn::after { display: none !important; }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
