/**
 * CENTER EVERYTHING ON MOBILE & TABLETS
 * Comprehensive centering for all responsive devices
 */

/* ==============================================
   UNIVERSAL CENTERING - MOBILE & TABLET
   ============================================== */

@media (max-width: 991px) {
    
    /* ========== TEXT CENTERING ========== */
    
    /* Center ALL text elements */
    * {
        text-align: center !important;
    }
    
    /* Center headings */
    h1, h2, h3, h4, h5, h6,
    .h1, .h2, .h3, .h4, .h5, .h6,
    .display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
        text-align: center !important;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Center paragraphs and text */
    p, span, div, a, small, label, legend {
        text-align: center !important;
    }
    
    /* Center lists */
    ul, ol {
        text-align: center !important;
        list-style-position: inside;
        padding-right: 0 !important;
        padding-left: 0 !important;
    }
    
    li {
        text-align: center !important;
    }
    
    /* ========== LAYOUT CENTERING ========== */
    
    /* Center all containers */
    .container,
    .container-fluid {
        text-align: center;
    }
    
    /* Center rows */
    .row {
        justify-content: center !important;
        text-align: center;
    }
    
    /* Center columns (footer keeps normal grid so footer-brand-accent can center) */
    .main-content [class*="col-"],
    .site-header [class*="col-"] {
        text-align: center !important;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Center cards */
    .card {
        text-align: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    .card-body,
    .card-header,
    .card-footer {
        text-align: center !important;
    }
    
    /* ========== FLEX CENTERING ========== */
    
    /* Center all flex containers */
    .d-flex,
    .d-inline-flex,
    [class*="flex-"] {
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    /* Center flex items */
    .flex-grow-1,
    .flex-shrink-1 {
        text-align: center !important;
    }
    
    /* ========== BUTTONS CENTERING ========== */
    
    /* Center all buttons */
    .btn,
    .btn-group,
    .btn-toolbar {
        display: block !important;
        margin-left: auto !important;
        margin-right: auto !important;
        text-align: center !important;
        width: 90% !important;
        max-width: 400px;
    }
    
    .btn-group .btn {
        width: auto !important;
        margin: 5px !important;
    }
    
    /* ========== IMAGES CENTERING ========== */
    
    /* Center all images */
    img,
    .news-image,
    .featured-image,
    .article-cover-image img {
        display: block !important;
        margin-left: auto !important;
        margin-right: auto !important;
        text-align: center;
    }
    
    .news-image-wrapper,
    .article-cover-image {
        text-align: center;
    }
    
    /* ========== BADGES & LABELS CENTERING ========== */
    
    /* Center badges */
    .badge,
    .category-badge,
    .breaking-badge,
    .featured-tag {
        position: static !important;
        display: inline-block !important;
        margin: 5px !important;
    }
    
    /* ========== NAVIGATION CENTERING ========== */
    
    /* Center navbar */
    .navbar {
        text-align: center;
    }
    
    .navbar-brand {
        margin-left: auto;
        margin-right: auto;
    }
    
    .navbar-nav {
        align-items: center !important;
        width: 100%;
    }
    
    .navbar-nav .nav-item {
        text-align: center !important;
        width: 100%;
    }
    
    .navbar-nav .nav-link {
        text-align: center !important;
        justify-content: center !important;
    }
    
    /* ========== FORMS CENTERING ========== */
    
    /* Center form elements */
    .form-control,
    .form-select,
    .form-check {
        text-align: center !important;
        margin-left: auto;
        margin-right: auto;
    }
    
    .form-label {
        text-align: center !important;
        display: block;
        width: 100%;
    }
    
    .form-check {
        justify-content: center;
    }
    
    .input-group {
        justify-content: center;
        margin: 0 auto;
    }
    
    /* ========== TABLES CENTERING ========== */
    
    /* Center table content */
    .table thead th,
    .table tbody td {
        text-align: center !important;
    }
    
    /* ========== WIDGETS CENTERING ========== */
    
    /* Center widgets */
    .widget {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
    }
    
    .widget-title {
        text-align: center !important;
        justify-content: center;
    }
    
    .calendar-event-item,
    .most-viewed-item {
        text-align: center !important;
    }
    
    .event-date {
        margin: 0 auto 15px auto !important;
    }
    
    /* ========== FOOTER CENTERING ========== */
    
    /* Center footer */
    .site-footer {
        text-align: center !important;
    }
    
    .site-footer .row,
    .site-footer .col-md-4 {
        text-align: center !important;
    }
    
    .site-footer h4,
    .site-footer h5,
    .site-footer p,
    .site-footer ul {
        text-align: center !important;
    }
    
    /* ========== ARTICLE PAGE CENTERING ========== */
    
    /* Center article elements */
    .article-detail {
        text-align: center;
    }
    
    .article-card {
        text-align: center !important;
    }
    
    .article-title,
    .article-summary,
    .article-content,
    .article-meta {
        text-align: center !important;
    }
    
    .article-content p,
    .article-content h2,
    .article-content h3 {
        text-align: center !important;
    }
    
    /* Center gallery */
    .article-gallery {
        text-align: center !important;
    }
    
    .article-gallery .row {
        justify-content: center;
    }
    
    /* Center share buttons */
    .article-share {
        text-align: center !important;
    }
    
    .share-buttons {
        justify-content: center !important;
        text-align: center;
    }
    
    /* ========== ADMIN PANEL CENTERING ========== */
    
    /* Center admin content */
    .content-wrapper {
        text-align: center;
    }
    
    /* Center stats cards */
    .stat-card {
        text-align: center !important;
    }
    
    .stat-card .card-body {
        text-align: center !important;
    }
    
    .stat-card .d-flex {
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .stat-icon {
        margin: 15px 0 !important;
    }
    
    /* Center page titles */
    .border-bottom {
        text-align: center !important;
    }
    
    .border-bottom h1 {
        text-align: center !important;
    }
    
    /* Center quick actions */
    .btn-toolbar .btn-group {
        width: 100%;
        justify-content: center;
    }
    
    /* ========== CATEGORY PAGE CENTERING ========== */
    
    body.page-category .category-header {
        text-align: center !important;
    }
    
    body.page-category .category-header .row {
        justify-content: center;
    }
    
    /* ========== PAGINATION CENTERING ========== */
    
    .pagination {
        justify-content: center !important;
    }
    
    nav[aria-label] {
        text-align: center;
    }
    
    /* ========== BREADCRUMB CENTERING ========== */
    
    .breadcrumb {
        justify-content: center !important;
        text-align: center;
    }
    
    .breadcrumb-item {
        text-align: center;
    }
    
    /* ========== SECTION HEADERS CENTERING ========== */
    
    .section-header {
        text-align: center !important;
        flex-direction: column;
        align-items: center !important;
    }
    
    .section-title {
        text-align: center !important;
        margin-bottom: 15px;
    }
    
    /* ========== BREAKING NEWS CENTERING ========== */
    
    .breaking-news-bar {
        text-align: center;
    }
    
    .breaking-news-bar .d-flex {
        justify-content: center !important;
        flex-wrap: wrap;
    }
    
    .breaking-label {
        margin: 10px auto !important;
    }
    
    .breaking-content {
        text-align: center;
        width: 100%;
    }
    
    /* ========== TOP BAR CENTERING ========== */
    
    .top-bar .row {
        text-align: center !important;
    }
    
    .top-bar .col-md-6 {
        text-align: center !important;
        margin-bottom: 5px;
    }
    
    .social-links {
        justify-content: center !important;
    }
}

/* ==============================================
   TABLET SPECIFIC CENTERING (768px - 991px)
   ============================================== */

@media (min-width: 768px) and (max-width: 991px) {
    /* Keep some elements left-aligned on tablet */
    .article-content {
        text-align: right !important; /* RTL for better reading */
    }
    
    .article-content p {
        text-align: right !important;
    }
    
    /* But keep titles centered */
    .article-title,
    .section-title,
    h1, h2, h3 {
        text-align: center !important;
    }
}

/* ==============================================
   DESKTOP - RESTORE NORMAL ALIGNMENT (≥ 992px)
   ============================================== */

@media (min-width: 992px) {
    /* Reset to normal on desktop */
    * {
        text-align: inherit !important;
    }
    
    /* RTL alignment for Arabic content */
    .article-content,
    .news-card .card-text {
        text-align: right !important;
    }
    
    /* Keep some centered on desktop too */
    .section-header {
        text-align: right !important;
    }
}

/* ==============================================
   FORCE CENTER UTILITIES
   ============================================== */

/* Utility class to force center on any device */
.mobile-center {
    text-align: center !important;
}

@media (max-width: 991px) {
    .mobile-center-only {
        text-align: center !important;
    }
}

/* Center on all devices */
.always-center {
    text-align: center !important;
    justify-content: center !important;
    align-items: center !important;
}

/* ==============================================
   FIX SCROLL TO TOP BUTTON ON MOBILE
   ============================================== */

@media (max-width: 991px) {
    /* Override scroll-to-top button */
    .btn-scroll-top {
        width: 55px !important;
        height: 55px !important;
        min-height: 55px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        bottom: 20px !important;
        left: 20px !important;
        font-size: 20px !important;
        display: none !important; /* Hidden by default */
        position: fixed !important;
        z-index: 9999 !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 8px 25px rgba(30, 64, 175, 0.5) !important;
    }
    
    .btn-scroll-top.show {
        display: flex !important;
    }
    
    .btn-scroll-top i {
        font-size: 20px;
        line-height: 1;
    }
}

@media (max-width: 575px) {
    /* Smaller on very small screens */
    .btn-scroll-top {
        width: 50px !important;
        height: 50px !important;
        min-height: 50px !important;
        bottom: 15px !important;
        left: 15px !important;
        font-size: 18px !important;
    }
    
    .btn-scroll-top i {
        font-size: 18px;
    }
}
