/* =====================================================
   FREEWORKDZ v2.0 – RESPONSIVE (Mobile-First)
   ===================================================== */

/* ══════════════════════════════════════════════════════
   TABLET  768 px +
══════════════════════════════════════════════════════ */
@media (min-width: 768px) {
    .container     { max-width: 720px; }
    .container-lg  { padding: 0 1.5rem; }

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

    .hero h1 { font-size: 2.75rem; }
    .hero p  { font-size: 1.15rem; }

    .search-bar { max-width: 600px; margin: 0 auto; }
    .dashboard-main { padding: 2.5rem; }
}

/* ══════════════════════════════════════════════════════
   DESKTOP  1024 px +
══════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
    .container    { max-width: 960px; }
    .container-lg { max-width: 1200px; }

    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }

    .hero { padding: 6rem 0; }
    .hero h1 { font-size: 3rem; }

    .sidebar               { display: block; }
    .mobile-sidebar-overlay { display: none !important; }
}

/* ══════════════════════════════════════════════════════
   LARGE DESKTOP  1440 px +
══════════════════════════════════════════════════════ */
@media (min-width: 1440px) {
    .container    { max-width: 1280px; }
    .container-lg { max-width: 1280px; }
}


/* ══════════════════════════════════════════════════════
   MOBILE  ≤ 900 px   (navbar breakpoint)
══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    /* Already handled inside header.php inline <style>
       (navbar-nav collapses to mobile drawer) */

    .nav-right .nav-link:not(.btn) {
        display: none; /* hide text nav links when drawer active */
    }
}


/* ══════════════════════════════════════════════════════
   MOBILE  ≤ 767 px
══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    :root {
        --navbar-height: 62px;
        --sidebar-width: 280px;
    }

    /* ── Typography ── */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.4rem; }
    h3 { font-size: 1.2rem; }

    /* ── Sections ── */
    .section  { padding: 2.5rem 0; }
    .hero     { padding: 2.5rem 0; }
    .hero h1  { font-size: 1.75rem; }
    .hero p   { font-size: 0.95rem; }

    /* ── Container ── */
    .container,
    .container-lg { padding: 0 1rem; }

    /* ── Grids → single column ── */
    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; gap: 1rem; }

    /* ── Cards ── */
    .card:hover { transform: none; }
    .card-body  { padding: 1rem; }

    /* ── Buttons ── */
    .btn-group      { flex-direction: column; }
    .btn-lg         { padding: 0.875rem 1.25rem; font-size: 0.95rem; }

    /* ── Page header ── */
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .page-title  { font-size: 1.35rem; }

    /* ── Stats bar ── */
    .stat-card     { padding: 1.25rem; }
    .stat-number   { font-size: 1.5rem; }

    /* ── Tables ── */
    .table-wrapper          { font-size: 0.825rem; }
    .table th, .table td    { padding: 0.65rem 0.75rem; }
    /* Hide less-important columns on mobile via utility */
    .table .hide-mobile     { display: none; }

    /* ── Forms ── */
    .form-control { font-size: 0.9rem; padding: 0.65rem 0.875rem; }
    .form-group   { margin-bottom: 1rem; }

    /* ── Search / filter bars ── */
    .search-bar            { flex-direction: column; border-radius: 1rem; }
    .search-bar input      { border-radius: 0.875rem; }
    .search-bar .btn       { border-radius: 0.875rem; width: 100%; }

    /* inline filter bars (missions / search pages) */
    .filter-bar-form .filter-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    .filter-bar-form .filter-row > * {
        min-width: 100% !important;
        flex: none !important;
    }

    /* ── Auth ── */
    .auth-container { padding: 1rem; }
    .auth-card      { border-radius: 1rem; padding: 1.5rem; }

    /* ── Upgrade banner ── */
    .upgrade-banner {
        text-align: center;
        flex-direction: column;
        padding: 1.5rem;
    }
    .upgrade-banner .btn { width: 100%; }

    /* ── Pagination ── */
    .pagination     { gap: 0.25rem; flex-wrap: wrap; justify-content: center; }
    .page-link      { min-width: 36px; height: 36px; font-size: 0.82rem; }

    /* ── Pricing / Subscription cards ── */
    .pricing-card     { margin-bottom: 1.25rem; padding: 1.5rem; }
    .price-amount     { font-size: 2rem; }

    /* ── Dashboard layout ── */
    .dashboard-layout { flex-direction: column; }
    .dashboard-main   { padding: 1rem; min-width: 0; }

    /* ── Sidebar: slide-in drawer on mobile ── */
    .sidebar {
        position: fixed;
        top: 0; left: -100%;
        width: var(--sidebar-width);
        max-width: 85vw;
        height: 100%;
        z-index: 2000;
        transition: left 0.28s cubic-bezier(.4,0,.2,1);
        box-shadow: 0 0 40px rgba(0,0,0,.18);
        padding-top: calc(var(--navbar-height) + 0.5rem);
        overflow-y: auto;
        background: white;
    }
    .sidebar.open { left: 0; }

    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        backdrop-filter: blur(2px);
        z-index: 1999;
    }
    .mobile-sidebar-overlay.open { display: block; }

    /* Sidebar toggle button (shown in dashboard pages) */
    .sidebar-toggle-btn {
        display: inline-flex !important;
    }

    /* ── Freelancer profile hero ── */
    .profile-hero        { min-height: 160px; padding: 2rem 1rem 0; }
    .profile-stats-bar   {
        margin: -2rem 1rem 0 !important;
        border-radius: 1rem !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
    }
    .profile-stats-bar .stat-item {
        border-right: 1px solid #e2e8f0;
        border-bottom: 1px solid #e2e8f0;
        padding: 0.875rem 0.75rem !important;
    }
    .profile-stats-bar .stat-item:nth-child(2n) { border-right: none; }
    .profile-stats-bar .stat-item:nth-child(3),
    .profile-stats-bar .stat-item:nth-child(4)  { border-bottom: none; }

    .profile-avatar-wrap { width: 80px !important; height: 80px !important; }
    .profile-avatar-wrap img { width: 80px !important; height: 80px !important; }

    .profile-grid { grid-template-columns: 1fr !important; gap: 1rem !important; }
    .profile-sidebar { order: -1; }

    /* ── Messages ── */
    .messages-layout        { flex-direction: column; }
    .messages-list-panel    { width: 100% !important; height: 320px; border-right: none !important; border-bottom: 1px solid #e2e8f0; }
    .messages-chat-panel    { height: calc(100vh - 400px); min-height: 300px; }

    /* ── Footer ── */
    footer .grid-4,
    footer .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
    footer         { padding: 2.5rem 0 1.5rem; }
}


/* ══════════════════════════════════════════════════════
   SMALL MOBILE  ≤ 480 px
══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .container,
    .container-lg { padding: 0 0.75rem; }

    .btn-lg { padding: 0.875rem 1.25rem; font-size: 0.95rem; }

    /* Stat cards */
    .stat-card    { padding: 1rem; }
    .stat-number  { font-size: 1.35rem; }

    /* Profile stats 2→2 already, make values smaller */
    .profile-stats-bar .stat-value  { font-size: 1.2rem !important; }
    .profile-stats-bar .stat-label  { font-size: 0.7rem !important; }

    /* Freelancer profile avatar smaller */
    .profile-avatar-wrap { width: 68px !important; height: 68px !important; }
    .profile-avatar-wrap img { width: 68px !important; height: 68px !important; }

    /* Search / freelancer cards */
    .freelancer-search-card .card-header-area { padding: 1.25rem 1rem !important; }

    /* Footer → 1 column */
    footer .grid-4,
    footer .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    footer .footer-bottom { align-items: flex-start; flex-direction: column; }

    /* Tables – allow horizontal scroll only */
    .table-wrapper { overflow-x: scroll; -webkit-overflow-scrolling: touch; }

    /* Pricing period toggle */
    .billing-toggle-wrap {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    /* Modal */
    .modal-inner { padding: 1.25rem !important; }
    .modal-inner .modal-header { padding: 1rem 1.25rem !important; }
}


/* ══════════════════════════════════════════════════════
   UTILITY: hide / show per breakpoint
══════════════════════════════════════════════════════ */
@media (max-width: 767px)  { .hide-mobile  { display: none !important; } }
@media (min-width: 768px)  { .show-mobile  { display: none !important; } }
@media (max-width: 1023px) { .hide-tablet  { display: none !important; } }
@media (min-width: 768px) and (max-width: 1023px) { .show-tablet { display: block !important; } }

/* Sidebar toggle button – hidden on desktop by default */
.sidebar-toggle-btn { display: none; }


/* ══════════════════════════════════════════════════════
   TOUCH-FRIENDLY IMPROVEMENTS (all mobile)
══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    /* Minimum tap target 44 × 44 px */
    .btn      { min-height: 44px; }
    .btn-sm   { min-height: 40px; }
    .nav-link { min-height: 44px; display: flex; align-items: center; }

    /* Smooth momentum scrolling */
    .table-wrapper,
    .sidebar,
    .messages-list-panel { -webkit-overflow-scrolling: touch; }

    /* Remove sticky hover effects that look broken on touch */
    .card:hover      { box-shadow: var(--shadow-md); transform: none; }
    .btn:hover       { transform: none; }
    .sidebar-link:hover { background: #eff6ff; }
}


/* ══════════════════════════════════════════════════════
   DASHBOARD — MOBILE SIDEBAR TOGGLE BUTTON
   (injected by dashboard pages)
══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .dashboard-mobile-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }
    .dashboard-mobile-header .page-title { margin: 0; }
}


/* ══════════════════════════════════════════════════════
   ADMIN PAGES
══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* Admin stats row */
    .admin-stats-row { grid-template-columns: 1fr 1fr !important; gap: 0.75rem; }

    /* Admin table actions → icon-only */
    .table .btn-sm span { display: none; }
    .table .btn-sm      { padding: 0.4rem 0.5rem !important; min-width: 34px; }
}


/* ══════════════════════════════════════════════════════
   ABONNEMENT / PRICING PAGE
══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
        max-width: 400px;
        margin: 0 auto;
    }
    .pricing-card.featured { transform: none !important; }
}


/* ══════════════════════════════════════════════════════
   PRINT
══════════════════════════════════════════════════════ */
@media print {
    .navbar, .sidebar, footer,
    .upgrade-banner, .mobile-sidebar-overlay { display: none !important; }
    .dashboard-main { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
