/* ============================================================
   CommessaTrack — Custom CSS
   Used alongside Tailwind CSS CDN
   ============================================================ */

/* -------------------------------------------------------
   Custom Animations
------------------------------------------------------- */

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

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

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulseRing {
    0%   { box-shadow: 0 0 0 0 currentColor; }
    70%  { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

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

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

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

/* -------------------------------------------------------
   Progress Bar
------------------------------------------------------- */

.progress-bar-fill {
    animation: progressFill 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.progress-bar-shimmer {
    background: linear-gradient(
        90deg,
        transparent    0%,
        rgba(255,255,255,0.35) 50%,
        transparent    100%
    );
    background-size: 200% 100%;
    animation: shimmer 2.4s linear infinite;
}

/* -------------------------------------------------------
   Fade / Slide Utilities
------------------------------------------------------- */

.fade-in   { animation: fadeIn      0.45s ease-out forwards; }
.fade-scale { animation: fadeInScale 0.3s  ease-out forwards; }

.slide-right { animation: slideInRight 0.3s ease-out forwards; }
.slide-left  { animation: slideInLeft  0.3s ease-out forwards; }

/* Stagger children */
.stagger-children > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2)  { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-children > * { opacity: 0; animation: fadeIn 0.4s ease-out forwards; }

/* -------------------------------------------------------
   State Cards (drag-and-drop)
------------------------------------------------------- */

.state-card {
    transition: box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
    cursor: default;
}

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

.state-card.drag-active {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: rotate(1deg) scale(1.01);
    opacity: 0.85;
    cursor: grabbing;
}

.state-card.drag-over {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.drag-handle {
    cursor: grab;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

/* -------------------------------------------------------
   Custom Scrollbar (Webkit)
------------------------------------------------------- */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Sidebar scrollbar (thinner) */
aside ::-webkit-scrollbar {
    width: 4px;
}

aside ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

aside ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* -------------------------------------------------------
   Milestone Tracking
------------------------------------------------------- */

.milestone-dot-current {
    animation: pulseRing 1.8s ease-in-out infinite;
}

.milestone-step {
    transition: transform 0.2s ease;
}

.milestone-step:hover {
    transform: scale(1.05);
}

/* -------------------------------------------------------
   Flash Messages
------------------------------------------------------- */

.flash-message {
    animation: slideInRight 0.3s ease-out forwards;
}

/* -------------------------------------------------------
   SMTP Test Spinner
------------------------------------------------------- */

.spin {
    animation: spin 0.8s linear infinite;
}

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

/* -------------------------------------------------------
   Table Rows
------------------------------------------------------- */

table tbody tr {
    transition: background-color 0.1s ease;
}

/* -------------------------------------------------------
   Form Elements Enhancement
------------------------------------------------------- */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #e2e8f0;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid white;
}

input[type="color"] {
    padding: 2px;
    cursor: pointer;
}

/* -------------------------------------------------------
   Monospace code elements
------------------------------------------------------- */

.font-mono-sm {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12.5px;
}

/* -------------------------------------------------------
   Print Styles (Tracking Page)
------------------------------------------------------- */

@media print {
    /* Hide non-essential UI */
    .no-print,
    nav,
    footer,
    button,
    a[href] {
        display: none !important;
    }

    /* Reset backgrounds for print */
    body {
        background: white !important;
    }

    .bg-white,
    .bg-gray-50 {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #e5e7eb !important;
    }

    /* Freeze animations */
    * {
        animation: none !important;
        transition: none !important;
    }

    /* Progress bar — show static width */
    .tracking-progress-bar,
    .progress-bar-fill {
        animation: none !important;
    }

    /* Page breaks */
    .page-break-before { page-break-before: always; }
    .page-break-after  { page-break-after: always; }

    /* Typography */
    body {
        font-size: 12pt;
        color: #111;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* -------------------------------------------------------
   Mobile Responsive Tweaks
------------------------------------------------------- */

@media (max-width: 640px) {
    /* Tighter padding on mobile */
    .mobile-compact {
        padding: 12px !important;
    }

    /* Full-width buttons on mobile */
    .mobile-full-btn {
        width: 100%;
        justify-content: center;
    }

    /* Stack flex items on mobile */
    .mobile-stack {
        flex-direction: column !important;
    }
}

/* -------------------------------------------------------
   Alpine x-cloak (prevents flash of unstyled content)
------------------------------------------------------- */

[x-cloak] {
    display: none !important;
}

/* -------------------------------------------------------
   Transition helpers for Alpine.js
------------------------------------------------------- */

.transition-fade-enter {
    opacity: 0;
}
.transition-fade-enter-active {
    transition: opacity 0.2s ease;
}
.transition-fade-leave-active {
    transition: opacity 0.15s ease;
}
.transition-fade-leave-to {
    opacity: 0;
}
