/* ================================================
   NEXTERA AUTOMOTIVE — Responsive Overrides
   Comprehensive mobile / tablet breakpoints for
   Admin panels, Dashboard, Tables, Forms, Nav
   ================================================
   Breakpoints:
     1024px — tablet landscape
      768px — tablet portrait
      640px — large phone
      480px — small phone
   ================================================ */

/* ========================================
   1. NAVIGATION — Mobile Burger Animation
   ======================================== */

/* Burger → X transform when menu open */
.nav__burger.is-active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav__burger.is-active span:nth-child(2) {
    opacity: 0;
}

.nav__burger.is-active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ========================================
   1b. NAVIGATION — Mobile Layout
   ======================================== */

@media (max-width: 768px) {
    /* Shrink nav height */
    .nav__container {
        height: 60px;
    }

    /* === Mobile open menu: include nav links AND action items === */
    .nav__links--open {
        top: 60px;
        padding-bottom: 12px;
    }

    /* Add dashboard/admin links into mobile menu */
    .nav__links--open::after {
        content: '';
        display: block;
        height: 1px;
        background: var(--border-color);
        margin: 8px 0;
    }

    /* Compact action icons in header bar */
    .nav__actions {
        gap: 4px;
    }

    .nav__divider {
        display: none;
    }

    /* Hide text-based lang name in button */
    .lang-switcher__btn span:not([class]) {
        /* Keep the label but shrink */
    }
    .lang-switcher__btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .nav__icon-btn {
        width: 28px;
        height: 28px;
    }

    .nav__avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    /* === Mobile dropdowns: bottom-sheet style === */
    .nav__admin-dropdown,
    .nav__user-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        min-width: 100%;
        max-height: 70vh;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 16px);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
        animation: slideUpSheet 0.25s var(--ease-out);
    }

    @keyframes slideUpSheet {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Larger tap targets on mobile */
    .nav__admin-link {
        padding: 14px 20px;
        font-size: 15px;
    }

    .nav__user-action {
        padding: 14px 20px;
        font-size: 15px;
    }

    .nav__user-info {
        padding: 18px 20px 12px;
    }

    .nav__user-email {
        font-size: 14px;
    }

    /* Add a grab handle indicator to bottom-sheet */
    .nav__admin-dropdown::before,
    .nav__user-dropdown::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--gray-300);
        border-radius: 2px;
        margin: 10px auto 6px;
    }
}

/* Very small phones: hide dashboard icon, keep admin and user */
@media (max-width: 380px) {
    .nav__actions > a.nav__icon-btn[title="Dashboard"] {
        display: none;
    }

    .lang-switcher__btn {
        padding: 3px 6px;
    }

    .lang-switcher__btn > i:last-child {
        display: none;
    }
}

/* ========================================
   2. ADMIN HEADER — Responsive Button Row
   ======================================== */

@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .admin-header__title {
        font-size: 1.5rem;
    }

    /* Target the inline-styled button groups in admin headers */
    .admin-header > div:last-child,
    .admin-header > div[style*="display:flex"] {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px !important;
        width: 100%;
    }

    .admin-header .btn {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        font-size: 12px;
        padding: 8px 12px;
    }

    .admin-header .btn--primary {
        flex: 1 1 100%;
        order: -1;
    }
}

@media (max-width: 480px) {
    .admin-header__title {
        font-size: 1.25rem;
    }

    .admin-header .btn {
        font-size: 11px;
        padding: 7px 10px;
    }
}

/* ========================================
   3. ADMIN TABLES — Horizontal Scroll
   All tables inside cards get scroll wrapper
   ======================================== */

/* Universal table scroll containers */
.admin-table-wrap,
.adm-card__body--flush,
.dash-card__body--table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Scroll shadow hint on the right side */
.admin-table-wrap,
.adm-card__body--flush,
.dash-card__body--table {
    position: relative;
}

@media (max-width: 768px) {
    /* Ensure tables don't collapse */
    .admin-table {
        min-width: 600px;
    }

    /* Slightly tighter cell padding */
    .admin-table th,
    .admin-table td {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }

    .admin-table th {
        font-size: 0.6875rem;
    }

    /* Permissions table too */
    .perm-table {
        min-width: 500px;
    }

    .perm-table th,
    .perm-table td {
        padding: 10px 12px;
    }
}

/* ========================================
   4. ADMIN TABLES — Card View for < 480px
   Transform table rows into stacked cards
   for the MAIN admin list pages
   ======================================== */

@media (max-width: 480px) {
    /* Main admin list tables (UserAdmin, FileAdmin, BlogAdmin Index) 
       Use a data-responsive attribute or override via parent */
    .admin-section > .container > .admin-table-wrap .admin-table {
        min-width: 0;
    }

    .admin-section > .container > .admin-table-wrap .admin-table thead {
        display: none;
    }

    .admin-section > .container > .admin-table-wrap .admin-table tbody tr {
        display: block;
        padding: 16px;
        border-bottom: 1px solid var(--gray-100);
        position: relative;
    }

    .admin-section > .container > .admin-table-wrap .admin-table tbody tr:last-child {
        border-bottom: none;
    }

    .admin-section > .container > .admin-table-wrap .admin-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 0;
        border-bottom: none;
        font-size: 0.8125rem;
    }

    .admin-section > .container > .admin-table-wrap .admin-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.725rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        flex-shrink: 0;
        margin-right: 12px;
    }

    /* Title cell takes full width */
    .admin-section > .container > .admin-table-wrap .admin-table td:first-child {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--gray-100);
    }

    .admin-section > .container > .admin-table-wrap .admin-table td:first-child::before {
        display: none;
    }

    /* Actions row at bottom */
    .admin-section > .container > .admin-table-wrap .admin-actions {
        justify-content: flex-end;
        margin-top: 8px;
    }
}

/* ========================================
   5. ADMIN STAT CARDS — Enhanced Mobile
   ======================================== */

@media (max-width: 640px) {
    .adm-stat {
        padding: 16px 18px;
        gap: 12px;
    }

    .adm-stat__icon {
        width: 40px;
        height: 40px;
    }

    .adm-stat__number {
        font-size: 1.25rem;
    }

    .adm-stat__label {
        font-size: 0.675rem;
    }

    .adm-stat__sub {
        flex-wrap: wrap;
    }

    .adm-stat__link {
        top: 12px;
        right: 12px;
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .adm-stat {
        padding: 14px 14px;
    }

    .adm-stat__number {
        font-size: 1.1rem;
        word-break: break-word;
    }
}

/* ========================================
   6. ADMIN ROW / GRID — Stacking
   ======================================== */

@media (max-width: 768px) {
    .adm-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dash-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ========================================
   7. QUICK ACTIONS — Grid Fix
   ======================================== */

@media (max-width: 480px) {
    .adm-quick {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .adm-quick__item {
        padding: 14px 8px;
        font-size: 0.725rem;
    }

    .adm-quick__ico {
        width: 36px;
        height: 36px;
    }
}

/* ========================================
   8. CHART — Mobile Readability
   ======================================== */

@media (max-width: 640px) {
    .adm-chart {
        height: 100px;
    }

    .adm-chart__axis {
        font-size: 0.6rem;
    }
}

/* ========================================
   9. CARD HEADER — Wrap on Mobile
   ======================================== */

@media (max-width: 640px) {
    .adm-card__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px 18px;
    }

    .dash-card__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px 18px;
    }
}

/* ========================================
   10. FORMS — Full Responsive
   ======================================== */

@media (max-width: 640px) {
    /* blog-admin form rows */
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* admin form styles */
    .admin-form {
        padding: 16px;
    }

    .admin-form__row {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .admin-form__textarea {
        min-height: 200px;
    }

    /* Form actions stack */
    .admin-form__actions,
    .form-actions {
        flex-direction: column;
    }

    .admin-form__actions .btn,
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Language tabs scroll */
    .admin-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        gap: 0;
    }

    .admin-tab {
        padding: 10px 14px;
        font-size: 0.8125rem;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .admin-form {
        padding: 12px;
    }

    .admin-form__input,
    .form-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
        padding: 10px 12px;
    }

    .admin-form__label,
    .form-label {
        font-size: 0.75rem;
    }

    /* Search form full-width */
    .admin-search > div[style*="max-width"] {
        max-width: 100% !important;
    }
}

/* ========================================
   11. ADMIN SECTION — Mobile Padding
   ======================================== */

@media (max-width: 768px) {
    .admin-section {
        padding: 80px 0 40px;
    }

    .dash-section {
        padding: 80px 0 40px;
    }
}

@media (max-width: 480px) {
    .admin-section {
        padding: 70px 0 32px;
    }

    .dash-section {
        padding: 70px 0 32px;
    }

    .container {
        padding: 0 16px;
    }
}

/* ========================================
   12. DELETE CONFIRM — Mobile
   ======================================== */

@media (max-width: 480px) {
    .admin-confirm {
        padding: 32px 20px;
    }

    .admin-confirm__actions {
        flex-direction: column;
    }

    .admin-confirm__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   13. UPLOAD ZONE — Mobile
   ======================================== */

@media (max-width: 480px) {
    .upload-zone {
        padding: 28px 16px;
    }
}

/* ========================================
   14. DASHBOARD PROFILE — Stacking
   ======================================== */

@media (max-width: 480px) {
    .dash-profile-row {
        flex-direction: column;
        gap: 4px;
    }

    .dash-profile-row__value {
        font-size: 0.9rem;
    }
}

/* ========================================
   15. DASHBOARD RESOURCES — Mobile
   ======================================== */

@media (max-width: 480px) {
    .dash-res-item {
        padding: 12px;
        gap: 10px;
    }

    .dash-res-item__text strong {
        font-size: 0.825rem;
    }

    .dash-res-item__text span {
        font-size: 0.7rem;
    }
}

/* ========================================
   16. PERMISSIONS — Mobile
   ======================================== */

@media (max-width: 640px) {
    .perm-roles {
        gap: 6px;
    }

    .perm-role-badge {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .perm-note {
        font-size: 0.75rem;
        padding: 10px 12px;
    }

    /* Make perm table scrollable */
    .dash-card__body:has(.perm-table),
    .dash-card__body--table:has(.perm-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   17. BADGES — Prevent Overflow
   ======================================== */

@media (max-width: 480px) {
    .admin-badge {
        font-size: 0.675rem;
        padding: 2px 8px;
        white-space: nowrap;
    }
}

/* ========================================
   18. PAGINATION — Mobile
   ======================================== */

@media (max-width: 480px) {
    .blog-pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .blog-pagination__page {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
}

/* ========================================
   19. ALERTS — Mobile
   ======================================== */

@media (max-width: 480px) {
    .admin-alert {
        font-size: 0.8rem;
        padding: 10px 14px;
    }
}

/* ========================================
   20. BREADCRUMBS — Mobile Scroll
   ======================================== */

@media (max-width: 480px) {
    .breadcrumbs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .breadcrumbs__item {
        flex-shrink: 0;
    }
}

/* ========================================
   21. AUTH PAGES — Full Responsive
   ======================================== */

@media (max-width: 768px) {
    .auth {
        padding: 80px 20px 40px;
    }

    .auth__card--wide {
        /* Register form takes full width */
    }
}

@media (max-width: 480px) {
    .auth {
        padding: 70px 16px 40px;
    }

    .auth__card {
        padding: 28px 20px;
        border-radius: var(--radius-lg);
    }

    .auth__title {
        font-size: 24px;
    }

    /* Login: Remember me + Forgot password row */
    .auth__form .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Inputs 16px to prevent iOS zoom */
    .auth__form .form-input {
        font-size: 16px;
    }
}

/* ========================================
   22. MOBILE NAV — Overlay Backdrop
   ======================================== */

/* Body scroll lock when mobile menu is open */
body.nav-open {
    overflow: hidden;
}

/* Backdrop overlay behind mobile menu */
.nav__overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 60px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    .nav__overlay--visible {
        display: block;
        animation: fadeIn 0.2s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Ensure mobile menu is above overlay */
    .nav__links--open {
        z-index: 1000;
    }
}

/* ========================================
   23. CARD HEAD BUTTONS — Smaller on Mobile
   ======================================== */

@media (max-width: 640px) {
    /* Prevent button overflow in card headers */
    .adm-card__head .btn,
    .dash-card__header .btn {
        font-size: 0.725rem;
        padding: 6px 10px;
    }
}

/* ========================================
   24. SAFE AREA — iOS Bottom Bar
   ======================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .admin-section,
    .dash-section {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   25. FORM CONTAINERS — Inline Padding Fix
   ======================================== */

@media (max-width: 480px) {
    /* Override inline padding on form wrappers */
    .admin-table-wrap[style*="padding"] {
        padding: 16px !important;
    }

    /* Container max-width overrides */
    .container[style*="max-width"] {
        max-width: 100% !important;
    }
}

/* ========================================
   26. PRINT — Hide Nav/Footer for Admin
   ======================================== */

@media print {
    .nav,
    .footer,
    .cookie-consent,
    .slab-overlay,
    .admin-header .btn,
    .admin-actions,
    .adm-quick,
    .breadcrumbs {
        display: none !important;
    }

    .admin-section,
    .dash-section {
        padding-top: 0;
    }

    .admin-table {
        min-width: 0;
        font-size: 10pt;
    }
}
