/**
 * Mobile-First Design - شهدای دانشجو
 * طراحی جداگانه و زیبا برای موبایل (صفحه اصلی + معرفی شهید)
 * Breakpoint: max-width 768px
 */

@media (max-width: 768px) {
    /* ========== Global Mobile ========== */
    :root {
        --mobile-gap: 16px;
        --mobile-radius: 16px;
        --mobile-radius-sm: 12px;
        --mobile-shadow: 0 4px 24px rgba(47, 45, 105, 0.08);
        --mobile-touch: 48px;
        --safe-top: env(safe-area-inset-top, 0);
        --safe-bottom: env(safe-area-inset-bottom, 0);
    }

    .container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: var(--safe-bottom);
    }

    .main-content {
        padding-top: 12px;
        padding-bottom: max(24px, var(--safe-bottom));
        min-height: auto;
    }

    /* ========== Header Mobile ========== */
    .top-header {
        padding: 12px 0;
        padding-top: max(12px, var(--safe-top));
    }

    .top-header-content {
        flex-direction: column;
        gap: 14px;
        align-items: stretch;
    }

    .header-logo {
        justify-content: center;
    }

    .logo-img {
        width: 56px;
        height: 36px;
    }

    .logo-text {
        font-size: 1rem;
    }

    .header-search {
        max-width: 100%;
        margin: 0;
    }

    .search-input-group {
        border-radius: 12px;
    }

    .search-input {
        padding: 14px 16px;
        font-size: 16px; /* prevent zoom on focus iOS */
    }

    .advanced-search-btn {
        align-self: center;
        padding: 10px 20px;
        border-radius: 10px;
        min-height: var(--mobile-touch);
    }

    /* Navbar mobile - ensure nav toggle and menu work */
    .navbar .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .nav-toggle {
        min-width: var(--mobile-touch);
        min-height: var(--mobile-touch);
    }

    .nav-link,
    .membership-btn {
        min-height: var(--mobile-touch);
        padding: 14px 16px;
        display: inline-flex;
        align-items: center;
        font-size: 15px;
    }

    /* ========== HOMEPAGE - Mobile Layout ========== */
    /* ترتیب ثابت: پوستر → نقشه شهدا → اخبار → سایر ویجت‌ها → سایدبار (دو سکشن فقط) */
    .homepage-layout {
        display: flex;
        flex-direction: column;
        gap: 20px;
        margin-top: 16px;
    }

    .homepage-layout .main-column {
        order: 0 !important;
        min-width: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .homepage-layout .main-column > .image-slider,
    .homepage-layout .main-column > .image-slider.image-slider-in-column {
        order: 1 !important;
    }
    .homepage-layout .main-column > .news-section {
        order: 2 !important;
    }
    .homepage-layout .main-column > .iran-map-section {
        order: 3 !important;
    }
    .homepage-layout .main-column > .quote-widget-container {
        order: 4 !important;
    }
    .homepage-layout .main-column > .stats-widget-container {
        order: 5 !important;
    }

    .homepage-layout .sidebar-left {
        width: 100%;
        order: 10 !important;
    }

    /* ----- پوستر/اسلایدر: نسبت مستطیلی ۱۶:۹ (عرض بیشتر از ارتفاع)، نه مربع ----- */
    .main-column .image-slider.image-slider-in-column,
    .three-column-layout .image-slider {
        margin-left: calc(-1 * max(16px, env(safe-area-inset-left)));
        margin-right: calc(-1 * max(16px, env(safe-area-inset-right)));
        width: calc(
            100%
            + max(16px, env(safe-area-inset-left))
            + max(16px, env(safe-area-inset-right))
        );
        max-width: 100vw;
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 20px;
    }

    .main-column .image-slider-in-column .slider-container,
    .homepage-layout .slider-container {
        width: 100%;
        /* نسبت مستطیلی ۱۶:۹ (عرض بیشتر از ارتفاع)؛ 56.25vw = ۹/۱۶ عرض */
        height: 56.25vw;
        min-height: 180px;
        max-height: 320px;
    }

    .slide-content {
        padding: 16px 20px;
        margin: 0 12px;
        border-radius: 14px;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        max-width: 92%;
    }

    .slide-content h1 {
        font-size: 1.25rem;
        margin-bottom: 6px;
        line-height: 1.35;
    }

    .slide-content p {
        font-size: 0.875rem;
        line-height: 1.5;
        opacity: 0.95;
    }

    .prev-btn, .next-btn {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
        padding: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    }

    .slider-indicators {
        bottom: 14px;
        gap: 8px;
    }

    .indicator {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        border-width: 2px;
    }

    /* ----- Iran Map Section Mobile ----- */
    .iran-map-section {
        border-radius: var(--mobile-radius);
        padding: 16px;
        margin-bottom: 20px;
        box-shadow: var(--mobile-shadow);
    }

    .iran-map-section h2 {
        font-size: 1.05rem;
        padding: 14px 16px;
        border-radius: var(--mobile-radius-sm);
        margin-bottom: 14px;
    }

    .iran-map,
    .iran-map svg {
        height: 320px;
        min-height: 280px;
        border-radius: var(--mobile-radius-sm);
    }

    /* ----- News Section - Card style mobile ----- */
    .news-section.section-pattern-news,
    .news-section {
        border-radius: var(--mobile-radius);
        margin-bottom: 20px;
        box-shadow: var(--mobile-shadow);
    }

    .news-section h2 {
        font-size: 1.05rem;
        padding: 1rem 1.2rem;
        border-radius: 12px 12px 0 0;
    }

    .news-item {
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid #eee;
        padding-right: 0;
    }

    .news-item:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }

    .news-item-content {
        flex-direction: column;
        gap: 12px;
    }

    .news-item-image {
        flex: none;
        width: 100%;
        height: 180px;
        border-radius: var(--mobile-radius-sm);
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    .news-item-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .news-item-text h3 {
        font-size: 1.05rem;
        font-weight: 700;
        line-height: 1.45;
        margin-bottom: 8px;
        color: #2F2D69;
    }

    .news-item-text p {
        font-size: 0.9rem;
        line-height: 1.65;
        color: #555;
        margin-bottom: 12px;
    }

    .read-more {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 10px 18px;
        min-height: 44px;
        background: #1AAB9E;
        color: white !important;
        border-radius: 10px;
        font-weight: 600;
        font-size: 0.9rem;
        box-shadow: 0 4px 14px rgba(26, 171, 158, 0.35);
        transition: transform 0.2s, box-shadow 0.2s;
    }

    .read-more:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 18px rgba(26, 171, 158, 0.4);
    }

    /* ----- Quote Widget Mobile ----- */
    .quote-widget-container .widget.quote-widget {
        border-radius: var(--mobile-radius);
        overflow: hidden;
        box-shadow: var(--mobile-shadow);
    }

    .quote-widget .widget-content {
        padding: 20px 18px;
    }

    .quote-text {
        font-size: 0.95rem;
        line-height: 1.8;
    }

    .quote-icon {
        font-size: 1.5rem;
    }

    .quote-author {
        font-size: 0.875rem;
    }

    /* ----- Stats Widget Mobile ----- */
    .stats-widget-container .widget.stats-widget {
        border-radius: var(--mobile-radius);
        box-shadow: var(--mobile-shadow);
    }

    .stats-widget .widget-header {
        padding: 14px 16px;
    }

    .stats-widget .widget-header h3 {
        font-size: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 14px;
        border-radius: var(--mobile-radius-sm);
        gap: 12px;
        min-height: 72px;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        font-size: 1.1rem;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* ----- Sidebars Mobile (Left + Right) ----- */
    .sidebar-section {
        border-radius: var(--mobile-radius);
        margin-bottom: 16px;
        box-shadow: var(--mobile-shadow);
    }

    .sidebar-section h3 {
        font-size: 1rem;
        padding: 1rem 1.2rem;
        border-radius: 12px 12px 0 0;
    }

    /* Left sidebar - special categories: horizontal scroll or compact list */
    .sidebar-left .special-categories {
        max-height: 280px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-left: 4px;
    }

    .sidebar-left .special-categories li a {
        padding: 12px 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
        border-radius: 10px;
        margin-bottom: 6px;
        background: rgba(248, 249, 250, 0.9);
    }

    .sidebar-left .special-categories li a:hover {
        background: rgba(26, 171, 158, 0.1);
    }

    /* Martyrs sliders in sidebars - touch friendly */
    .martyrs-slider-container {
        height: 260px;
    }

    .martyr-grid {
        gap: 8px;
        padding: 6px;
    }

    .martyr-card {
        padding: 8px;
        border-radius: 10px;
        min-height: 0;
    }

    .martyr-image {
        height: 70px;
        border-radius: 8px;
    }

    .martyr-name {
        font-size: 11px;
        line-height: 1.3;
        height: auto;
        margin-top: 4px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .martyrs-prev-btn, .martyrs-next-btn,
    .featured-prev-btn, .featured-next-btn,
    .non-iranian-martyrs-prev-btn, .non-iranian-martyrs-next-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 1.1rem;
    }

    .featured-martyr-card {
        padding: 12px;
        border-radius: var(--mobile-radius-sm);
    }

    .featured-martyr-image {
        height: 120px;
        border-radius: 10px;
    }

    .featured-martyr-name {
        font-size: 0.95rem;
    }

    .featured-view-link {
        padding: 8px 14px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    .non-iranian-martyr-card {
        padding: 12px;
        border-radius: var(--mobile-radius-sm);
    }

    .non-iranian-martyr-image {
        height: 80px;
        border-radius: 10px;
    }

    .view-all-link {
        margin-top: 12px;
    }

    .view-all-text {
        display: inline-flex;
        align-items: center;
        padding: 12px 20px;
        min-height: 44px;
        border-radius: 10px;
        font-weight: 600;
    }

    /* Popular links mobile */
    .popular-links li {
        margin-bottom: 10px;
    }

    .popular-link {
        padding: 14px 16px;
        min-height: 56px;
        border-radius: 12px;
    }

    .popular-link .logo-img {
        width: 40px;
        height: 40px;
    }

    .popular-link span {
        font-size: 0.9rem;
    }

    /* Commanders & Resistance sliders (left sidebar) */
    .commanders-slider-container,
    .resistance-slider-container {
        padding: 0 4px;
    }

    .commander-card,
    .resistance-martyr-card {
        padding: 12px;
        border-radius: 12px;
        min-height: 60px;
    }

    .commander-image,
    .resistance-martyr-image {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .commander-name,
    .resistance-martyr-name {
        font-size: 0.9rem;
    }
}

/* ========== MARTYR PROFILE PAGE - Mobile ========== */
@media (max-width: 768px) {
    .martyr-profile-header {
        border-radius: var(--mobile-radius);
        padding: 20px 16px;
        margin-bottom: 20px;
        margin-left: 0;
        margin-right: 0;
        box-shadow: var(--mobile-shadow);
    }

    .martyr-header-content {
        grid-template-columns: 1fr;
        gap: 20px;
        text-align: center;
    }

    .martyr-image-section {
        order: 0;
    }

    .martyr-image-container {
        width: 140px;
        height: 140px;
        margin: 0 auto;
        border-width: 4px;
        border-radius: 50%;
        box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    }

    .martyr-image-overlay {
        border-radius: 50%;
    }

    /* Show overlay + badge on mobile by default (no hover) */
    .martyr-image-container .martyr-image-overlay {
        opacity: 0.92;
    }
    .martyr-image-container .martyr-badge {
        background: rgba(255,255,255,0.98);
        color: #2F2D69;
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 0.85rem;
    }

    .martyr-info-section {
        order: 1;
    }

    .martyr-name {
        font-size: 1.2rem;
        font-weight: 800;
        margin-bottom: 16px;
        padding-right: 0;
        text-align: center;
        line-height: 1.4;
    }

    /* گرید داینامیک: دو ستون، آیتم‌های کوتاه کنار هم، فشرده */
    .martyr-details-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .detail-item {
        padding: 8px 10px;
        border-radius: 10px;
        min-height: 0;
        flex-direction: row;
        text-align: right;
        background: rgba(255,255,255,0.15);
        border: 1px solid rgba(255,255,255,0.25);
        align-items: center;
        gap: 8px;
    }

    .detail-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        border-radius: 8px;
        font-size: 0.8rem;
    }

    .detail-content {
        min-width: 0;
        overflow: hidden;
    }

    .detail-label {
        font-size: 0.7rem;
        margin-bottom: 0;
        line-height: 1.3;
        opacity: 0.9;
    }

    .detail-value {
        font-size: 0.85rem;
        line-height: 1.35;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Profile content grid: single column, sidebar on top */
    .profile-content-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .profile-sidebar {
        order: -1;
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Sidebar sections as cards */
    .qr-code-section,
    .related-martyrs-section,
    .share-section {
        border-radius: var(--mobile-radius);
        padding: 18px;
        box-shadow: var(--mobile-shadow);
    }

    .qr-code-section h3,
    .related-martyrs-section h3,
    .share-section h3 {
        font-size: 1rem;
        margin-bottom: 14px;
    }

    .qr-code-image {
        padding: 14px;
        border-radius: 12px;
    }

    .qr-code-image img {
        width: 140px;
        height: 140px;
    }

    .qr-description {
        font-size: 0.85rem;
    }

    /* Share buttons: 2x2 grid, big touch targets */
    .share-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .share-btn {
        padding: 14px 16px;
        min-height: 52px;
        border-radius: 12px;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .share-btn i {
        font-size: 1.25rem;
    }

    /* Related martyrs list */
    .related-martyr-item {
        padding: 14px;
        border-radius: 12px;
        min-height: 72px;
    }

    .related-martyr-image {
        width: 56px;
        height: 56px;
        border-radius: 12px;
    }

    .related-martyr-info h4 {
        font-size: 0.95rem;
    }

    .related-martyr-info p {
        font-size: 0.8rem;
    }

    /* Main content sections */
    .biography-section,
    .testimony-section,
    .gallery-section,
    .comments-section {
        border-radius: var(--mobile-radius);
        padding: 18px;
        margin-bottom: 18px;
        box-shadow: var(--mobile-shadow);
    }

    .section-header {
        padding: 14px 16px;
        border-radius: var(--mobile-radius-sm);
        margin-bottom: 16px;
        flex-direction: row;
        gap: 12px;
    }

    .section-header h2 {
        font-size: 1rem;
    }

    .section-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .biography-content p,
    .testimony-quote p {
        font-size: 0.95rem;
        line-height: 1.85;
    }

    .testimony-quote {
        padding: 18px;
        border-radius: 12px;
        border-right-width: 4px;
    }

    /* Gallery grid: 2 columns on mobile */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .gallery-item {
        border-radius: 12px;
        overflow: hidden;
    }

    .gallery-item img {
        height: 140px;
        object-fit: cover;
    }

    .gallery-overlay i {
        font-size: 1.5rem;
    }

    /* Comments */
    .comment-item {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .comment-header {
        margin-bottom: 8px;
    }

    .author-avatar {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    .author-info h4 {
        font-size: 0.95rem;
    }

    .comment-content p {
        font-size: 0.9rem;
        line-height: 1.65;
    }

    .like-btn {
        padding: 10px 16px;
        min-height: 40px;
        border-radius: 24px;
        font-size: 0.85rem;
    }

    .add-comment-section {
        padding: 18px;
        border-radius: var(--mobile-radius);
        margin-top: 18px;
    }

    .add-comment-section h3 {
        font-size: 1rem;
    }

    .form-group textarea {
        padding: 14px;
        border-radius: 12px;
        font-size: 16px; /* prevent zoom iOS */
        min-height: 120px;
    }

    .submit-btn {
        padding: 14px 24px;
        min-height: 50px;
        border-radius: 14px;
        font-size: 0.95rem;
        width: 100%;
        justify-content: center;
    }

    /* Lightbox mobile */
    .lightbox-content {
        max-width: 96%;
        padding: 12px;
    }

    .lightbox-close {
        top: -44px;
        right: 8px;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .lightbox-download {
        padding: 14px 20px;
        min-height: 48px;
        border-radius: 14px;
        width: 100%;
        justify-content: center;
    }
}

/* ========== Extra small devices (optional) ========== */
@media (max-width: 480px) {
    .container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .main-column .image-slider-in-column .slider-container,
    .slider-container {
        min-height: 220px;
    }

    .slide-content h1 {
        font-size: 1.1rem;
    }

    .slide-content p {
        font-size: 0.8125rem;
    }

    .iran-map,
    .iran-map svg {
        height: 260px;
    }

    .news-item-image {
        height: 160px;
    }

    .martyr-image-container {
        width: 120px;
        height: 120px;
    }

    .martyr-name {
        font-size: 1.1rem;
    }

    .martyr-details-grid {
        gap: 6px;
    }

    .detail-item {
        padding: 6px 8px;
    }

    .detail-icon {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        font-size: 0.75rem;
    }

    .detail-label {
        font-size: 0.65rem;
    }

    .detail-value {
        font-size: 0.8rem;
    }

    .gallery-grid {
        gap: 8px;
    }

    .gallery-item img {
        height: 110px;
    }

    .share-buttons {
        grid-template-columns: 1fr;
    }

    .share-btn {
        min-height: 48px;
    }
}

/* ========== Footer Mobile ========== */
@media (max-width: 768px) {
    .footer .container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(20px, var(--safe-bottom));
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
        text-align: center;
    }

    .footer-section h3,
    .footer-section h4 {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .footer-section p,
    .footer-section ul li a {
        font-size: 0.9rem;
    }

    .footer-section ul li {
        margin-bottom: 8px;
    }

    .footer-bottom {
        padding-top: 20px;
        padding-bottom: max(16px, var(--safe-bottom));
    }

    .footer-bottom p {
        font-size: 0.85rem;
        line-height: 1.6;
    }
}
