/*
Funnel CMS SaaS Phase 8G — Root Style Cleanup
Purpose:
- Keep existing colors.
- Reduce heavy typography.
- Normalize buttons, search boxes, inputs, selects, textareas, tables.
- Improve mobile friendliness.
- Use ideal system UI font stack without external font dependency.
*/

:root {
    --saas-radius-control: 10px;
    --saas-radius-control-sm: 8px;
    --saas-control-height: 42px;
    --saas-control-height-mobile: 44px;
    --saas-control-px: 12px;
    --saas-control-py: 9px;
    --saas-focus-ring: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
    --saas-text-line-height: 1.5;
    --saas-heading-line-height: 1.22;
    --saas-transition: 140ms ease;
}

/* Use a fast, readable OS-native font stack. Do not force colors. */
html,
body,
button,
input,
select,
textarea {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Keep browser/user default base size. Normalize readability only. */
body {
    font-size: 100%;
    line-height: var(--saas-text-line-height);
    font-weight: 400;
}

/* Reduce heavy font feeling without changing layout color. */
h1, h2, h3, h4, h5, h6,
.admin-title,
.user-title,
.page-title,
.card-title,
.dashboard-title,
.section-title {
    font-weight: 650;
    line-height: var(--saas-heading-line-height);
    letter-spacing: -0.015em;
}

h1, .h1, .admin-title, .user-title, .page-title {
    font-size: clamp(1.45rem, 1.08rem + 1.1vw, 2.05rem);
}

h2, .h2, .section-title {
    font-size: clamp(1.25rem, 1.05rem + .55vw, 1.55rem);
}

h3, .h3, .card-title {
    font-size: clamp(1.08rem, 1rem + .25vw, 1.25rem);
}

strong, b {
    font-weight: 650;
}

/* Sidebar/menu text: compact but readable. Keep active colors unchanged. */
.admin-sidebar,
.user-sidebar,
.sidebar,
.admin-nav,
.user-nav,
.side-menu {
    font-size: 0.9375rem;
}

.admin-nav a,
.user-nav a,
.sidebar a,
.side-menu a,
.admin-nav button,
.user-nav button,
.side-menu button {
    font-weight: 500;
    line-height: 1.25;
}

/* Buttons: cleaner SaaS density, less heavy, current colors preserved. */
button,
[type="button"],
[type="submit"],
[type="reset"],
.btn,
.button,
.admin-button,
.user-button,
.action-button,
.primary-button,
.secondary-button,
a.btn,
a.button,
a.admin-button,
a.user-button {
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.2;
    min-height: 40px;
    padding: 0.58rem 0.9rem;
    border-radius: var(--saas-radius-control);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    transition: transform var(--saas-transition), box-shadow var(--saas-transition), border-color var(--saas-transition), background-color var(--saas-transition), color var(--saas-transition);
}

button:hover,
[type="button"]:hover,
[type="submit"]:hover,
[type="reset"]:hover,
.btn:hover,
.button:hover,
.admin-button:hover,
.user-button:hover {
    transform: translateY(-1px);
}

button:disabled,
[type="button"]:disabled,
[type="submit"]:disabled,
[type="reset"]:disabled,
.btn:disabled,
.button:disabled,
.admin-button:disabled,
.user-button:disabled {
    cursor: not-allowed;
    transform: none;
    opacity: .65;
}

button:focus-visible,
[type="button"]:focus-visible,
[type="submit"]:focus-visible,
[type="reset"]:focus-visible,
.btn:focus-visible,
.button:focus-visible,
.admin-button:focus-visible,
.user-button:focus-visible,
a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Inputs/search/select/textarea: modern SaaS shape, same colors. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
select,
textarea,
.form-control,
.form-input,
.admin-input,
.user-input,
.search-input,
.search-box input,
.filter-input,
.filter-select,
.admin-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.admin-form select,
.admin-form textarea,
.user-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.user-form select,
.user-form textarea {
    font: inherit;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.35;
    min-height: var(--saas-control-height);
    padding: var(--saas-control-py) var(--saas-control-px);
    border-radius: var(--saas-radius-control);
    box-shadow: none;
    max-width: 100%;
    transition: border-color var(--saas-transition), box-shadow var(--saas-transition), background-color var(--saas-transition), color var(--saas-transition);
}

select,
.filter-select,
.admin-form select,
.user-form select {
    padding-right: 2.25rem;
}

textarea,
.admin-form textarea,
.user-form textarea {
    min-height: 108px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    opacity: .68;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-input:focus,
.admin-input:focus,
.user-input:focus,
.search-input:focus {
    outline: none;
    box-shadow: var(--saas-focus-ring);
}

/* Labels: normal weight as requested. */
label,
.form-label,
.admin-label,
.user-label,
.admin-form label,
.user-form label {
    font-weight: 400;
    line-height: 1.35;
}

/* File inputs should stay readable but not over-styled. */
input[type="file"] {
    font: inherit;
    font-size: 0.9375rem;
    max-width: 100%;
}

/* Tables: readable density, lighter text weight. */
table,
.admin-table,
.user-table {
    font-size: 0.9375rem;
    line-height: 1.45;
}

th,
.table-heading,
.admin-table th,
.user-table th {
    font-weight: 600;
}

td,
.admin-table td,
.user-table td {
    font-weight: 400;
}

td .btn,
td .button,
td .admin-button,
td .user-button,
.table-actions .btn,
.table-actions .button,
.table-actions .admin-button,
.table-actions .user-button {
    min-height: 34px;
    padding: 0.42rem 0.65rem;
    font-size: 0.875rem;
    border-radius: var(--saas-radius-control-sm);
}

/* Cards keep rounded style. Only normalize text and spacing gently. */
.card,
.admin-card,
.user-card,
.dashboard-card,
.settings-card,
.panel-card {
    max-width: 100%;
}

.card p,
.admin-card p,
.user-card p,
.dashboard-card p,
.settings-card p {
    line-height: var(--saas-text-line-height);
}

/* Toolbars/filter/search rows should wrap instead of causing horizontal overflow. */
.toolbar,
.admin-toolbar,
.user-toolbar,
.filter-row,
.search-row,
.table-actions,
.form-actions,
.admin-actions,
.user-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .65rem;
}

/* Dropdown menus: keep color, clean typography and spacing. */
.dropdown-menu,
.admin-dropdown,
.user-dropdown,
.saas-profile-menu {
    font-size: 0.9375rem;
    line-height: 1.35;
}

.dropdown-menu a,
.admin-dropdown a,
.user-dropdown a,
.saas-profile-menu a,
.dropdown-menu button,
.admin-dropdown button,
.user-dropdown button,
.saas-profile-menu button {
    font-weight: 500;
}

/* Public funnel/forms inherit the same readable root style. */
.funnel-page,
.funnel-wrapper,
.funnel-content,
.public-page,
.public-form {
    font-family: inherit;
    font-size: 100%;
    line-height: var(--saas-text-line-height);
}

.funnel-page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.funnel-page select,
.funnel-page textarea,
.public-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.public-form select,
.public-form textarea {
    font-size: 1rem;
    min-height: var(--saas-control-height);
}

/* Mobile SaaS polish. Do not change colors. */
@media (max-width: 768px) {
    body {
        -webkit-text-size-adjust: 100%;
    }

    button,
    [type="button"],
    [type="submit"],
    [type="reset"],
    .btn,
    .button,
    .admin-button,
    .user-button,
    a.btn,
    a.button,
    a.admin-button,
    a.user-button {
        min-height: var(--saas-control-height-mobile);
        padding: 0.68rem 0.95rem;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
    select,
    textarea,
    .form-control,
    .form-input,
    .admin-input,
    .user-input,
    .search-input,
    .search-box input,
    .filter-input,
    .filter-select {
        min-height: var(--saas-control-height-mobile);
        font-size: 1rem;
    }

    .toolbar,
    .admin-toolbar,
    .user-toolbar,
    .filter-row,
    .search-row,
    .table-actions,
    .form-actions,
    .admin-actions,
    .user-actions {
        gap: .55rem;
    }

    .toolbar > *,
    .admin-toolbar > *,
    .user-toolbar > *,
    .filter-row > *,
    .search-row > * {
        min-width: 0;
    }

    .search-row input,
    .filter-row input,
    .filter-row select {
        width: 100%;
    }

    .table-responsive,
    .admin-table-wrap,
    .user-table-wrap,
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table,
    .admin-table,
    .user-table {
        min-width: 640px;
    }

    .admin-card,
    .user-card,
    .dashboard-card,
    .settings-card,
    .panel-card {
        overflow-wrap: anywhere;
    }
}

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