/* ========================================
   MOBILE RESPONSIVE STYLES FOR WRITECLARITY
   ======================================== */

/* Base Mobile Styles */
@media (max-width: 991.98px) {

    /* Ensure proper viewport behavior */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }

    body {
        font-size: 16px !important;
        line-height: 1.6 !important;
        overflow-x: hidden !important;
    }

    /* Container padding for mobile */
    .container {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Prevent horizontal scroll */
    * {
        max-width: 100%;
    }

    img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ========================================
   DESKTOP NAVIGATION IMPROVEMENTS
   ======================================== */
@media (min-width: 992px) {

    /* Ensure navbar is fixed on desktop too */
    .navbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1030 !important;
    }

    /* Add padding to body to account for fixed navbar */
    body {
        padding-top: 80px !important;
    }

    /* Navbar layout */
    .navbar .d-flex.w-100 {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }

    .navbar-brand-container {
        flex: 0 0 auto !important;
        min-width: 200px !important;
    }

    .navbar-collapse {
        flex: 1 1 auto !important;
        display: flex !important;
        justify-content: center !important;
    }

    .navbar-nav {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
        margin: 0 !important;
    }

    .navbar-actions {
        flex: 0 0 auto !important;
        min-width: 200px !important;
        display: flex !important;
        justify-content: flex-end !important;
    }
}

/* Large Desktop - Full spacing */
@media (min-width: 1400px) {
    .navbar-brand-container {
        min-width: 220px !important;
    }

    .navbar-actions {
        min-width: 220px !important;
    }

    .nav-link {
        margin: 0 0.5rem !important;
        padding: 0.5rem 1rem !important;
        font-size: 1rem !important;
    }
}

/* Desktop - Standard spacing */
@media (min-width: 1200px) and (max-width: 1399.98px) {
    .navbar-brand-container {
        min-width: 200px !important;
    }

    .navbar-actions {
        min-width: 200px !important;
    }

    .nav-link {
        margin: 0 0.4rem !important;
        padding: 0.5rem 0.9rem !important;
        font-size: 0.95rem !important;
    }
}

/* Small Desktop/Tablet - Compact spacing */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .navbar-brand-container {
        min-width: 160px !important;
    }

    .navbar-brand .logo-text {
        font-size: 1.35rem !important;
    }

    .navbar-actions {
        min-width: 160px !important;
    }

    .navbar-actions .btn {
        padding: 8px 16px !important;
        font-size: 0.8125rem !important;
    }

    .nav-link {
        margin: 0 0.2rem !important;
        padding: 0.4rem 0.65rem !important;
        font-size: 0.8125rem !important;
    }
}

/* ========================================
   NAVIGATION - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Fixed navbar positioning */
    .navbar {
        padding: 0.65rem 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1030 !important;
        background-color: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(10px) !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
    }

    /* Add padding to body to account for fixed navbar */
    body {
        padding-top: 70px !important;
    }

    .navbar .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        position: relative !important;
    }

    /* Navbar layout - logo and toggler side by side */
    .navbar .d-flex.w-100 {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
    }

    .navbar-brand-container {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        margin-right: 0.5rem !important;
    }

    /* Logo sizing */
    .navbar-brand {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .navbar-brand .logo-text {
        font-size: 1.3rem !important;
        white-space: nowrap !important;
    }

    .navbar-brand .logo-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1rem !important;
        flex-shrink: 0 !important;
    }

    /* Hamburger toggler button */
    .navbar-toggler {
        order: 2 !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
        border: 2px solid rgba(0, 70, 145, 0.15) !important;
        padding: 0.5rem 0.65rem !important;
        border-radius: 10px !important;
        background-color: rgba(0, 70, 145, 0.03) !important;
        position: relative !important;
        z-index: 1031 !important;
        cursor: pointer !important;
    }

    .navbar-toggler:hover {
        border-color: rgba(0, 70, 145, 0.3) !important;
        background-color: rgba(0, 70, 145, 0.08) !important;
        transform: scale(1.05) !important;
    }

    .navbar-toggler:focus {
        box-shadow: 0 0 0 3px rgba(0, 70, 145, 0.15) !important;
        outline: none !important;
        border-color: #004691 !important;
    }

    .navbar-toggler:active {
        transform: scale(0.95) !important;
    }

    /* Hamburger icon styling */
    .navbar-toggler-icon {
        background-image: none !important;
        width: 26px !important;
        height: 20px !important;
        position: relative !important;
        display: block !important;
        background-color: #004691 !important;
        height: 3px !important;
        border-radius: 2px !important;
        transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .navbar-toggler-icon::before,
    .navbar-toggler-icon::after {
        content: '' !important;
        position: absolute !important;
        left: 0 !important;
        width: 100% !important;
        height: 3px !important;
        background-color: #004691 !important;
        border-radius: 2px !important;
        transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .navbar-toggler-icon::before {
        top: -8px !important;
    }

    .navbar-toggler-icon::after {
        bottom: -8px !important;
    }

    /* Animated X when menu is open */
    .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon {
        background-color: transparent !important;
    }

    .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon::before {
        top: 0 !important;
        transform: rotate(45deg) !important;
    }

    .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon::after {
        bottom: 0 !important;
        transform: rotate(-45deg) !important;
    }

    .navbar-toggler[aria-expanded="true"] {
        background-color: rgba(0, 70, 145, 0.12) !important;
        border-color: #004691 !important;
    }

    /* Mobile menu dropdown */
    .navbar-collapse {
        background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%) !important;
        border-radius: 16px !important;
        box-shadow: 0 8px 32px rgba(0, 70, 145, 0.15) !important;
        margin-top: 1.25rem !important;
        padding: 1.5rem !important;
        border: 2px solid rgba(0, 70, 145, 0.1) !important;
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        width: 100% !important;
        max-height: calc(100vh - 100px) !important;
        overflow-y: auto !important;
    }

    /* Smooth animation for menu opening */
    .navbar-collapse.show {
        animation: slideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .navbar-collapse.collapsing {
        transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* Navigation links */
    .navbar-nav {
        margin-bottom: 1.25rem !important;
        flex-direction: column !important;
    }

    .nav-link {
        padding: 0.85rem 1.25rem !important;
        margin: 0.35rem 0 !important;
        border-radius: 10px !important;
        font-size: 1rem !important;
        font-weight: 500 !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        position: relative !important;
        overflow: hidden !important;
        display: block !important;
    }

    .nav-link::before {
        content: '' !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        height: 100% !important;
        width: 4px !important;
        background: #004691 !important;
        transform: scaleY(0) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .nav-link:hover::before,
    .nav-link.active::before {
        transform: scaleY(1) !important;
    }

    .nav-link:hover {
        background-color: rgba(0, 70, 145, 0.08) !important;
        transform: translateX(8px) !important;
        padding-left: 1.5rem !important;
    }

    .nav-link.active {
        background-color: rgba(0, 70, 145, 0.1) !important;
        color: #004691 !important;
        font-weight: 600 !important;
    }

    /* Mobile action buttons */
    .navbar-actions {
        flex-direction: column !important;
        gap: 0.85rem !important;
        width: 100% !important;
        margin-left: 0 !important;
        padding-top: 1rem !important;
        border-top: 2px solid rgba(0, 70, 145, 0.1) !important;
    }

    .navbar-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 0.85rem 1.5rem !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        border-radius: 10px !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .navbar-actions .btn:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 20px rgba(0, 70, 145, 0.2) !important;
    }

    .navbar-actions .btn:active {
        transform: translateY(0) !important;
    }

    .navbar-actions .dropdown {
        width: 100% !important;
    }

    .navbar-actions .dropdown .btn {
        width: 100% !important;
    }

    .navbar-actions .dropdown-menu {
        width: 100% !important;
        margin-top: 0.5rem !important;
        border-radius: 10px !important;
        border: 2px solid rgba(0, 70, 145, 0.1) !important;
        box-shadow: 0 4px 16px rgba(0, 70, 145, 0.12) !important;
    }

    .navbar-actions .dropdown-item {
        padding: 0.75rem 1.25rem !important;
        border-radius: 8px !important;
        margin: 0.25rem 0.5rem !important;
        transition: all 0.25s ease !important;
    }

    .navbar-actions .dropdown-item:hover {
        background-color: rgba(0, 70, 145, 0.08) !important;
        transform: translateX(4px) !important;
    }
}

/* ========================================
   HOME PAGE - HERO SECTION
   ======================================== */
@media (max-width: 1024px) {

    /* Hero section */
    section.hero,
    .hero {
        height: auto !important;
        min-height: auto !important;
        padding: 80px 20px 40px 20px !important;
    }

    .hero-wrapper {
        border-radius: 0 0 24px 24px !important;
    }

    /* Solid blue background on mobile */
    .hero-bg-main {
        background: linear-gradient(135deg, #004691 0%, #00509d 100%) !important;
    }

    /* Hide decorative elements */
    .hero-bg-accent-1,
    .hero-bg-accent-2 {
        display: none !important;
    }

    /* Hero content layout */
    .hero-content {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }

    /* All text white on blue background */
    .hero-left .hero-tag,
    .hero-left .hero-title,
    .hero-left .hero-description {
        color: #FFFFFF !important;
    }

    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        border-bottom-color: rgba(255, 255, 255, 0.3) !important;
    }

    .hero-tag {
        font-size: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    .hero-description {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Hide feature badges on mobile */
    .hero-features {
        display: none !important;
    }

    /* Buttons */
    .hero-buttons {
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
    }

    .hero-buttons .btn {
        width: 100% !important;
        text-align: center !important;
        padding: 0.875rem 1.5rem !important;
        font-size: 0.95rem !important;
    }

    .hero-buttons .btn:first-child {
        background: #F9BE4A !important;
        color: #004691 !important;
    }

    .hero-buttons .btn:last-child {
        background: transparent !important;
        color: #FFFFFF !important;
        border: 2px solid #FFFFFF !important;
    }

    /* Trust cards */
    .trust-card {
        padding: 1.5rem !important;
        background: rgba(255, 255, 255, 0.1) !important;
        border-color: rgba(255, 255, 255, 0.2) !important;
    }

    .trust-card h3 {
        font-size: 1.125rem !important;
        color: #FFFFFF !important;
    }

    .trust-card p {
        font-size: 0.875rem !important;
        color: rgba(255, 255, 255, 0.85) !important;
    }

    .trust-icon .material-icons {
        font-size: 2.25rem !important;
        color: #F9BE4A !important;
    }
}

/* ========================================
   HOME PAGE - PRICING SECTION
   ======================================== */
@media (max-width: 1024px) {
    .pricing-section {
        padding: 2.5rem 0 !important;
    }

    .pricing-header {
        padding: 1.5rem 1.25rem !important;
        margin-bottom: 1.5rem !important;
    }

    .pricing-title {
        font-size: 1.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .pricing-tag {
        font-size: 0.7rem !important;
        padding: 0.375rem 0.875rem !important;
    }

    .pricing-content-wrapper {
        padding: 1.5rem 1rem !important;
        border-radius: 16px !important;
    }

    .pricing-content {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .pricing-left {
        padding: 1.25rem !important;
    }

    .pricing-left h3 {
        font-size: 1.125rem !important;
    }

    .pricing-left p {
        font-size: 0.875rem !important;
    }

    .pricing-middle {
        display: none !important;
    }

    .pricing-right {
        justify-content: center !important;
    }

    .calculator-wrapper {
        max-width: 100% !important;
        padding: 1.5rem 1.25rem !important;
    }

    .calculator-header h3 {
        font-size: 1.125rem !important;
    }

    .form-group {
        margin-bottom: 1rem !important;
    }

    .form-group label {
        font-size: 0.8125rem !important;
    }

    .form-group select,
    .form-group input {
        padding: 0.75rem 0.875rem !important;
        font-size: 0.875rem !important;
    }

    .cost-display {
        padding: 1.25rem 1rem !important;
    }

    .cost-amount {
        font-size: 2.25rem !important;
    }
}

/* ========================================
   SERVICES PAGE - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Hero section */
    section[style*="background: linear-gradient(135deg, #004691"] {
        padding: 3rem 1rem 2rem 1rem !important;
    }

    /* Service cards carousel */
    .service-slide {
        padding: 1rem !important;
    }

    .service-slide h4 {
        font-size: 1.125rem !important;
    }

    .service-slide p {
        font-size: 0.875rem !important;
    }

    /* Pricing table */
    table {
        font-size: 0.8125rem !important;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem !important;
    }

    /* Make table scrollable on mobile */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ========================================
   HOW IT WORKS PAGE - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Process steps */
    .process-step-item {
        padding: 1.25rem !important;
    }

    .process-step-item h5 {
        font-size: 1.0625rem !important;
    }

    .process-step-item p {
        font-size: 0.875rem !important;
    }

    /* Feature items */
    .feature-item {
        padding: 1rem 0 !important;
    }

    .feature-item h5 {
        font-size: 1.0625rem !important;
    }

    .feature-item p {
        font-size: 0.8125rem !important;
    }
}

/* ========================================
   CONTACT PAGE - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Contact form */
    .col-lg-8,
    .col-lg-4 {
        width: 100% !important;
        margin-bottom: 1.5rem !important;
    }

    /* Form inputs */
    .form-control,
    .form-select {
        font-size: 1rem !important;
        padding: 0.75rem !important;
    }

    /* Contact info cards */
    div[style*="display: flex; align-items: flex-start"] {
        flex-direction: row !important;
        gap: 0.875rem !important;
    }
}

/* ========================================
   BLOG PAGE - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Blog cards */
    .blog-card {
        margin-bottom: 1.5rem !important;
    }

    .blog-card img {
        height: auto !important;
        max-height: 200px !important;
        object-fit: cover !important;
    }

    .blog-card h3 {
        font-size: 1.25rem !important;
    }

    .blog-card p {
        font-size: 0.875rem !important;
    }
}

/* ========================================
   SAMPLES PAGE - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Sample cards */
    .sample-card {
        margin-bottom: 1.5rem !important;
    }

    .sample-card h4 {
        font-size: 1.125rem !important;
    }

    .sample-card p {
        font-size: 0.875rem !important;
    }
}

/* ========================================
   ORDER NOW PAGE - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Order form */
    .order-form {
        padding: 1.5rem 1rem !important;
    }

    .order-form .form-group {
        margin-bottom: 1.25rem !important;
    }

    .order-form label {
        font-size: 0.875rem !important;
        font-weight: 600 !important;
    }

    .order-form input,
    .order-form select,
    .order-form textarea {
        font-size: 1rem !important;
        padding: 0.75rem !important;
    }

    /* Order summary */
    .order-summary {
        padding: 1.25rem !important;
        margin-top: 1.5rem !important;
    }

    .order-summary h3 {
        font-size: 1.25rem !important;
    }

    .order-summary .price {
        font-size: 2rem !important;
    }

    /* File upload */
    .file-upload-area {
        padding: 1.5rem 1rem !important;
    }

    /* Payment buttons */
    .payment-buttons {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .payment-buttons .btn {
        width: 100% !important;
        padding: 0.875rem !important;
        font-size: 1rem !important;
    }
}

/* ========================================
   ADMIN DASHBOARD - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Sidebar */
    .sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        z-index: 1050 !important;
        transition: left 0.3s ease !important;
    }

    .sidebar.show {
        left: 0 !important;
    }

    /* Mobile menu toggle */
    .mobile-menu-toggle {
        display: block !important;
        position: fixed !important;
        top: 1rem !important;
        left: 1rem !important;
        z-index: 1051 !important;
        background: #004691 !important;
        color: white !important;
        border: none !important;
        padding: 0.5rem 0.75rem !important;
        border-radius: 0.5rem !important;
        font-size: 1.25rem !important;
    }

    /* Main content */
    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
        padding-top: 4rem !important;
    }

    /* Dashboard cards */
    .dashboard-card {
        margin-bottom: 1rem !important;
    }

    .dashboard-card h3 {
        font-size: 1.125rem !important;
    }

    .dashboard-card .stat-number {
        font-size: 1.75rem !important;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    table {
        min-width: 600px !important;
        font-size: 0.8125rem !important;
    }

    table th,
    table td {
        padding: 0.5rem !important;
        white-space: nowrap !important;
    }

    /* Action buttons in tables */
    .btn-sm {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

/* ========================================
   CLIENT DASHBOARD - MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 991.98px) {

    /* Dashboard layout */
    .dashboard-container {
        padding: 1rem !important;
    }

    /* STAT BOXES - FIX OVERFLOW ISSUE */
    /* Force stat boxes to stack vertically on mobile */
    .row.g-2>.col-6,
    .row.g-2>.col-md-3 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Stat box container - ensure proper flex layout */
    .row.g-2>.col-6>div,
    .row.g-2>.col-md-3>div {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 12px 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Icon - fixed width */
    .row.g-2>.col-6>div>.material-symbols-outlined,
    .row.g-2>.col-md-3>div>.material-symbols-outlined {
        flex-shrink: 0 !important;
        width: 24px !important;
        font-size: 20px !important;
    }

    /* Label - flexible, can wrap if needed */
    .row.g-2>.col-6>div>div:nth-child(2),
    .row.g-2>.col-md-3>div>div:nth-child(2) {
        flex: 1 1 auto !important;
        font-size: 11px !important;
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.3 !important;
        max-width: calc(100% - 80px) !important;
    }

    /* Value - fixed width on right */
    .row.g-2>.col-6>div>div:last-child,
    .row.g-2>.col-md-3>div>div:last-child {
        flex-shrink: 0 !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        margin-left: auto !important;
        min-width: 40px !important;
        text-align: right !important;
    }

    /* Order cards */
    .order-card {
        margin-bottom: 1rem !important;
        padding: 1.25rem !important;
    }

    .order-card h4 {
        font-size: 1.125rem !important;
    }

    .order-card .order-status {
        font-size: 0.75rem !important;
        padding: 0.375rem 0.75rem !important;
    }

    /* Messages */
    .message-list {
        max-height: 400px !important;
    }

    .message-item {
        padding: 0.875rem !important;
    }

    .message-item .message-text {
        font-size: 0.875rem !important;
    }

    /* File downloads */
    .file-list {
        padding: 1rem !important;
    }

    .file-item {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    .file-item .file-name {
        font-size: 0.875rem !important;
    }
}

/* ========================================
   STAT BOXES - SMALL MOBILE FIX
   ======================================== */
@media (max-width: 575.98px) {

    /* Even smaller on phones */
    .row.g-2>.col-6>div,
    .row.g-2>.col-md-3>div {
        padding: 10px 14px !important;
        gap: 8px !important;
    }

    .row.g-2>.col-6>div>.material-symbols-outlined,
    .row.g-2>.col-md-3>div>.material-symbols-outlined {
        font-size: 18px !important;
        width: 20px !important;
    }

    .row.g-2>.col-6>div>div:nth-child(2),
    .row.g-2>.col-md-3>div>div:nth-child(2) {
        font-size: 10px !important;
        max-width: calc(100% - 70px) !important;
    }

    .row.g-2>.col-6>div>div:last-child,
    .row.g-2>.col-md-3>div>div:last-child {
        font-size: 16px !important;
        min-width: 35px !important;
    }
}

/* ========================================
   STAT BOXES - EXTRA SMALL MOBILE
   ======================================== */
@media (max-width: 400px) {

    .row.g-2>.col-6>div,
    .row.g-2>.col-md-3>div {
        padding: 8px 12px !important;
        gap: 6px !important;
    }

    .row.g-2>.col-6>div>.material-symbols-outlined,
    .row.g-2>.col-md-3>div>.material-symbols-outlined {
        font-size: 16px !important;
        width: 18px !important;
    }

    .row.g-2>.col-6>div>div:nth-child(2),
    .row.g-2>.col-md-3>div>div:nth-child(2) {
        font-size: 9px !important;
        max-width: calc(100% - 60px) !important;
    }

    .row.g-2>.col-6>div>div:last-child,
    .row.g-2>.col-md-3>div>div:last-child {
        font-size: 14px !important;
        min-width: 30px !important;
    }
}

/* ========================================
   ADMIN DASHBOARD STAT BOXES FIX
   ======================================== */
@media (max-width: 991.98px) {

    /* Admin stat boxes with financial data */
    .card-body .row.g-2>div[class*="col"]>div[style*="display: flex"] {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding: 10px 14px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Ensure icons don't shrink */
    .card-body .row.g-2>div[class*="col"]>div[style*="display: flex"]>span[class*="material"] {
        flex-shrink: 0 !important;
        width: 20px !important;
        font-size: 18px !important;
    }

    /* Labels should be flexible but not overflow */
    .card-body .row.g-2>div[class*="col"]>div[style*="display: flex"]>div:not(:last-child) {
        flex: 1 1 auto !important;
        font-size: 10px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 50% !important;
    }

    /* Values should stay on the right */
    .card-body .row.g-2>div[class*="col"]>div[style*="display: flex"]>div:last-child {
        flex-shrink: 0 !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        margin-left: auto !important;
        text-align: right !important;
        white-space: nowrap !important;
    }
}

/* ========================================
   FORCE PROPER STAT BOX LAYOUT
   ======================================== */
@media (max-width: 767px) {

    /* Override any inline styles that might cause overflow */
    .card-body div[style*="gap: 8px"] {
        gap: 6px !important;
    }

    /* Ensure stat boxes never overflow */
    .card-body .row.g-2 {
        margin: 0 !important;
        width: 100% !important;
    }

    .card-body .row.g-2>div {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: 8px !important;
    }

    /* Force proper flex behavior */
    .card-body .row.g-2>div>div[style*="display: flex"] {
        flex-wrap: nowrap !important;
        min-width: 0 !important;
    }

    /* Prevent text from breaking out */
    .card-body .row.g-2>div>div[style*="display: flex"]>* {
        min-width: 0 !important;
    }
}

/* ========================================
   GENERAL MOBILE IMPROVEMENTS
   ======================================== */
@media (max-width: 991.98px) {

    /* Headings */
    h1 {
        font-size: 1.875rem !important;
        line-height: 1.2 !important;
    }

    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }

    h3 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }

    h4 {
        font-size: 1.125rem !important;
    }

    h5 {
        font-size: 1rem !important;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.9375rem !important;
    }

    .btn-lg {
        padding: 0.875rem 1.75rem !important;
        font-size: 1rem !important;
    }

    .btn-sm {
        padding: 0.5rem 1rem !important;
        font-size: 0.8125rem !important;
    }

    /* Cards */
    .card {
        margin-bottom: 1.25rem !important;
        border-radius: 0.75rem !important;
    }

    .card-body {
        padding: 1.25rem !important;
    }

    /* Modals */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-content {
        border-radius: 0.75rem !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem !important;
    }

    /* Alerts */
    .alert {
        padding: 0.875rem 1rem !important;
        font-size: 0.875rem !important;
        border-radius: 0.5rem !important;
    }

    /* Badges */
    .badge {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    /* Spacing utilities */
    .mb-5 {
        margin-bottom: 2rem !important;
    }

    .mt-5 {
        margin-top: 2rem !important;
    }

    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .px-5 {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
}

/* ========================================
   SMALL MOBILE (< 576px)
   ======================================== */
@media (max-width: 575.98px) {
    body {
        font-size: 14px !important;
    }

    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    h1 {
        font-size: 1.625rem !important;
    }

    h2 {
        font-size: 1.375rem !important;
    }

    h3 {
        font-size: 1.125rem !important;
    }

    .btn {
        padding: 0.625rem 1.25rem !important;
        font-size: 0.875rem !important;
    }

    .hero-title {
        font-size: 1.75rem !important;
    }

    .hero-description {
        font-size: 0.9375rem !important;
    }

    .pricing-title {
        font-size: 1.5rem !important;
    }

    .calculator-wrapper {
        padding: 1.25rem 1rem !important;
    }

    .cost-amount {
        font-size: 2rem !important;
    }
}

/* ========================================
   TOUCH IMPROVEMENTS
   ======================================== */
@media (hover: none) and (pointer: coarse) {

    /* Increase touch targets */
    .btn,
    .nav-link,
    a {
        min-height: 44px !important;
        min-width: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    a:hover {
        transform: none !important;
    }

    /* Add active states for touch feedback */
    .btn:active {
        transform: scale(0.98) !important;
        opacity: 0.9 !important;
    }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */
@media (max-width: 991.98px) and (orientation: landscape) {
    .hero {
        padding: 60px 20px 30px 20px !important;
    }

    .hero-title {
        font-size: 1.75rem !important;
    }

    .modal-dialog {
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */
@media (max-width: 991.98px) {

    /* Focus states */
    *:focus {
        outline: 2px solid #F9BE4A !important;
        outline-offset: 2px !important;
    }

    /* Skip to content link */
    .skip-to-content {
        position: absolute !important;
        top: -40px !important;
        left: 0 !important;
        background: #004691 !important;
        color: white !important;
        padding: 8px !important;
        text-decoration: none !important;
        z-index: 100 !important;
    }

    .skip-to-content:focus {
        top: 0 !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {

    .navbar,
    .footer,
    .btn,
    .sidebar {
        display: none !important;
    }

    body {
        font-size: 12pt !important;
        color: black !important;
        background: white !important;
    }

    a {
        text-decoration: underline !important;
        color: black !important;
    }
}


/* ========================================
   CRITICAL FIX: STAT BOX TEXT OVERFLOW
   Prevents "check_circleCOMPLETED£0.00" from overflowing
   ======================================== */
@media (max-width: 991.98px) {

    /* Target all stat box containers */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"] {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Icon - always visible, fixed size */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>span.material-symbols-outlined {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        width: 20px !important;
        min-width: 20px !important;
        font-size: 18px !important;
        margin-right: 0 !important;
    }

    /* Label text - flexible, can shrink */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>div[style*="font-size: 12px"] {
        flex: 1 1 auto !important;
        font-size: 10px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        min-width: 0 !important;
        max-width: 45% !important;
    }

    /* Value - always visible, fixed size */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>div[style*="font-size: 20px"] {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        font-size: 16px !important;
        font-weight: 700 !important;
        margin-left: auto !important;
        text-align: right !important;
        white-space: nowrap !important;
        min-width: 40px !important;
    }
}

@media (max-width: 575.98px) {

    /* Smaller on phones */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"] {
        padding: 10px 12px !important;
        gap: 6px !important;
    }

    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>span.material-symbols-outlined {
        width: 18px !important;
        font-size: 16px !important;
    }

    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>div[style*="font-size: 12px"] {
        font-size: 9px !important;
        max-width: 40% !important;
    }

    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>div[style*="font-size: 20px"] {
        font-size: 14px !important;
        min-width: 35px !important;
    }
}

@media (max-width: 400px) {

    /* Extra small phones */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"] {
        padding: 8px 10px !important;
        gap: 5px !important;
    }

    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>span.material-symbols-outlined {
        width: 16px !important;
        font-size: 14px !important;
    }

    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>div[style*="font-size: 12px"] {
        font-size: 8px !important;
        max-width: 35% !important;
    }

    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"]>div[style*="font-size: 20px"] {
        font-size: 13px !important;
        min-width: 30px !important;
    }
}

/* ========================================
   UNIVERSAL OVERFLOW PREVENTION
   ======================================== */
@media (max-width: 991.98px) {

    /* Prevent any element from causing horizontal scroll */
    * {
        max-width: 100% !important;
    }

    /* Specific containers that should never overflow */
    .container,
    .container-fluid,
    .row,
    .col,
    [class*="col-"],
    .card,
    .card-body,
    .card-header {
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* Flex containers should wrap properly */
    div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    /* But stat boxes should NOT wrap */
    div[style*="display: flex"][style*="gap: 8px"][style*="padding: 12px"] {
        flex-wrap: nowrap !important;
    }
}