*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    text-align: right;
    background-color: #f4f7f6;
    color: #2d3436;
    display: flex;
    flex-direction: column;
}

.container,
.container-fluid {
    padding-left: 20px !important;
    padding-right: 20px !important;
}

main.container {
    max-width: 1440px;
    margin: 0 auto;
    flex: 1 0 auto;
}

/* Mobile-First Design & Native Feel */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 991px) {
    body {
        padding-top: 60px !important;
        /* Account for sticky-top mobile header */
        padding-bottom: 0 !important;
        background-color: #f8f9fa !important;
    }

    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Fixed Top Header Styling */
    header.sticky-top {
        height: 60px;
        display: flex;
        align-items: center;
        z-index: 1030;
    }

    /* Sidebar Styling */
    .offcanvas {
        width: 280px !important;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    .offcanvas-header {
        padding: 1.5rem;
    }

    .offcanvas-body {
        font-size: 0.95rem;
    }

    .offcanvas .nav-link {
        color: rgba(255, 255, 255, 0.8);
        font-weight: 500;
        transition: all 0.2s;
    }

    .offcanvas .nav-link:hover,
    .offcanvas .nav-link.active {
        color: #fff;
        background: rgba(255, 255, 255, 0.1);
    }

    .offcanvas .collapse .nav-link {
        padding-right: 2.5rem;
        font-size: 0.9rem;
        border-bottom: none !important;
    }

    /* Enhanced Card Layout for Tables on Mobile */
    .table-responsive {
        border: none !important;
    }

    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block !important;
        width: 100% !important;
    }

    .table-responsive thead tr {
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
    }

    .table-responsive tr {
        margin-bottom: 1.5rem !important;
        background: white !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
        padding: 1rem !important;
        border: 1px solid #edf2f7 !important;
    }

    .table-responsive td {
        border: none !important;
        position: relative !important;
        padding-right: 45% !important;
        text-align: left !important;
        border-bottom: 1px solid #f7fafc !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        font-size: 0.9rem;
    }

    .table-responsive td:before {
        position: absolute !important;
        right: 0 !important;
        width: 40% !important;
        white-space: nowrap !important;
        font-weight: 700 !important;
        color: #718096 !important;
        content: attr(data-label) !important;
        text-align: right !important;
        font-size: 0.8rem !important;
        text-transform: uppercase;
    }

    .table-responsive td:last-child {
        border-bottom: 0 !important;
        margin-top: 5px;
        padding-top: 10px;
        justify-content: center !important;
        padding-right: 0 !important;
    }
}

/* Navbar Tweaks */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

/* Dashboard Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
}

.card-icon {
    font-size: 2.5rem;
    color: #198754;
    opacity: 0.8;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

/* Premium Design System */
.glass-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.07);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(31, 38, 135, 0.12);
}

.gradient-text {
    background: linear-gradient(45deg, #198754, #20c997);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.stat-value-lg {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: -1px;
}

.card-title-premium {
    font-size: 0.9rem;
    font-weight: 700;
    color: #636e72;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bg-premium-green {
    background: linear-gradient(135deg, #1dd1a1, #10ac84) !important;
    color: white;
}

.bg-premium-blue {
    background: linear-gradient(135deg, #48dbfb, #0abde3) !important;
    color: white;
}

.bg-premium-orange {
    background: linear-gradient(135deg, #ff9f43, #ee5253) !important;
    color: white;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeInUp 0.6s ease forwards;
}

/* Print Overrides */
@media print {

    .navbar,
    .mobile-bottom-nav,
    .d-print-none {
        display: none !important;
    }

    html,
    body {
        background-color: white !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    main.container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .glass-card,
    .card {
        box-shadow: none !important;
        border: 1px solid #eee !important;
        backdrop-filter: none !important;
        page-break-inside: avoid !important;
    }

    /* Force traditional table layout in print, overriding mobile block styling */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: table-cell !important;
        width: auto !important;
    }

    .table-responsive table {
        display: table !important;
        width: 100% !important;
    }

    .table-responsive thead {
        display: table-header-group !important;
    }

    .table-responsive tbody {
        display: table-row-group !important;
    }

    .table-responsive tr {
        display: table-row !important;
        margin-bottom: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        page-break-inside: avoid !important;
    }

    .table-responsive td,
    .table-responsive th {
        border-bottom: 1px solid #dee2e6 !important;
        padding: 0.5rem !important;
        text-align: right !important;
        min-height: auto !important;
    }

    .table-responsive td:before {
        display: none !important;
    }
}

/* Premium Animal Profile Styling */
.animal-profile-header {
    background: linear-gradient(135deg, #198754 0%, #146c43 100%);
    color: white;
    padding: 3.5rem 1.5rem 5.5rem;
    border-radius: 0 0 2.5rem 2.5rem;
    margin-bottom: 0;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-top: -60px;
    /* Offset the body padding to touch the top */
}

.animal-profile-header .badge {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.1);
}

.profile-stats-container {
    margin-top: -3.5rem;
    padding: 0 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: white;
    padding: 1.25rem 0.75rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    text-align: center;
    border: 1px solid #f1f5f9;
    height: 100%;
}

.stat-card .stat-label {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.stat-card .stat-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

/* Custom Pills Styling */
.nav-custom-pills {
    background: #f1f5f9;
    padding: 0.4rem;
    border-radius: 1.5rem !important;
    border: none !important;
}

.nav-custom-pills .nav-link {
    border-radius: 1.2rem !important;
    font-weight: 600;
    color: #64748b !important;
    padding: 0.6rem 1rem;
    border: none !important;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.nav-custom-pills .nav-link.active {
    background: white !important;
    color: #198754 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.activity-item {
    padding: 1.25rem;
    border-radius: 1.25rem;
    margin-bottom: 1rem;
    background: white;
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}

.activity-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.qr-card-wrapper {
    background: white;
    padding: 2.5rem;
    border-radius: 2.5rem;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
    margin-top: 2rem;
}