/**
 * Syncnamatic — mobile and small-screen overrides.
 * Loaded after page styles on dashboard pages; after styles.css elsewhere.
 */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: clip;
}

@media (max-width: 768px) {
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .contact-page {
        padding: 5rem 0 3rem;
    }

    .legal-page {
        padding: 5rem 0 2rem;
    }

    .legal-content {
        padding: 1.75rem 1.25rem;
    }

    .legal-content h1 {
        font-size: 1.85rem;
    }

    .legal-content h2 {
        font-size: 1.25rem;
    }

    .footer-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.35rem 0.75rem;
    }
}

@media (max-width: 640px) {
    /* Dashboard shell */
    .dash-header-inner {
        padding: 0.85rem 1rem;
        flex-wrap: wrap;
    }

    .dash-main {
        padding: 1.75rem 1rem 3rem;
    }

    .dash-greeting h1,
    .page-intro h1 {
        font-size: 1.45rem;
    }

    .header-actions {
        flex: 1 1 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .header-actions .btn-ghost,
    .header-actions .btn-solid {
        flex: 1 1 calc(50% - 0.25rem);
        text-align: center;
        padding: 0.5rem 0.65rem;
        font-size: 0.82rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .card {
        padding: 1.25rem;
    }

    .card h2 {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }

    .card-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-actions .btn-ghost,
    .card-actions .btn-sm {
        flex: 1 1 auto;
        text-align: center;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .setup-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .setup-dismiss {
        align-self: flex-end;
    }

    .impersonation-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 0.75rem;
    }

    .impersonation-banner .btn-ghost {
        width: 100%;
        justify-content: center;
    }

    .detail-grid,
    .profile-form {
        grid-template-columns: 1fr;
    }

    .profile-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .profile-actions .btn-ghost,
    .profile-actions .btn-solid {
        width: 100%;
        text-align: center;
        min-height: 44px;
    }

    .profile-feedback {
        margin-right: 0;
        text-align: center;
    }

    .google-connect-row {
        flex-direction: column;
        align-items: stretch;
    }

    .google-connect-actions {
        width: 100%;
    }

    .google-connect-actions .btn-ghost,
    .google-connect-actions .btn-solid {
        flex: 1;
        min-height: 44px;
    }

    .admin-select {
        min-width: 0;
        width: 100%;
    }

    /* Invoice dashboard */
    .invoice-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-toolbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .invoice-toolbar-filters {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-search {
        min-width: 0;
        width: 100%;
    }

    .delivery-filter-wrap {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .delivery-segment {
        width: 100%;
        justify-content: stretch;
        flex-wrap: wrap;
        border-radius: 12px;
    }

    .delivery-segment-btn {
        flex: 1 1 auto;
        text-align: center;
        min-height: 36px;
    }

    .invoice-sort-mobile {
        display: block;
    }

    .invoices-scroll {
        display: none;
    }

    .invoices-cards {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
    }

    .invoice-card-meta {
        grid-template-columns: 1fr;
    }

    .invoice-card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-card-badges {
        justify-content: flex-start;
    }

    .invoice-card-footer .row-actions {
        justify-content: flex-end;
    }

    .invoice-pagination {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 0.75rem;
    }

    .invoice-page-nav {
        justify-content: center;
    }

    /* Modals */
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    .modal {
        border-radius: 0;
        min-height: 100dvh;
        max-width: none;
        padding: 1.25rem;
    }

    .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-actions .btn-ghost,
    .modal-actions .btn-solid,
    .modal-actions .btn-danger,
    .modal-actions .send-btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
    }

    .preview-modal {
        padding: 0;
        align-items: stretch;
    }

    .preview-modal-panel {
        width: 100%;
        max-height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
    }

    .preview-modal-body {
        min-height: 0;
    }

    .preview-frame {
        height: min(72dvh, 100%);
    }

    /* Template library */
    .template-row {
        flex-direction: column;
        align-items: stretch;
    }

    .template-actions {
        width: 100%;
    }

    .template-actions .btn-ghost {
        flex: 1;
        text-align: center;
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 3.5rem 0;
    }

    section {
        padding: 2.5rem 0;
    }

    .hero-title {
        font-size: 1.65rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .section-title {
        font-size: 1.65rem;
        margin-bottom: 2rem;
    }

    .section-subtitle {
        font-size: 0.95rem;
        margin-bottom: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-buttons .btn,
    .btn-large {
        width: 100%;
    }

    .btn-large {
        padding: 0.85rem 1.5rem;
        font-size: 1rem;
    }

    .contact-form {
        padding: 1.25rem;
    }

    .login-container {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .login-box {
        padding: 1.75rem 1.25rem;
    }
}
