/**
 * ToolStack Pro - Responsive Design (Upgraded v2.0)
 * Mobile-First + Website Sidebar + Full Responsive
 * Author: Mr Arslan CEO
 */

/* ================================================
   MOBILE SIDEBAR SYSTEM (Website)
   ================================================ */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mobile-sidebar-overlay.show { display: block; opacity: 1; }

.mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--bg-card);
    z-index: 2001;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 4px 0 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
}
.mobile-sidebar.show { transform: translateX(0); }

.mobile-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
    min-height: 64px;
}
.mobile-sidebar-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}
.mobile-sidebar-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.mobile-sidebar-nav {
    padding: 16px;
    flex: 1;
}
.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-bottom: 4px;
}
.mobile-nav-link:hover {
    background: rgba(102,126,234,0.08);
    color: var(--primary);
}
.mobile-nav-link.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-glow);
}
.mobile-nav-link .icon { font-size: 20px; width: 28px; text-align: center; }
.mobile-nav-link.signup-link {
    background: var(--gradient-primary);
    color: #fff;
    margin-top: 8px;
    justify-content: center;
    font-weight: 700;
}
.mobile-nav-link.logout-link:hover {
    background: rgba(255,107,107,0.08);
    color: #ff6b6b;
}

.mobile-sidebar-divider {
    height: 1px;
    background: var(--border-light);
    margin: 12px 0;
}

/* ================================================
   TABLET (max-width: 1024px)
   ================================================ */
@media (max-width: 1024px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
    }
    .hero-title { font-size: 40px; }
    .hero-stats { gap: 30px; }
    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    .pricing-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    .testimonials-grid {
        grid-template-columns: 1fr;
    }
    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================
   MOBILE LANDSCAPE (max-width: 768px)
   ================================================ */
@media (max-width: 768px) {
    .nav-links { display: none !important; }
    .nav-dashboard-link { display: none; }
    .btn-nav-outline { display: none; }
    .btn-nav-primary { display: none; }
    .nav-user-menu { display: none; }
    .mobile-menu-btn { display: flex !important; }

    .hero-section { padding: 70px 20px 60px; }
    .hero-title { font-size: 32px; }
    .hero-description { font-size: 15px; }
    .hero-buttons { flex-direction: column; }
    .hero-buttons .btn { width: 100%; }
    .hero-stats {
        flex-direction: column;
        gap: 20px;
    }

    .section { padding: 50px 20px; }
    .section-title { font-size: 28px; }

    .tools-grid { grid-template-columns: 1fr; }
    .blogs-grid { grid-template-columns: 1fr; }
    .categories-grid { grid-template-columns: 1fr; }
    .pricing-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    .footer-brand { text-align: center; }
    .footer-social { justify-content: center; }

    .page-header { padding: 40px 20px 30px; }
    .page-header h1 { font-size: 24px; }

    .search-bar { flex-direction: column; }
    .search-bar .form-control { max-width: 100% !important; }
    .filter-bar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
    .filter-btn { white-space: nowrap; flex-shrink: 0; }

    .tool-detail-card { flex-direction: column; text-align: center; }
    .tool-detail-actions { justify-content: center; flex-wrap: wrap; }
    .tool-detail-content { padding: 24px; }

    .blog-post-title { font-size: 26px; }
    .blog-post-meta { flex-direction: column; gap: 8px; }

    .auth-card { padding: 30px 20px; }
    .form-row { grid-template-columns: 1fr !important; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    .theme-switcher-float { bottom: 20px; right: 20px; }
    .theme-panel { width: 200px; right: -10px; }

    .pagination { flex-wrap: wrap; }
    .featured-carousel { gap: 16px; }
    .featured-carousel .tool-card { min-width: 280px; }

    /* Touch-friendly buttons */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    .form-control { min-height: 44px; font-size: 16px; } /* Prevents zoom on iOS */
    select.form-control { min-height: 44px; }
}

/* ================================================
   MOBILE PORTRAIT (max-width: 480px)
   ================================================ */
@media (max-width: 480px) {
    .nav-container { padding: 0 16px; }
    .nav-logo { font-size: 18px; }
    .logo-icon { width: 32px; height: 32px; font-size: 15px; }

    .hero-section { padding: 50px 16px 50px; }
    .hero-title { font-size: 26px; }
    .hero-badge { font-size: 11px; padding: 6px 14px; }

    .section { padding: 40px 16px; }
    .section-title { font-size: 22px; }

    .tool-card { padding: 20px; }
    .tool-logo { width: 46px; height: 46px; }
    .tool-name { font-size: 15px; }

    .pricing-card { padding: 28px 20px; }
    .pricing-amount { font-size: 36px; }

    .blog-card-body { padding: 18px; }
    .blog-card-title { font-size: 16px; }

    .btn { padding: 12px 24px; font-size: 14px; }
    .btn-lg { padding: 14px 28px; font-size: 15px; }

    .stat-card { padding: 18px; }
    .stat-icon { width: 44px; height: 44px; font-size: 20px; }
    .stat-info h3 { font-size: 20px; }

    .share-buttons { flex-wrap: wrap; }
    .comment-item { flex-direction: column; gap: 8px; }

    .flash-message {
        left: 16px;
        right: 16px;
        top: 80px;
    }

    .testimonial-card { padding: 24px; }
    .testimonials-grid { gap: 16px; }
    .faq-question { padding: 16px 18px; font-size: 14px; }
    .faq-answer-inner { padding: 0 18px 16px; }
}

/* ================================================
   SMALL MOBILE (max-width: 360px)
   ================================================ */
@media (max-width: 360px) {
    .hero-title { font-size: 22px; }
    .hero-stat .num { font-size: 24px; }
    .section-title { font-size: 20px; }
    .mobile-sidebar { width: 260px; }
    .tool-card-header { gap: 10px; }
    .pricing-card { padding: 20px 16px; }
}

/* ================================================
   LARGE SCREENS (min-width: 1400px)
   ================================================ */
@media (min-width: 1400px) {
    .container { max-width: 1400px; }
    .tools-grid { grid-template-columns: repeat(4, 1fr); }
    .hero-title { font-size: 58px; }
}

/* ================================================
   PRINT STYLES
   ================================================ */
@media print {
    .main-nav, .site-footer, .theme-switcher-float,
    .flash-message, .mobile-menu-btn, .mobile-sidebar,
    .mobile-sidebar-overlay { display: none !important; }
    .main-content { padding-top: 0; }
    .tool-card, .blog-card, .pricing-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ================================================
   ACCESSIBILITY - Reduced Motion
   ================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
