
/* =====================================================
   1. LOADING SPINNER ON FORM SUBMIT
   Prevents double-clicks, shows user something is happening
===================================================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn-loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Auto-apply to all forms with data-loading attribute */
form[data-loading] .btn[type="submit"] {
    transition: all 0.2s ease;
}


/* =====================================================
   2. IMPROVED TABLE STYLES
===================================================== */

/* Clickable rows */
.table-clickable tbody tr {
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.table-clickable tbody tr:hover {
    background: rgba(var(--rt-orange-rgb), 0.05) !important;
}

/* Better tracking code styling */
.tracking-code, td code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-weight: 600;
    font-size: 0.85em;
    background: linear-gradient(135deg, var(--rt-gray-100), var(--rt-gray-50));
    padding: 0.2em 0.5em;
    border-radius: 4px;
    border: 1px solid var(--rt-gray-200);
    color: var(--rt-navy);
    letter-spacing: 0.02em;
}


/* =====================================================
   3. IMPROVED CARD ANIMATIONS
===================================================== */

.card {
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

/* Cards with hover lift effect */
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.15);
}


/* =====================================================
   4. BETTER BADGE STYLING
===================================================== */

.badge {
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 0.4em 0.7em;
}

/* Status badges with icon alignment */
.badge i {
    font-size: 0.85em;
    vertical-align: -0.05em;
}

/* Pulse animation for urgent items */
.badge-pulse {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}


/* =====================================================
   5. IMPROVED FORM STYLING
===================================================== */

/* Floating labels enhancement */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--rt-orange);
    font-weight: 500;
}

/* Input group focus */
.input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(var(--rt-orange-rgb), 0.1);
    border-radius: var(--radius-md);
}

.input-group:focus-within .input-group-text {
    border-color: var(--rt-orange);
    color: var(--rt-orange);
}

.input-group:focus-within .form-control {
    border-color: var(--rt-orange);
}

/* Select dropdown improvement */
.form-select:focus {
    border-color: var(--rt-orange);
    box-shadow: 0 0 0 3px rgba(var(--rt-orange-rgb), 0.15);
}

/* Required field indicator */
.form-label .text-danger {
    font-size: 1.1em;
    line-height: 1;
}


/* =====================================================
   6. BETTER BUTTONS
===================================================== */

/* Outline buttons with better hover */
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover,
.btn-outline-info:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Button group compact on mobile */
@media (max-width: 575.98px) {
    .btn-group-sm .btn {
        padding: 0.3rem 0.45rem;
        font-size: 0.78rem;
    }
    
    /* Stack action buttons */
    td .btn-group {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
}

/* Delete button always red on hover */
.btn-outline-danger:hover {
    background: var(--rt-danger);
    border-color: var(--rt-danger);
    color: white;
}


/* =====================================================
   7. IMPROVED PROGRESS BAR
===================================================== */

.progress {
    background: var(--rt-gray-200);
    border-radius: 50px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--rt-orange) 0%, var(--rt-orange-light) 100%);
    border-radius: 50px;
    transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}

/* Shimmer effect on progress bar */
.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}


/* =====================================================
   8. MOBILE SPECIFIC IMPROVEMENTS
===================================================== */

@media (max-width: 767.98px) {
    /* Larger touch targets on mobile */
    .nav-link {
        padding: 0.75rem 1rem !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Better stat cards on mobile */
    .stat-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .stat-card .stat-value {
        font-size: 1.75rem;
    }
    
    .stat-card .stat-icon {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    /* Full-width buttons on mobile */
    .card-footer .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    
    /* Better spacing on mobile */
    .container, .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Card body tighter on mobile */
    .card-body {
        padding: 1rem;
    }
    
    /* Hero section mobile */
    .hero-title {
        font-size: 1.8rem !important;
    }
    
    /* Hide table columns on mobile to prevent overflow */
    .table-mobile-hide {
        display: none;
    }
}


/* =====================================================
   9. SMOOTH PAGE TRANSITIONS
===================================================== */

.page-content {
    animation: pageEnter 0.3s ease-out;
}

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


/* =====================================================
   10. EMPTY STATE IMPROVEMENTS
===================================================== */

/* When tables/lists are empty */
.empty-state {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--rt-gray-400);
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    max-width: 300px;
    margin: 0.5rem auto;
}


/* =====================================================
   11. TOOLTIP & POPOVER IMPROVEMENTS
===================================================== */

[title] {
    cursor: help;
}

/* Better focus outlines for accessibility */
:focus-visible {
    outline: 2px solid var(--rt-orange);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Skip link styling */
.visually-hidden-focusable:focus {
    z-index: 9999 !important;
    background: var(--rt-orange) !important;
    color: white !important;
    padding: 0.75rem 1.5rem !important;
    font-size: 1rem !important;
    text-decoration: none !important;
}


/* =====================================================
   12. PRINT IMPROVEMENTS
===================================================== */

@media print {
    .no-print,
    .navbar,
    footer,
    .sidebar-col,
    .sidebar-toggle-btn,
    .alert-container,
    .btn-group,
    .breadcrumb {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
    
    body {
        background: white !important;
        font-size: 11pt !important;
    }
    
    .container, .container-fluid {
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    a[href]::after {
        content: none !important;
    }
    
    .badge {
        border: 1px solid #333 !important;
        color: #333 !important;
        background: white !important;
    }
}


/* =====================================================
   13. RESPONSIVE PARCEL IMAGES
===================================================== */

.parcel-photo-container img {
    width: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

@media (max-width: 575.98px) {
    .parcel-photo-container img {
        height: 200px;
        max-height: 200px;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .parcel-photo-container img {
        height: 280px;
        max-height: 280px;
    }
}

@media (min-width: 992px) {
    .parcel-photo-container img {
        max-height: 400px;
        height: auto;
        object-fit: contain;
    }
}

/*For payment methods collapse*/
.payment-method-toggle {
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--rt-gray-50);
    border: 1px solid var(--rt-gray-200);
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.payment-method-toggle:hover {
    background: var(--rt-gray-100);
}

.payment-method-toggle .toggle-icon {
    transition: transform 0.3s ease;
}

.payment-method-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}


/*for compact parcel grid*/
.parcel-info-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

.parcel-info-compact .info-item {
    background: var(--rt-gray-50);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

.parcel-info-compact .info-item label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rt-gray-500);
    margin-bottom: 0;
    display: block;
}

.parcel-info-compact .info-item .info-value {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--rt-gray-800);
    margin: 0;
}


.action-toggle {
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-base);
    position: relative;
}

.action-toggle::after {
    content: '\F282';  /* bi-chevron-down */
    font-family: 'bootstrap-icons';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
    font-size: 1rem;
}

.action-toggle[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(180deg);
}


/* =====================================================
   MOBILE-FIRST UX IMPROVEMENTS
===================================================== */

/* Prevent iOS overscroll bounce showing blank footer area */
html {
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
}

/* Bigger form controls on mobile */
@media (max-width: 575.98px) {
    .form-control, .form-select, .input-group-text {
        font-size: 1rem;
        min-height: 48px; /* Google recommends 48px touch targets */
    }

    .btn {
        min-height: 48px;
        font-size: 1rem;
    }

    /* Make tracking input full-width and more prominent */
    .track-card {
        padding: 1.25rem !important;
    }

    .track-card .input-group-lg .form-control {
        font-size: 1rem;
    }

    /* Stack footer columns tighter */
    footer .col-md-4 {
        margin-bottom: 1.5rem;
    }

    /* Ensure footer background extends fully */
    footer {
        position: relative;
        z-index: 1;
    }
}


/* =====================================================
   MOBILE FIXES — append to static/css/improvements.css
   ===================================================== */

/*!* On mobile, show pricing/pay sidebar ABOVE main parcel details.*/
/*   Clients care about price and pay button first, not shipment timeline. *!*/
/*@media (max-width: 991.98px) {*/
/*    .col-lg-4 {*/
/*        order: -1;*/
/*    }*/
/*}*/

/* Stack action buttons vertically on small phones.
   Prevents messy 2-3 row wrapping of 5+ buttons. */
@media (max-width: 575.98px) {
    .card-footer.d-flex {
        flex-direction: column !important;
    }
    .card-footer .btn {
        width: 100%;
        font-size: 0.85rem;
    }
    /* Keep small badges/info inline */
    .card-footer small {
        text-align: center;
    }
}

/* Client mobile parcel cards — smooth tap feedback */
.d-md-none a .d-flex:active {
    background: var(--rt-gray-50);
}