/* ==============================================
   RESPONSIVE.CSS — All @media breakpoints
   (panel layout, tables, forms, mobile sidebar)
   ============================================== */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }

    .form-control,
    .form-select {
        font-size: 16px !important;
    }
}

/* ---------- TABLET 1024px ---------- */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
        width: calc(100vw - 220px);
    }

    .content-header h1 {
        font-size: 1.4rem;
    }

    .table thead th,
    .table tbody td {
        padding: 9px 8px !important;
        font-size: 0.88rem;
    }
}

/* ---------- MOBILE 768px ---------- */
@media (max-width: 768px) {
    /* Sidebar offcanvas */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 85vw;
        max-width: 300px;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1050;
        transition: transform 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.open,
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 6px 0 24px rgba(0,0,0,0.4);
    }

    /* Hamburger → X animacja */
    .mobile-menu-toggle.is-open .hamburger span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .mobile-menu-toggle.is-open .hamburger span:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    .mobile-menu-toggle.is-open .hamburger span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .mobile-overlay.active {
        display: block;
    }

    .mobile-menu-toggle {
        display: flex !important;
        width: 48px;
        height: 48px;
        top: 12px;
        left: 12px;
    }

    /* Main content — full width */
    .main-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
        padding-top: 72px;
    }

    .content-header {
        padding: 12px 16px 12px 68px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 900;
    }

    .content-header h1 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100vw - 120px);
    }

    .content-inner {
        padding: 12px;
    }

    /* Filters */
    .content-filters { padding: 10px 12px; }

    .input-group {
        flex-direction: column;
    }

    .input-group .form-control {
        min-width: 100%;
        margin-bottom: 8px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    /* Buttons — touch-friendly */
    .btn {
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm {
        min-height: 36px;
        padding: 6px 10px !important;
    }

    /* Table */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Wskazówka że jest scroll */
        background:
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
            radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.1), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.1), rgba(0,0,0,0)) 0 100%;
        background-repeat: no-repeat;
        background-color: white;
        background-size: 40px 100%, 40px 100%, 8px 100%, 8px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    .table {
        min-width: 800px;
    }

    .table thead th,
    .table tbody td {
        padding: 9px 7px !important;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .table .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .table .btn-sm {
        padding: 4px 8px !important;
        font-size: 0.73rem !important;
    }

    /* Cards */
    .card { margin-bottom: 14px; }
    .card-header { padding: 10px 14px; font-size: 0.95rem; }
    .card-body  { padding: 14px; }

    .badge {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .alert {
        padding: 11px 14px;
        font-size: 0.88rem;
    }
}

/* ---------- SMALL MOBILE 480px ---------- */
@media (max-width: 480px) {
    .content-header {
        padding: 10px 14px 10px 58px;
    }

    .content-header h1 {
        font-size: 0.95rem;
    }

    .content-inner {
        padding: 10px;
    }

    .table {
        min-width: 600px;
    }

    /* Hide extra columns on very small screens */
    .table thead th:nth-child(n+7),
    .table tbody td:nth-child(n+7) {
        display: none;
    }

    .btn {
        font-size: 0.82rem;
        padding: 7px 12px;
    }
}

/* ---------- LANDSCAPE MOBILE ---------- */
@media (max-width: 768px) and (orientation: landscape) {
    .content-header {
        padding: 8px 14px 8px 58px;
    }

    .content-header h1 {
        font-size: 1rem;
    }

    .table thead th,
    .table tbody td {
        padding: 7px 6px !important;
        font-size: 0.79rem;
    }
}

/* ---------- DASHBOARD (1100px) ---------- */
@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-actions__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ---------- DASHBOARD (768px) ---------- */
@media (max-width: 768px) {
    .dashboard-hero__content {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid,
    .dashboard-grid,
    .status-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-list__item {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-list__item span {
        text-align: left;
    }

    /* Client list hybrid */
    .desktop-only { display: none; }
    .mobile-only  { display: block; }
}

/* ---------- DASHBOARD (480px) ---------- */
@media (max-width: 480px) {
    .quick-actions__grid {
        grid-template-columns: 1fr;
    }

    .dashboard-hero {
        padding: 20px;
    }

    .dashboard-hero h1 {
        font-size: 1.6rem;
    }
}
