/* Mobile-First Responsive Design for ThemeLBd */

/* ===== MOBILE OPTIMIZATIONS ===== */

/* Enhanced Mobile Performance */
@media (max-width: 480px) {
    /* Improve image loading */
    img {
        max-width: 100%;
        height: auto;
        image-rendering: -webkit-optimize-contrast;
    }
    
    /* Better mobile typography */
    body {
        line-height: 1.6;
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Optimize scroll performance */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Better mobile header */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    /* Mobile-optimized posts */
    .post-content img {
        border-radius: 8px;
        margin: 1rem 0;
    }
    
    /* Better mobile spacing */
    .post-content p {
        margin-bottom: 1rem;
        font-size: 1rem;
        line-height: 1.6;
    }
    
    /* Mobile-friendly tables */
    .post-content table {
        font-size: 0.8rem;
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }
    
    /* Enhanced mobile navigation */
    .main-navigation.mobile-open {
        background: rgba(0, 0, 0, 0.95);
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 9999;
    }
    
    /* Better mobile content readability */
    .entry-content {
        font-size: 1rem;
        line-height: 1.7;
    }
    
    .entry-content h1 { font-size: 1.5rem; }
    .entry-content h2 { font-size: 1.3rem; }
    .entry-content h3 { font-size: 1.2rem; }
    .entry-content h4 { font-size: 1.1rem; }
    .entry-content h5 { font-size: 1rem; }
    .entry-content h6 { font-size: 0.9rem; }
}

/* Base Mobile Styles (up to 480px) */
@media (max-width: 480px) {
    /* Container & Layout */
    .container {
        padding: 0 10px;
        max-width: 100%;
    }
    
    /* Header Mobile */
    .site-header {
        padding: 0.5rem 0;
        position: relative;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .site-title {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }
    
    .site-description {
        font-size: 0.8rem;
        display: none; /* Hide on small screens */
    }    
    /* Header Search - Removed */
      /* Main Navigation Mobile - Sticky */
    .main-navigation {
        background: var(--menu-bg);
        border-top: 1px solid rgba(255,255,255,0.1);
        position: sticky;
        top: 0;
        z-index: 999;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Navigation container mobile - Full width trên mobile */
    .main-navigation .container {
        max-width: 100%;
        padding: 0;
    }
    
    .menu-toggle {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        background: none;
        border: none;
        color: var(--menu-text);
        font-size: 1rem;
        cursor: pointer;
    }
    
    .menu-toggle::after {
        content: '☰';
        font-size: 1.5rem;
    }
    
    .menu-toggle.active::after {
        content: '✕';
    }
    
    .primary-menu-container {
        display: none;
        width: 100%;
    }
    
    .primary-menu-container.active {
        display: block;
        animation: slideDown 0.3s ease;
    }
    
    .main-navigation .menu {
        flex-direction: column;
        gap: 0;
    }
    
    .main-navigation .menu a {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        text-align: left;
        font-size: 1rem;
        width: 100%;
    }
    
    .main-navigation .menu li:last-child a {
        border-bottom: none;
    }
    
    /* Main Content Mobile */
    .main-content {
        display: block; /* Override grid */
        gap: 1rem;
        margin: 1rem 0;
    }
    
    .content-area {
        order: 1;
        margin-bottom: 2rem;
        padding: 1rem;
        border-radius: 8px;
        background: var(--card-background, #fff);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .sidebar-left,
    .sidebar-right {
        order: 2;
        margin-bottom: 1rem;
        padding: 1rem;
        background: var(--sidebar-bg);
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Posts Grid Mobile */
    .posts-grid {
        grid-template-columns: 1fr; /* Single column on mobile, no !important */
        gap: 1rem;
    }
    
    .post-item {
        margin-bottom: 1rem;
        background: #fff;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .post-thumbnail {
        position: relative;
        overflow: hidden;
    }
    
    .post-thumbnail img {
        width: 100%;
        height: 200px;
        object-fit: cover;
    }
    
    .post-content {
        padding: 1rem;
    }
    
    .post-title {
        font-size: 1.1rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }
    
    .post-title a {
        color: var(--heading-color, #333);
        text-decoration: none;
    }
    
    .post-excerpt {
        font-size: 0.9rem;
        line-height: 1.5;
        color: var(--text-color, #666);
        margin-bottom: 1rem;
    }
    
    .post-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.8rem;
        color: var(--text-muted, #999);
    }
    
    .post-meta span {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
    
    /* Single Post Mobile */
    .single-post .entry-header {
        text-align: left;
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .single-post .entry-title {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }
    
    .single-post .entry-meta {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.75rem;
        font-size: 0.8rem;
    }
    
    .single-post .featured-image {
        margin: 1rem 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .single-post .featured-image img {
        width: 100%;
        height: auto;
        max-height: 250px;
        object-fit: cover;
    }
    
    /* Widgets Mobile */
    .widget {
        margin-bottom: 1.5rem;
        background: #fff;
        border: 1px solid var(--border-color, #e9ecef);
        border-radius: 8px;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    .widget-title {
        font-size: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid var(--accent-color, #3498db);
        color: var(--heading-color, #333);
    }
    
    /* Featured Posts Widget Mobile */
    .featured-post-item {
        flex-direction: column;
        padding: 1rem;
        margin-bottom: 1rem;
        background: #f8f9fa;
        border-radius: 6px;
    }
    
    .featured-post-thumbnail {
        width: 100%;
        height: 120px;
        margin-right: 0;
        margin-bottom: 0.75rem;
        border-radius: 6px;
        overflow: hidden;
    }
    
    .featured-post-thumbnail img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .featured-post-title {
        font-size: 1rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }
    
    .featured-post-title a {
        color: var(--heading-color, #333);
        text-decoration: none;
    }
    
    .featured-post-meta {
        font-size: 0.8rem;
        color: var(--text-muted, #999);
    }
    
    /* Footer Mobile */
    .site-footer {
        text-align: center;
        padding: 2rem 1rem;
    }
    
    .footer-widgets {
        display: block;
    }
    
    .footer-widget {
        margin-bottom: 2rem;
        text-align: left;
    }
    
    .footer-widget:last-child {
        margin-bottom: 0;
    }
    
    .footer-widget .widget-title {
        font-size: 1rem;
        margin-bottom: 1rem;
        text-align: center;
    }
    
    /* Buttons Mobile */
    .btn,
    .button,
    .load-more-btn {
        display: block;
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        text-align: center;
        border-radius: 8px;
        border: none;
        background: var(--accent-color, #3498db);
        color: white;
        cursor: pointer;
        transition: all 0.3s ease;
        margin: 1rem 0;
    }
    
    .btn:hover,
    .button:hover,
    .load-more-btn:hover {
        background: var(--accent-hover, #2980b9);
        transform: translateY(-2px);
    }
    
    /* Forms Mobile */
    .search-form,
    .contact-form {
        width: 100%;
    }
    
    .contact-form .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .contact-form input,
    .contact-form textarea {
        width: 100%;
        padding: 1rem;
        font-size: 16px; /* Prevent zoom on iOS */
        border: 1px solid var(--border-color, #ddd);
        border-radius: 8px;
        background: #fff;
    }
    
    .contact-form textarea {
        min-height: 120px;
        resize: vertical;
    }
    
    /* Comments Mobile */
    .comments-area {
        margin: 2rem 0;
        padding: 1rem;
    }
    
    .comment-list li {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
        background: #f8f9fa;
        border: 1px solid var(--border-color, #e9ecef);
    }
    
    .comment-list .children {
        margin-left: 1rem;
        margin-top: 1rem;
        padding-left: 1rem;
        border-left: 2px solid var(--accent-color, #3498db);
    }
    
    .comment-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .comment-author img {
        width: 40px;
        height: 40px;
    }
    
    .comment-form {
        padding: 1rem;
        background: #fff;
        border: 1px solid var(--border-color, #e9ecef);
        border-radius: 8px;
    }
    
    .comment-form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    /* Banner đã được handle trong style.css - removed để tránh xung đột */
    
    /* Archive & Search Results Mobile */
    .archive-header,
    .search-header {
        text-align: center;
        padding: 1rem;
        margin-bottom: 2rem;
        background: var(--card-background, #fff);
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .archive-title,
    .search-title {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
        color: var(--heading-color, #333);
    }
    
    .search-result-item {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    
    .result-thumbnail {
        width: 100%;
    }
    
    .result-thumbnail img {
        width: 100%;
        height: 150px;
        object-fit: cover;
        border-radius: 8px;
    }
    
    /* 404 Page Mobile */
    .error-404-page {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .error-title {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .error-description {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .error-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .links-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Accessibility Improvements */
    .skip-link {
        position: absolute;
        left: -9999px;
        z-index: 999999;
        padding: 8px 16px;
        background: var(--accent-color, #3498db);
        color: white;
        text-decoration: none;
    }
    
    .skip-link:focus {
        left: 6px;
        top: 7px;
    }
    
    /* Touch Improvements */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Prevent zoom on inputs */
    input[type="color"],
    input[type="date"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="email"],
    input[type="month"],
    input[type="number"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="text"],
    input[type="time"],
    input[type="url"],
    input[type="week"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Small Mobile (up to 360px) */
@media (max-width: 360px) {
    .container {
        padding: 0 8px;
    }
    
    .site-title {
        font-size: 1.1rem;
    }
    
    .post-title {
        font-size: 1rem;
    }
    
    .single-post .entry-title {
        font-size: 1.3rem;
    }
    
    /* Banner styles removed - handled in style.css */
    
    .widget {
        padding: 0.75rem;
    }
    
    .featured-post-item {
        padding: 0.75rem;
    }
}

/* Tablet Portrait (481px to 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .main-content {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .sidebar-left,
    .sidebar-right {
        display: block;
        order: 2;
    }
    
    .content-area {
        order: 1;
    }
    
    .site-title {
        font-size: 1.5rem;
    }
    
    /* Banner styles removed - handled in style.css */
    
    .single-post .entry-title {
        font-size: 2rem;
    }
    
    .footer-widgets {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

/* Tablet Landscape (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        grid-template-columns: 200px 1fr 200px;
        gap: 1.5rem;
    }
    
    .posts-grid {
        /* Default 2 columns on tablet, customizer JS will override if needed */
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .footer-widgets {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    .menu-toggle {
        display: none;
    }
    
    .primary-menu-container {
        display: block !important;
    }
    
    .main-navigation .menu {
        flex-direction: row;
    }
    
    .main-navigation .menu a {
        padding: 1rem 1.5rem;
        border-bottom: none;
    }
}

/* Animation for mobile menu */
@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* Loading states for mobile */
.mobile-loading {
    text-align: center;
    padding: 2rem;
}

.mobile-loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color, #e9ecef);
    border-top: 3px solid var(--accent-color, #3498db);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
}

/* Fix for iOS bounce scroll */
body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* Improve tap targets */
@media (hover: none) and (pointer: coarse) {
    a, button, [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ===== TABLET RESPONSIVE ===== */

@media (max-width: 768px) and (min-width: 481px) {
    /* Banner styles removed - handled in style.css */
}

/* ===== MOBILE DEBUG & UTILITIES ===== */

/* Mobile debugging (chỉ hiển thị trong development) */
@media (max-width: 768px) {
    .mobile-debug {
        position: fixed;
        top: 0;
        right: 0;
        background: rgba(255, 0, 0, 0.8);
        color: white;
        padding: 5px 10px;
        font-size: 12px;
        z-index: 99999;
        border-radius: 0 0 0 8px;
    }
    
    /* Show current breakpoint */
    .mobile-debug::before {
        content: 'Mobile: ' attr(data-breakpoint);
    }
}

/* Mobile utility classes */
@media (max-width: 480px) {
    .hide-on-mobile { display: none !important; }
    .show-on-mobile { display: block !important; }
    .mobile-center { text-align: center !important; }
    .mobile-full-width { width: 100% !important; }
    .mobile-no-padding { padding: 0 !important; }
    .mobile-no-margin { margin: 0 !important; }
}

/* Enhanced mobile performance optimizations */
@media (max-width: 768px) {
    /* GPU acceleration for smooth animations */
    .mobile-smooth {
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-perspective: 1000;
        perspective: 1000;
    }
    
    /* Optimize rendering */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-text-size-adjust: none;
    }
    
    /* Better mobile scrolling */
    .mobile-scroll {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Mobile-optimized animations */
    @keyframes mobileFadeIn {
        from { 
            opacity: 0; 
            transform: translateY(20px); 
        }
        to { 
            opacity: 1; 
            transform: translateY(0); 
        }
    }
    
    .mobile-fade-in {
        animation: mobileFadeIn 0.3s ease-out;
    }
}

/* Print styles for mobile */
@media print {
    .no-print,
    .mobile-menu,
    .sidebar,
    .search-form,
    .back-to-top,
    .social-links {
        display: none !important;
    }
    
    .main-content {
        display: block !important;
        width: 100% !important;
    }
    
    .post-content {
        font-size: 12pt !important;
        line-height: 1.4 !important;
    }
}
