/* ============================================================
   Site-wide Responsive Foundation — 100% fluid layout
   Loads after style.css / tools.css / admin.css
   Does NOT alter backend behavior
   ============================================================ */

:root {
    --page-pad: clamp(0.75rem, 2.2vw, 2.5rem);
    --section-gap: clamp(1.25rem, 3vw, 3.5rem);
    --text-xs: clamp(0.72rem, 0.85vw, 0.82rem);
    --text-sm: clamp(0.82rem, 1vw, 0.95rem);
    --text-base: clamp(0.92rem, 1.1vw, 1.05rem);
    --text-lg: clamp(1.05rem, 1.5vw, 1.35rem);
    --text-xl: clamp(1.25rem, 2.2vw, 1.85rem);
    --text-2xl: clamp(1.6rem, 4vw, 3.2rem);
    --nav-height: clamp(3.75rem, 8vw, 4.5rem);
}

/* ── Global overflow & media safety ── */
html {
    overflow-x: clip;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: clip;
    max-width: 100vw;
    font-size: var(--text-base);
    line-height: 1.65;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
    height: auto;
}

img {
    object-fit: cover;
}

button,
input,
select,
textarea {
    max-width: 100%;
    font: inherit;
}

/* Responsive tables: scroll inside wrapper only */
table {
    max-width: 100%;
}

.table-responsive,
.admin-table-wrap,
.admin-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.table-responsive > table,
.admin-table-wrap > table,
.admin-table-scroll > table {
    min-width: 36rem;
    width: 100%;
}

/* Prefer wrapping long strings */
a,
p,
h1, h2, h3, h4, h5, h6,
span,
li,
label,
td,
th {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Focus visibility */
:focus-visible {
    outline: 2px solid var(--primary, #4361ee);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ══════════════════════════════════════
   PUBLIC NAVBAR + HAMBURGER DRAWER
   ══════════════════════════════════════ */
.navbar {
    height: var(--nav-height);
    padding-inline: var(--page-pad);
    gap: clamp(0.5rem, 1.5vw, 1.25rem);
    min-width: 0;
}

.navbar-start {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex-shrink: 0;
}

.navbar .logo {
    font-size: clamp(1.05rem, 2vw, 1.45rem);
    min-width: 0;
}

.navbar .logo .site-logo-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(42vw, 12rem);
}

.nav-burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 0.75rem;
    background: var(--gray-100, #f1f5f9);
    color: var(--gray-800, #1e293b);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.22s ease, border-color 0.22s ease;
}

[data-theme="dark"] .nav-burger {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

.nav-burger-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 1.1rem;
}

.nav-burger-lines span {
    display: block;
    height: 2px;
    width: 100%;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.nav-burger[aria-expanded="true"] .nav-burger-lines span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-burger[aria-expanded="true"] .nav-burger-lines span:nth-child(2) {
    opacity: 0;
}

.nav-burger[aria-expanded="true"] .nav-burger-lines span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.navbar .nav-links {
    flex-wrap: nowrap;
    min-width: 0;
}

.navbar .nav-actions {
    gap: clamp(0.4rem, 1vw, 0.9rem);
    min-width: 0;
    flex-shrink: 1;
}

.navbar .search-box {
    min-width: 0;
    flex: 0 1 auto;
}

.navbar .search-box input {
    width: clamp(4.5rem, 14vw, 11rem);
    min-width: 0;
    font-size: var(--text-sm);
}

.lang-switcher .lang-label {
    font-size: var(--text-xs);
}

.nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.nav-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.nav-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 1100;
    width: min(88vw, 20rem);
    background: #fff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

html[dir="rtl"] .nav-drawer {
    transform: translateX(105%);
}

.nav-drawer.is-open {
    transform: translateX(0);
}

[data-theme="dark"] .nav-drawer {
    background: #0f172a;
    color: #f8fafc;
}

.nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.85rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .nav-drawer-head {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.nav-drawer-close {
    width: 2.4rem;
    height: 2.4rem;
    border: none;
    border-radius: 0.7rem;
    background: var(--gray-100, #f1f5f9);
    color: inherit;
    cursor: pointer;
}

[data-theme="dark"] .nav-drawer-close {
    background: rgba(255, 255, 255, 0.08);
}

.nav-drawer-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-drawer-links a {
    display: block;
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--gray-700, #334155);
    transition: background 0.2s ease, color 0.2s ease;
}

[data-theme="dark"] .nav-drawer-links a {
    color: #e2e8f0;
}

.nav-drawer-links a:hover,
.nav-drawer-links a.active {
    background: var(--primary-light, #eef2ff);
    color: var(--primary, #4361ee);
}

body.nav-drawer-open {
    overflow: hidden !important;
}

/* ══════════════════════════════════════
   HERO / STATS / CARDS / FOOTER
   ══════════════════════════════════════ */
.hero {
    margin-inline: clamp(0.5rem, 2vw, 1.5rem);
    padding: clamp(2rem, 5vw, 4.5rem) clamp(1rem, 3vw, 2rem) clamp(1.5rem, 4vw, 2.5rem);
}

.hero h1 {
    font-size: var(--text-2xl);
    line-height: 1.2;
}

.hero .sub {
    font-size: var(--text-base);
    max-width: min(42rem, 100%);
    margin-inline: auto;
}

.hero .badge-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.stats {
    max-width: min(75rem, 100%);
    margin-inline: auto;
    padding-inline: var(--page-pad);
    gap: clamp(0.75rem, 2vw, 1.25rem);
}

.stat-item .num {
    font-size: clamp(1.4rem, 3vw, 2.4rem);
}

.container,
.tool-page,
.auth-page,
.account-page {
    max-width: min(87.5rem, 100%);
    width: 100%;
    padding-inline: var(--page-pad);
    box-sizing: border-box;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(0.75rem, 1.8vw, 1.35rem);
}

.tool-card {
    min-width: 0;
    width: 100%;
}

.category-header {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.category-title {
    font-size: var(--text-xl);
    flex-wrap: wrap;
    min-width: 0;
}

.footer {
    padding: clamp(2.5rem, 6vw, 5rem) var(--page-pad) clamp(1.5rem, 3vw, 2.5rem);
}

.footer-top {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr);
    gap: clamp(1.5rem, 4vw, 3.5rem);
}

.footer-links-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1rem, 3vw, 2.5rem);
}

.footer-column a,
.footer-brand p {
    font-size: var(--text-sm);
}

/* ══════════════════════════════════════
   FORMS (site + tools)
   ══════════════════════════════════════ */
.form-group,
.tool-workspace .form-group,
.auth-card .form-group {
    min-width: 0;
}

input.form-input,
textarea.form-textarea,
select.form-input,
.tool-workspace input,
.tool-workspace textarea,
.tool-workspace select,
.auth-card input,
.auth-card textarea,
.auth-card select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.form-fields-grid,
.form-row,
.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(0.75rem, 2vw, 1.1rem);
}

.btn-row,
.tool-actions,
.form-actions,
.admin-topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

.btn-row > *,
.tool-actions > *,
.form-actions > * {
    max-width: 100%;
}

/* Auth / account cards */
.auth-card,
.account-card,
.subscription-card {
    width: min(100%, 32rem);
    max-width: 100%;
    margin-inline: auto;
    box-sizing: border-box;
}

/* ══════════════════════════════════════
   ADMIN SHELL POLISH
   ══════════════════════════════════════ */
.admin-shell {
    min-width: 0;
}

.admin-main,
.admin-content,
.admin-topbar {
    min-width: 0;
}

.admin-content {
    padding-inline: clamp(0.85rem, 2vw, 1.75rem);
}

.admin-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ══════════════════════════════════════
   BREAKPOINTS
   ══════════════════════════════════════ */

/* ≤1600 */
@media (max-width: 1600px) {
    .tools-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ≤1280 laptop */
@media (max-width: 1280px) {
    .tools-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .navbar .nav-links a {
        padding: 0.45rem 0.7rem;
        font-size: 0.82rem;
    }

    .admin-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ≤1024 tablet landscape */
@media (max-width: 1024px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .footer-top {
        grid-template-columns: 1fr;
    }

    .navbar .nav-links {
        display: none;
    }

    .nav-burger {
        display: inline-flex;
    }

    .lang-switcher .lang-label {
        display: none;
    }
}

/* ≤992 */
@media (max-width: 992px) {
    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-fields-grid,
    .form-row,
    .auth-grid {
        grid-template-columns: 1fr;
    }

    .result-hero {
        grid-template-columns: 1fr !important;
    }
}

/* ≤768 phones / small tablets */
@media (max-width: 768px) {
    .navbar .search-box input {
        width: clamp(4rem, 28vw, 8rem);
    }

    .footer-links-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-page {
        padding-block: 1rem;
    }

    .tool-workspace {
        padding: clamp(0.9rem, 3vw, 1.25rem) !important;
    }

    .admin-stats {
        grid-template-columns: 1fr;
    }

    .admin-topbar {
        flex-wrap: wrap;
        gap: 0.65rem;
    }

    .admin-topbar-actions {
        width: 100%;
    }
}

/* ≤576 */
@media (max-width: 576px) {
    .stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        max-width: 22rem;
        margin-inline: auto;
    }

    .navbar .search-box {
        display: none;
    }

    .hero .badge-group .badge {
        font-size: 0.72rem;
        padding: 0.3rem 0.75rem;
    }

    .btn-row > .cv-btn,
    .tool-actions > button,
    .form-actions > button,
    .tool-actions > a,
    .form-actions > a {
        flex: 1 1 auto;
        justify-content: center;
        text-align: center;
    }
}

/* ≤425 / 375 / 320 */
@media (max-width: 425px) {
    .stats {
        grid-template-columns: 1fr;
    }

    .navbar .logo .site-logo-text {
        max-width: 7.5rem;
    }
}

/* Ultrawide / 4K: constrain reading width, keep cards airy */
@media (min-width: 1920px) {
    .container,
    .footer-top,
    .stats {
        max-width: 90rem;
    }

    .tools-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 2560px) {
    .tools-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* CV builder already manages its own overflow — don't fight it */
body:has(.cv-ats-app) {
    max-width: none;
}

body:has(.cv-ats-app[data-cv-step="edit"]) {
    overflow: hidden;
}
