/*
 * Global responsive foundation:
 * - Fluid typography across phones/tablets/laptops
 * - Safer touch targets on mobile
 * - Prevent oversized headings/components on small devices
 */
:root {
    --rz-font-base: clamp(14px, 0.78rem + 0.28vw, 17px);
    --rz-font-small: clamp(12px, 0.72rem + 0.18vw, 14px);
    --rz-font-h1: clamp(1.35rem, 1.05rem + 1.05vw, 2.1rem);
    --rz-font-h2: clamp(1.2rem, 0.98rem + 0.8vw, 1.75rem);
    --rz-font-h3: clamp(1.08rem, 0.93rem + 0.58vw, 1.4rem);
    --rz-radius: clamp(8px, 0.45rem + 0.3vw, 14px);
    --rz-space-1: clamp(0.375rem, 0.25rem + 0.3vw, 0.625rem);
    --rz-space-2: clamp(0.5rem, 0.35rem + 0.45vw, 0.875rem);
    --rz-space-3: clamp(0.75rem, 0.5rem + 0.6vw, 1.25rem);
}

html {
    font-size: var(--rz-font-base);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-size: 1rem;
    line-height: 1.5;
}

h1, .h1 { font-size: var(--rz-font-h1); line-height: 1.25; }
h2, .h2 { font-size: var(--rz-font-h2); line-height: 1.3; }
h3, .h3 { font-size: var(--rz-font-h3); line-height: 1.35; }
h4, .h4 { font-size: clamp(1rem, 0.9rem + 0.4vw, 1.2rem); }
h5, .h5 { font-size: clamp(0.95rem, 0.85rem + 0.28vw, 1.08rem); }
h6, .h6 { font-size: clamp(0.88rem, 0.82rem + 0.2vw, 0.98rem); }
small, .small, .text-muted { font-size: var(--rz-font-small); }

.container, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl {
    padding-left: var(--rz-space-2);
    padding-right: var(--rz-space-2);
}

.card, .modal-content, .dropdown-menu, .offcanvas {
    border-radius: var(--rz-radius);
}

.btn, .form-control, .form-select, .input-group-text {
    font-size: 1rem;
    border-radius: clamp(8px, 0.5rem + 0.2vw, 12px);
}

/* Mobile-first touch and readability tweaks */
@media (max-width: 768px) {
    .btn {
        min-height: 40px;
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }

    .form-control, .form-select {
        min-height: 40px;
    }

    /* Prevent iOS zoom on form focus */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Global modal hardening for small devices (wizards + dialogs) */
    .modal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }

    .modal .modal-content {
        max-height: calc(100dvh - 1rem);
        overflow: hidden;
    }

    .modal .modal-header {
        padding: 0.65rem 0.75rem;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .modal .modal-title {
        font-size: 0.98rem;
        line-height: 1.25;
    }

    .modal .btn-close {
        margin: 0;
        padding: 0.45rem;
        min-width: 36px;
        min-height: 36px;
    }

    .modal .modal-body {
        overflow-x: hidden;
    }

    .mobile-header-actions {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        margin-inline-start: auto;
        margin-inline-end: 0.3rem;
    }

    .mobile-header-icon-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        border-radius: 50%;
        border: 1px solid var(--theme-border, rgba(255, 255, 255, 0.22));
        background: rgba(255, 255, 255, 0.08);
        color: var(--theme-text-primary, #fff);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    /* Unify shape and style for all mobile header icon buttons (account, messages, logout) */
    .mobile-header-actions .mobile-header-icon-btn,
    .mobile-header-actions a.mobile-header-icon-btn,
    .mobile-header-actions .theme-toggle.mobile-header-icon-btn {
        border-radius: 50% !important;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid var(--theme-border, rgba(255, 255, 255, 0.22)) !important;
    }

    .mobile-header-actions a.mobile-header-messages-btn { position: relative; }
    [data-theme="light"] .mobile-header-actions .mobile-header-icon-btn,
    [data-theme="light"] .mobile-header-actions a.mobile-header-icon-btn,
    [data-theme="light"] .mobile-header-actions .theme-toggle.mobile-header-icon-btn,
    html:not([data-theme="dark"]) .mobile-header-actions .mobile-header-icon-btn,
    html:not([data-theme="dark"]) .mobile-header-actions a.mobile-header-icon-btn,
    html:not([data-theme="dark"]) .mobile-header-actions .theme-toggle.mobile-header-icon-btn {
        background: rgba(17, 24, 39, 0.08) !important;
        border-color: rgba(17, 24, 39, 0.18) !important;
        color: #111827 !important;
    }

    .mobile-header-language-wrap .lang-toggle {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        border-radius: 10px;
        border: 1px solid var(--theme-border, rgba(255, 255, 255, 0.22));
        background: rgba(255, 255, 255, 0.08);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
    }

    .mobile-header-language-wrap .lang-toggle .fw-medium,
    .mobile-header-language-wrap .lang-toggle .mobile-nav-inline-label {
        display: none !important;
    }

    .mobile-header-language-wrap .lang-toggle i {
        margin: 0 !important;
    }
}

/* Header quick actions should stay on one row on all mobile/tablet sizes (< lg) */
@media (max-width: 991.98px) {
    .mobile-header-actions {
        display: inline-flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 0.35rem !important;
        white-space: nowrap !important;
    }

    .mobile-header-actions > * {
        display: inline-flex !important;
        align-items: center !important;
        flex: 0 0 auto !important;
    }

    .mobile-header-language-wrap {
        display: inline-flex !important;
        align-items: center !important;
        margin: 0 !important;
    }

    .mobile-header-logout-form {
        margin: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
    }

    .mobile-header-language-wrap .lang-toggle {
        display: inline-flex !important;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        padding: 0 !important;
    }
}

@media (max-width: 576px) {
    main#main-content {
        padding-left: var(--rz-space-1);
        padding-right: var(--rz-space-1);
    }
}
