/**
 * Responsive Alignment & Layout Fix
 * إصلاح المحاذاة والتخطيط المتجاوب
 * 
 * This file ensures consistent alignment and layout across all devices
 */

/* ========================================
   HIDE SCROLLBARS (Keep functionality)
   ======================================== */

/* Hide scrollbar for Chrome, Safari and Opera */
*::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Hide scrollbar for IE, Edge and Firefox */
* {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Ensure body and html hide scrollbar */
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    width: 0;
}

html,
body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ========================================
   BASE FIXES - Apply to All Devices
   ======================================== */

* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

.container,
.container-fluid {
    max-width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

.row {
    margin-right: -15px;
    margin-left: -15px;
}

[class*="col-"] {
    padding-right: 15px;
    padding-left: 15px;
}

/* Prevent text overflow */
h1, h2, h3, h4, h5, h6, p, span, div, a, li {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Images responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   TOP BAR - Responsive
   ======================================== */

.top-bar {
    padding: 10px 0;
}

.top-bar .container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.top-bar .row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0;
    flex-wrap: wrap;
    gap: 15px;
}

.top-bar-right,
.top-bar-left {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.top-bar .col-auto {
    display: flex;
    align-items: center;
    justify-content: center;
}

#current-date {
    font-size: 14px;
    white-space: nowrap;
}

.social-links {
    display: flex;
    gap: 10px;
}

.social-links a {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   HEADER - Logo and Navigation
   ======================================== */

.main-header {
    padding: 20px 0;
    position: relative;
    z-index: 999;
    background: #fff;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    min-height: 80px;
}

.main-header .container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Sticky header on scroll */
.main-header.sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease;
    min-height: 60px;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Add padding to body when header is sticky to prevent content jump */
body.header-sticky {
    padding-top: 80px;
}

.site-logo {
    font-size: clamp(24px, 5vw, 36px);
    margin: 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.navbar {
    padding: 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.navbar-toggler {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    order: 2;
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .navbar-toggler {
    right: auto;
    left: 0;
    margin-left: 0;
    margin-right: auto;
}

.navbar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-item {
    margin: 0;
    display: flex;
    align-items: center;
}

.nav-link {
    padding: 8px 15px;
    white-space: nowrap;
    font-size: clamp(14px, 2vw, 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.nav-link i {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   BREAKING NEWS BAR
   ======================================== */

.breaking-news {
    width: 100%;
    overflow: hidden;
}

.breaking-news-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 50px;
}

.breaking-badge {
    flex-shrink: 0;
    white-space: nowrap;
}

.breaking-news-content {
    flex: 1;
    overflow: hidden;
}

/* ========================================
   NEWS CARDS - Grid Layout
   ======================================== */

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.news-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.news-card-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.news-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.news-card-title {
    font-size: clamp(16px, 2.5vw, 20px);
    line-height: 1.4;
    margin-bottom: 10px;
}

.news-card-description {
    font-size: clamp(14px, 2vw, 16px);
    line-height: 1.6;
    flex: 1;
}

.news-card-footer {
    margin-top: auto;
    padding-top: 15px;
}

/* ========================================
   SIDEBAR WIDGETS
   ======================================== */

.sidebar-widget {
    margin-bottom: 25px;
    padding: 20px;
}

.widget-title {
    font-size: clamp(18px, 3vw, 22px);
    margin-bottom: 15px;
}

/* Weather Widget */
.weather-widget {
    text-align: center;
}

.weather-temp {
    font-size: clamp(36px, 6vw, 48px);
}

.weather-city {
    font-size: clamp(16px, 2.5vw, 20px);
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

/* Currency Widget */
.currency-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 10px;
}

.currency-name {
    font-size: clamp(14px, 2vw, 16px);
}

.currency-value {
    font-size: clamp(16px, 2.5vw, 18px);
    font-weight: bold;
}

/* ========================================
   FOOTER - Always Centered
   ======================================== */

.main-footer {
    width: 100%;
    padding: 40px 0 20px;
}

.footer-links,
.footer-contact {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li,
.footer-contact li {
    padding: 8px 0;
    text-align: center;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.footer-social a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
}

.copyright {
    font-size: clamp(12px, 1.5vw, 14px);
    margin: 0;
}

/* ========================================
   TABLET - 768px to 991px
   ======================================== */

@media (max-width: 991px) {
    /* Adjust container padding */
    .container,
    .container-fluid {
        padding-right: 20px;
        padding-left: 20px;
    }
    
    /* News grid - 2 columns */
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    /* Top bar - center alignment */
    .top-bar .container {
        justify-content: center;
        align-items: center;
        gap: 15px;
    }
    
    .top-bar .row {
        justify-content: center;
        align-items: center;
        gap: 15px;
    }
    
    .top-bar-right,
    .top-bar-left {
        justify-content: center;
        align-items: center;
    }
    
    /* Navigation - wrap better */
    .navbar-nav {
        gap: 8px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* ========================================
   MOBILE - Up to 767px
   ======================================== */

@media (max-width: 767px) {
    /* Container - more padding */
    .container,
    .container-fluid {
        padding-right: 15px;
        padding-left: 15px;
    }
    
    /* Top bar - center alignment on mobile */
    .top-bar .container {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    .top-bar .row {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    .top-bar-right,
    .top-bar-left {
        width: 100%;
        justify-content: center;
        align-items: center;
    }
    
    .date-time {
        margin-left: 0;
        justify-content: center;
    }
    
    .top-bar-left span[style*="color: #999"] {
        display: none; /* Hide separator on mobile */
    }
    
    /* Header - center logo and align vertically */
    .main-header {
        text-align: center;
        padding: 15px 0;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 70px;
    }
    
    .main-header .container {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }
    
    /* Sticky header on mobile - more compact */
    .main-header.sticky {
        padding: 10px 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        min-height: 60px;
    }
    
    .main-header.sticky .site-logo {
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .main-header.sticky .navbar {
        padding: 10px 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .main-header.sticky .nav-link {
        padding: 8px 12px;
        font-size: 13px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Adjust body padding for sticky header on mobile */
    body.header-sticky {
        padding-top: 120px;
    }
    
    .site-logo {
        font-size: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
    }
    
    .navbar-brand {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
    
    /* Navigation - full width and vertically centered */
    .navbar {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        position: relative;
    }
    
    .navbar-toggler {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        order: 2;
        margin-left: auto;
        margin-right: 0;
    }
    
    [dir="rtl"] .navbar-toggler {
        right: auto;
        left: 15px;
        margin-left: 0;
        margin-right: auto;
    }
    
    .navbar-nav {
        width: 100%;
        flex-direction: column;
        gap: 5px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-item {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
        padding: 12px 15px;
        font-size: 15px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .nav-link i {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Breaking news - smaller badge */
    .breaking-badge {
        font-size: 13px;
        padding: 10px 15px;
    }
    
    /* News grid - 1 column */
    .news-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .news-card-img {
        height: 200px;
    }
    
    .news-card-title {
        font-size: 18px;
    }
    
    .news-card-description {
        font-size: 15px;
    }
    
    /* Sidebar - full width */
    .sidebar-widget {
        margin-bottom: 20px;
        padding: 15px;
    }
    
    /* Weather widget */
    .weather-temp {
        font-size: 42px;
    }
    
    .weather-details {
        gap: 10px;
    }
    
    /* Footer - stack everything */
    .main-footer .row {
        text-align: center;
    }
    
    .footer-links li,
    .footer-contact li {
        text-align: center;
    }
    
    .footer-menu {
        flex-direction: column;
        gap: 10px;
    }
}

/* ========================================
   SMALL MOBILE - Up to 480px
   ======================================== */

@media (max-width: 480px) {
    /* Even more compact */
    .container,
    .container-fluid {
        padding-right: 10px;
        padding-left: 10px;
    }
    
    /* Top bar - very compact */
    #current-date {
        font-size: 12px;
    }
    
    .social-links a {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    /* Logo - smaller */
    .site-logo {
        font-size: 24px;
    }
    
    /* Navigation links - compact */
    .nav-link {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    /* Breaking news - very compact */
    .breaking-badge {
        font-size: 11px;
        padding: 8px 12px;
    }
    
    .breaking-news-content marquee {
        font-size: 13px;
    }
    
    /* News cards - more compact */
    .news-card {
        margin-bottom: 15px;
    }
    
    .news-card-img {
        height: 180px;
    }
    
    .news-card-body {
        padding: 15px;
    }
    
    .news-card-title {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .news-card-description {
        font-size: 14px;
    }
    
    /* Sidebar */
    .sidebar-widget {
        padding: 12px;
    }
    
    .widget-title {
        font-size: 18px;
    }
    
    /* Weather */
    .weather-temp {
        font-size: 36px;
    }
    
    .weather-city {
        font-size: 16px;
    }
    
    /* Currency */
    .currency-item {
        padding: 10px;
        font-size: 13px;
    }
    
    .currency-name {
        font-size: 13px;
    }
    
    .currency-value {
        font-size: 15px;
    }
    
    /* Footer */
    .footer-social a {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .copyright {
        font-size: 12px;
    }
}

/* ========================================
   EXTRA SMALL - Up to 360px
   ======================================== */

@media (max-width: 360px) {
    /* Maximum compactness for very small screens */
    .container,
    .container-fluid {
        padding-right: 8px;
        padding-left: 8px;
    }
    
    .site-logo {
        font-size: 20px;
    }
    
    .nav-link {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .news-card-img {
        height: 160px;
    }
    
    .news-card-title {
        font-size: 15px;
    }
    
    .weather-temp {
        font-size: 32px;
    }
    
    .footer-social a {
        width: 32px;
        height: 32px;
    }
}

/* ========================================
   LARGE DESKTOP - 1200px and up
   ======================================== */

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    /* News grid - 3 columns */
    .news-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
    
    .news-card-img {
        height: 240px;
    }
}

/* ========================================
   EXTRA LARGE DESKTOP - 1400px and up
   ======================================== */

@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    /* News grid - can handle 4 columns if needed */
    .news-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 35px;
    }
}

/* ========================================
   UTILITY CLASSES - Universal
   ======================================== */

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-left {
    text-align: left !important;
}

.d-flex {
    display: flex !important;
}

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

.align-items-center {
    align-items: center !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.w-100 {
    width: 100% !important;
}

.h-100 {
    height: 100% !important;
}

/* Prevent horizontal scroll on all elements */
body > * {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Ensure all containers respect viewport */
.container,
.container-fluid,
.row,
[class*="col-"] {
    max-width: 100%;
    overflow-x: hidden;
}
