/*
 * ملف CSS محسن للتجاوب - موقع مجمع المدارس
 * تم إنشاؤه لتحسين التجاوب على جميع الأجهزة
 */

/* ============================================
   تحسينات عامة للتجاوب ومقاومة التمدد الأفقي
   ============================================ */

html, body {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    position: relative;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* تحسين الخطوط للأجهزة المحمولة */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.3rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
}

/* تحسين الأزرار للأجهزة المحمولة */
@media (max-width: 768px) {
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        min-height: 44px; /* الحد الأدنى للمس */
        min-width: 44px;
    }
    
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    
    .btn-lg {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }
}

/* ============================================
   تحسينات الهيدر والتوجيه
   ============================================ */

/* تحسين الهيدر للأجهزة المحمولة */
@media (max-width: 768px) {
    .site-header {
        padding: 0.5rem 0;
    }
    
    .site-title {
        font-size: 1.2rem;
    }
    
    .site-subtitle {
        font-size: 0.8rem;
    }
    
    .site-logo img {
        width: 60px;
        height: 60px;
    }
    
    .partner-logo-item img {
        width: 40px;
        height: 40px;
    }
}

/* تحسين القائمة للأجهزة المحمولة */
@media (max-width: 991.98px) {
    .main-navbar .navbar-collapse {
        background-color: #1a237e;
        border-radius: 0 0 10px 10px;
        padding: 1rem;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        margin-top: 0.5rem;
    }
    
    .main-navbar .nav-link {
        padding: 0.8rem 1rem;
        margin-bottom: 0.3rem;
        border-radius: 6px;
        font-size: 0.9rem;
    }
    
    .main-navbar .nav-link.active::after {
        display: none;
    }
    
    .search-form {
        width: 100%;
        margin: 0.5rem 0;
    }
    
    .search-input {
        font-size: 0.9rem;
        padding: 0.7rem 1rem;
    }
    
    .login-btn {
        margin-top: 0.5rem;
        width: 100%;
        border-radius: 6px;
        height: auto;
        padding: 0.6rem;
    }
}

/* تحسين شريط الأخبار العاجلة */
@media (max-width: 768px) {
    .breaking-news {
        flex-direction: column;
        align-items: flex-start;
        position: relative;
        padding: 0.5rem 0;
    }
    
    .breaking-news-label {
        margin-bottom: 0.5rem;
        align-self: flex-start;
        font-size: 0.8rem;
        padding: 0.3rem 0.8rem;
    }
    
    .breaking-news-ticker {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .ticker-item {
        font-size: 0.85rem;
        padding: 0 1rem;
    }
    
    .breaking-news-controls {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        display: flex;
        gap: 0.5rem;
    }
    
    .ticker-control {
        width: 35px;
        height: 35px;
        font-size: 0.8rem;
        min-height: 44px;
        min-width: 44px;
    }
}

@media (max-width: 480px) {
    .breaking-news {
        padding: 0.3rem 0;
    }
    
    .breaking-news-label {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }
    
    .ticker-item {
        font-size: 0.8rem;
        padding: 0 0.8rem;
    }
    
    .breaking-news-controls {
        top: 0.3rem;
        right: 0.3rem;
    }
    
    .ticker-control {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
        min-height: 44px;
        min-width: 44px;
    }
}

/* ============================================
   تحسينات الصفحة الرئيسية
   ============================================ */

/* تحسين السلايدر للأجهزة المحمولة */
@media (max-width: 768px) {
    .carousel-item {
        height: 300px;
    }
    
    .carousel-caption {
        bottom: 1rem;
        padding: 0.8rem;
        max-width: 95%;
    }
    
    .carousel-caption h2 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .carousel-caption p {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
    }
    
    .carousel-caption .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* تحسين قسم الترحيب */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 0;
        text-align: center;
    }
    
    .hero-section h2 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }
    
    .hero-section p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .hero-section .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* تحسين بطاقة الأخبار المهمة */
@media (max-width: 768px) {
    .featured-news-card {
        margin-top: 1rem;
    }
    
    .featured-news-header {
        padding: 1rem;
    }
    
    .featured-news-title {
        font-size: 1.2rem;
    }
    
    .featured-news-content {
        padding: 1rem;
    }
    
    .featured-news-image {
        height: 150px;
    }
}

/* ============================================
   تحسينات البطاقات والكروت
   ============================================ */

/* تحسين بطاقات الأنشطة */
@media (max-width: 768px) {
    .activity-card {
        margin-bottom: 1rem;
    }
    
    .activity-card .card-img-top {
        height: 200px;
    }
    
    .activity-card .card-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .activity-card .card-text {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
    }
    
    .activity-type {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

/* تحسين بطاقات المنشورات */
@media (max-width: 768px) {
    .post-card {
        margin-bottom: 1rem;
    }
    
    .post-card .card-img-top {
        height: 180px;
    }
    
    .post-card .card-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .post-card .card-text {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
    }
}

/* ============================================
   تحسينات النماذج
   ============================================ */

/* تحسين النماذج للأجهزة المحمولة */
@media (max-width: 768px) {
    .form-control {
        font-size: 16px; /* منع التكبير التلقائي على iOS */
        padding: 0.8rem;
        border-radius: 6px;
    }
    
    .form-label {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
    }
    
    .form-text {
        font-size: 0.8rem;
    }
    
    .form-check-label {
        font-size: 0.9rem;
    }
    
    .form-select {
        font-size: 16px;
        padding: 0.8rem;
    }
}

/* تحسين أزرار النماذج */
@media (max-width: 768px) {
    .form-control:focus {
        box-shadow: 0 0 0 0.2rem rgba(30, 136, 229, 0.25);
    }
    
    .btn-primary {
        width: 100%;
        margin-top: 1rem;
    }
    
    .btn-secondary {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* ============================================
   تحسينات المعرض
   ============================================ */

/* تحسين معرض الصور */
@media (max-width: 768px) {
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
    }
    
    .gallery-item img {
        height: 150px;
        border-radius: 6px;
    }
    
    .gallery-item:hover {
        transform: scale(1.02);
    }
}

/* ============================================
   تحسينات الجداول
   ============================================ */

/* تحسين الجداول للأجهزة المحمولة */
@media (max-width: 768px) {
    .table-responsive {
        border: none;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.3rem;
    }
}

/* ============================================
   تحسينات التصفح (Pagination)
   ============================================ */

/* تحسين أزرار التصفح */
@media (max-width: 768px) {
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .page-item {
        margin: 0.2rem;
    }
    
    .page-link {
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
        min-width: 44px;
        text-align: center;
    }
}

/* ============================================
   تحسينات الفوتر
   ============================================ */

/* تحسين الفوتر للأجهزة المحمولة */
@media (max-width: 768px) {
    .footer {
        text-align: center;
        padding: 2rem 0;
    }
    
    .footer h5 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .footer p,
    .footer a {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .footer .row > div {
        margin-bottom: 2rem;
    }
}

/* ============================================
   تحسينات إضافية للأجهزة الصغيرة جداً
   ============================================ */

@media (max-width: 576px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .col,
    [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-text {
        font-size: 0.85rem;
    }
}

/* ============================================
   تحسينات للأجهزة اللوحية
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 960px;
    }
    
    .hero-section {
        padding: 3.5rem 0;
    }
    
    .hero-section h2 {
        font-size: 2.5rem;
    }
    
    .carousel-caption h2 {
        font-size: 2.5rem;
    }
    
    .carousel-item {
        height: 450px;
    }
    
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .gallery-item img {
        height: 200px;
    }
    
    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
    }
    
    .form-control {
        font-size: 16px;
        padding: 0.9rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.8rem 1.2rem;
        font-size: 0.95rem;
    }
}

/* ============================================
   تحسينات للحواسيب والشاشات المتوسطة
   ============================================ */

@media (min-width: 1024px) and (max-width: 1199px) {
    .container {
        max-width: 1140px;
    }
    
    .hero-section {
        padding: 4rem 0;
    }
    
    .hero-section h2 {
        font-size: 2.8rem;
    }
    
    .carousel-caption h2 {
        font-size: 2.8rem;
    }
    
    .carousel-item {
        height: 500px;
    }
    
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
    
    .gallery-item img {
        height: 220px;
    }
    
    .btn {
        padding: 0.8rem 1.8rem;
        font-size: 1rem;
    }
    
    .form-control {
        font-size: 16px;
        padding: 1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }
}

/* ============================================
   تحسينات للشاشات الكبيرة
   ============================================ */

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .hero-section {
        padding: 5rem 0;
    }
    
    .hero-section h2 {
        font-size: 3rem;
    }
    
    .carousel-caption h2 {
        font-size: 3rem;
    }
    
    .carousel-item {
        height: 600px;
    }
    
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    
    .gallery-item img {
        height: 250px;
    }
    
    .btn {
        padding: 1rem 2rem;
        font-size: 1.1rem;
    }
    
    .form-control {
        font-size: 16px;
        padding: 1.1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1.2rem 1.8rem;
        font-size: 1.1rem;
    }
}

/* ============================================
   تحسينات للشاشات الكبيرة جداً
   ============================================ */

@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-section {
        padding: 6rem 0;
    }
    
    .hero-section h2 {
        font-size: 3.5rem;
    }
    
    .carousel-caption h2 {
        font-size: 3.5rem;
    }
    
    .carousel-item {
        height: 700px;
    }
    
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }
    
    .gallery-item img {
        height: 280px;
    }
    
    .btn {
        padding: 1.2rem 2.5rem;
        font-size: 1.2rem;
    }
    
    .form-control {
        font-size: 18px;
        padding: 1.2rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1.5rem 2rem;
        font-size: 1.2rem;
    }
    
    .site-title {
        font-size: 2.5rem;
    }
    
    .site-subtitle {
        font-size: 1.2rem;
    }
    
    .site-logo img {
        width: 100px;
        height: 100px;
    }
    
    .partner-logo-item img {
        width: 80px;
        height: 80px;
    }
}

/* =========================================================================
   تنسيقات متقدمة وشاملة مخصصة لجهاز iPad Pro 13" (Portrait 1024px / Landscape 1366px)
   وكذلك iPad Pro 12.9" و iPad Pro M4 (1032px / 1376px)
   ضمان التناسق الكامل 100% وإلغاء أي فراغات أو تفاوت في أبعاد البطاقات والصور
   ========================================================================= */

/* 1. الوضع الرأسي لـ iPad Pro 13 (Portrait: 1024px - 1199px) */
@media screen and (min-width: 992px) and (max-width: 1199.98px),
       screen and (min-width: 1024px) and (max-width: 1035px) and (orientation: portrait),
       screen and (min-device-width: 1024px) and (max-device-width: 1366px) and (orientation: portrait),
       screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 1024px) and (max-width: 1199.98px) {

    /* الحاوية الأساسية */
    .container {
        max-width: 980px !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* ضمان تمدد البطاقات وتساوي ارتفاعاتها */
    .post-card,
    .activity-card,
    .project-card {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* حاويات صور البطاقات */
    .post-card .card-img-wrapper,
    .activity-card .card-img-wrapper {
        height: 240px !important;
        min-height: 240px !important;
        width: 100% !important;
        position: relative !important;
        overflow: hidden !important;
    }

    /* صور البطاقات - ملء 100% دون أي بكسل فراغ */
    .post-card .card-img-top,
    .activity-card .card-img-top,
    .project-card .card-img {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        display: block !important;
    }

    /* المنشور المميز (posts.php) - تثبيت تام للصورة مع ارتفاع النص */
    .featured-post .row {
        align-items: stretch !important;
    }

    .featured-post .featured-img-col {
        position: relative !important;
        min-height: 100% !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .featured-post .featured-img-wrapper,
    .featured-post .featured-img {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
    }

    .featured-post .card-body {
        padding: 2.2rem 2rem !important;
    }

    .featured-post .card-title {
        font-size: 1.55rem !important;
        line-height: 1.4 !important;
    }

    .featured-post .card-text {
        font-size: 1.05rem !important;
        line-height: 1.7 !important;
        margin-bottom: 1.25rem !important;
    }

    /* صفحة تفاصيل المنشور الفردي (post.php) */
    .featured-image-container {
        min-height: 440px !important;
        height: 460px !important;
        width: 100% !important;
        border-radius: 20px !important;
        margin-bottom: 2rem !important;
    }

    .detail-image {
        width: 100% !important;
        height: 100% !important;
        min-height: 440px !important;
        max-height: 460px !important;
        object-fit: cover !important;
        object-position: center !important;
    }

    .post-content {
        padding: 2.5rem 2.2rem !important;
        font-size: 1.12rem !important;
        line-height: 2 !important;
    }

    .post-detail-title {
        font-size: 2.2rem !important;
        line-height: 1.35 !important;
    }

    /* السلايدر الرئيسي في الصفحة الرئيسية */
    #mainCarousel .carousel-inner {
        height: 560px !important;
    }

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

    .hero-subtitle {
        font-size: 1.15rem !important;
    }

    /* بطاقة الترحيب */
    .welcome-card {
        padding: 2.5rem 2rem !important;
    }

    .welcome-heading {
        font-size: 2.25rem !important;
    }
}

/* 2. الوضع الأفقي لـ iPad Pro 13 (Landscape: 1200px - 1399px) */
@media screen and (min-width: 1200px) and (max-width: 1399.98px),
       screen and (min-width: 1360px) and (max-width: 1376px) and (orientation: landscape),
       screen and (min-device-width: 1024px) and (max-device-width: 1366px) and (orientation: landscape),
       screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 1200px) and (max-width: 1399.98px) {

    .container {
        max-width: 1280px !important;
    }

    .post-card .card-img-wrapper,
    .activity-card .card-img-wrapper {
        height: 260px !important;
        min-height: 260px !important;
    }

    .post-card .card-img-top,
    .activity-card .card-img-top,
    .project-card .card-img {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        object-fit: cover !important;
    }

    .featured-post .row {
        align-items: stretch !important;
    }

    .featured-post .featured-img-col {
        position: relative !important;
        min-height: 100% !important;
        height: 100% !important;
    }

    .featured-post .featured-img-wrapper,
    .featured-post .featured-img {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        object-fit: cover !important;
    }

    .featured-image-container {
        min-height: 480px !important;
        height: 500px !important;
        width: 100% !important;
    }

    .detail-image {
        width: 100% !important;
        height: 100% !important;
        min-height: 480px !important;
        max-height: 500px !important;
        object-fit: cover !important;
    }

    #mainCarousel .carousel-inner {
        height: 640px !important;
    }
}

/* ============================================
   تحسينات للطباعة
   ============================================ */

@media print {
    .navbar,
    .footer,
    .btn,
    .carousel,
    .breaking-news-container {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000;
        page-break-after: avoid;
    }
    
    .card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}
