/* ============================================================================
   Buttons - Bootstrap 3 .btn variants restyled to look modern
   ============================================================================ */

body.theme-new .btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    letter-spacing: 0.2px;
    transition:
        background var(--transition-speed) var(--ease-standard),
        color var(--transition-speed) var(--ease-standard),
        border-color var(--transition-speed) var(--ease-standard),
        box-shadow var(--transition-speed) var(--ease-standard),
        transform var(--transition-speed) var(--ease-standard);
    box-shadow: none;
}

body.theme-new .btn:focus,
body.theme-new .btn:focus-visible,
body.theme-new .btn.focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-focus);
}

body.theme-new .btn:active {
    transform: translateY(1px);
}

/* Primary - iNexxus green.
   custom.css:308 sets `.btn-primary { background: #272727 }` (dark grey,
   reads as black). Our class-scoped selector has higher specificity, but
   custom.css also defines hover/focus/active variants with `!important`
   on a couple. Use `!important` here to win all the cascade battles
   without playing whack-a-mole on each pseudo-state. */
body.theme-new .btn-primary {
    background: var(--primary-color) !important;
    background-color: var(--primary-color) !important;
    border: 1px solid var(--primary-color) !important;
    color: #fff !important;
    font-weight: 600;
}

body.theme-new .btn-primary:hover,
body.theme-new .btn-primary:focus,
body.theme-new .btn-primary.focus {
    background: var(--primary-700) !important;
    background-color: var(--primary-700) !important;
    border: 1px solid var(--primary-700) !important;
    color: #fff !important;
    box-shadow: 0 6px 18px var(--primary-focus) !important;
}

body.theme-new .btn-primary:active,
body.theme-new .btn-primary.active,
body.theme-new .open > .dropdown-toggle.btn-primary,
body.theme-new .btn-primary:active:hover,
body.theme-new .btn-primary:active:focus {
    background: var(--primary-700) !important;
    background-color: var(--primary-700) !important;
    border: 1px solid var(--primary-700) !important;
    color: #fff !important;
}

/* The generic legacy rule `.btn:active { background: #6d6e6d !important }`
   in custom.css:338 would otherwise turn ANY active button grey. Block
   that for primary buttons. */
body.theme-new .btn.btn-primary:active {
    background: var(--primary-700) !important;
    background-color: var(--primary-700) !important;
    border-color: var(--primary-700) !important;
}

/* Default / Secondary - neutral */
body.theme-new .btn-default {
    background: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-main);
}

body.theme-new .btn-default:hover,
body.theme-new .btn-default:focus {
    background: var(--primary-tint);
    border-color: var(--border-color);
    color: var(--text-heading);
}

body.theme-new .btn-default:active,
body.theme-new .btn-default.active,
body.theme-new .open > .dropdown-toggle.btn-default {
    background: var(--bg-elevated) !important;
    border-color: var(--primary-color) !important;
    color: var(--text-heading) !important;
}

/* Success / Danger / Warning / Info - keep semantic colors */
body.theme-new .btn-success {
    background: var(--success-color);
    border-color: var(--success-color);
    color: #fff;
    font-weight: 600;
}

body.theme-new .btn-success:hover,
body.theme-new .btn-success:focus {
    filter: brightness(1.08);
    background: var(--success-color);
    border-color: var(--success-color);
    color: #fff;
}

body.theme-new .btn-danger {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
    font-weight: 600;
}

body.theme-new .btn-danger:hover,
body.theme-new .btn-danger:focus {
    filter: brightness(1.08);
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
}

body.theme-new .btn-warning {
    background: var(--warning-color);
    border-color: var(--warning-color);
    color: var(--bg-body);
    font-weight: 600;
}

body.theme-new .btn-warning:hover,
body.theme-new .btn-warning:focus {
    filter: brightness(1.08);
    background: var(--warning-color);
    border-color: var(--warning-color);
    color: var(--bg-body);
}

body.theme-new .btn-info {
    background: var(--info-color);
    border-color: var(--info-color);
    color: var(--bg-body);
    font-weight: 600;
}

body.theme-new .btn-info:hover,
body.theme-new .btn-info:focus {
    filter: brightness(1.08);
    background: var(--info-color);
    border-color: var(--info-color);
    color: var(--bg-body);
}

/* Link buttons */
body.theme-new .btn-link {
    color: var(--primary-color);
}
body.theme-new .btn-link:hover,
body.theme-new .btn-link:focus {
    color: var(--primary-color);
    filter: brightness(1.15);
    text-decoration: none;
}

/* Sizes - just radius adjustments */
body.theme-new .btn-lg { border-radius: var(--radius-md); }
body.theme-new .btn-sm,
body.theme-new .btn-xs { border-radius: var(--radius-sm); }

/* Icon-only square button (Perfex uses .btn-icon a lot for row actions) */
body.theme-new .btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* Disabled state */
body.theme-new .btn[disabled],
body.theme-new .btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Button groups - tighten the radius corners */
body.theme-new .btn-group > .btn:first-child:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
body.theme-new .btn-group > .btn:last-child:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
body.theme-new .btn-group > .btn:not(:first-child):not(:last-child) { border-radius: 0; }

/* Generic .dropdown-menu container - works for ANY dropdown, not just
   ones inside .btn-group. BS3's default .dropdown-menu has a white
   background which would otherwise leave our white text invisible in
   dark mode. */
body.theme-new .dropdown-menu {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-elev) !important;
    padding: 6px !important;
    color: var(--text-main) !important;
}

/* Keep the btn-group variant for the explicit case the header dropdown
   wrappers also pick this up via the shared base rule */
body.theme-new .btn-group > .dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elev);
    padding: 6px;
}

body.theme-new .dropdown-menu > li > a {
    color: var(--text-main) !important;
    padding: 8px 12px !important;
    border-radius: var(--radius-sm) !important;
    transition: background var(--transition-speed) var(--ease-standard),
                color var(--transition-speed) var(--ease-standard);
    background: transparent !important;
    text-decoration: none;
}

body.theme-new .dropdown-menu > li > a:hover,
body.theme-new .dropdown-menu > li > a:focus,
body.theme-new .dropdown-menu > li.active > a {
    background: var(--primary-tint) !important;
    color: var(--primary-color) !important;
}

/* Disabled dropdown item */
body.theme-new .dropdown-menu > li.disabled > a,
body.theme-new .dropdown-menu > li.disabled > a:hover {
    color: var(--text-muted) !important;
    background: transparent !important;
    cursor: not-allowed;
}

body.theme-new .dropdown-menu .divider,
body.theme-new .dropdown-menu .dropdown-divider {
    background: var(--border-soft) !important;
    height: 1px;
    margin: 4px 0;
}

body.theme-new .dropdown-menu .dropdown-header {
    color: var(--text-muted) !important;
    padding: 6px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Light mode: BS3 default dropdown has white bg + dark text, which
   already reads correctly. The above !important rules force our card
   surface (which is also white in light mode) - so this just unifies
   appearance across themes. */

@media (prefers-reduced-motion: reduce) {
    body.theme-new .btn { transition: none !important; }
    body.theme-new .btn:active { transform: none !important; }
}

/* ============================================================================
   .btn-bottom-toolbar - the sticky "save bar" at the bottom of edit forms.
   Legacy style.css:4578 uses 230px sidebar offset + white bg.
   custom.css overrides with 330px offset + #000 black bg (looks like a
   black bar with a button in it). Re-anchor to our 260px sidebar +
   theme card surface so it matches the new chrome.
   ============================================================================ */
body.theme-new .btn-bottom-toolbar {
    background: var(--bg-card) !important;
    border-top: 1px solid var(--border-soft) !important;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.25) !important;
    margin-left: var(--sidebar-width) !important;
    width: calc(100% - var(--sidebar-width)) !important;
    padding: 12px 32px !important;
    color: var(--text-main);
}

/* When the sidebar is in icon-rail mode (collapsed), shrink the toolbar
   offset accordingly. */
body.theme-new.sidebar-collapsed .btn-bottom-toolbar {
    margin-left: var(--sidebar-collapsed-width) !important;
    width: calc(100% - var(--sidebar-collapsed-width)) !important;
}

/* Mobile - full width, no sidebar offset */
@media (max-width: 991.98px) {
    body.theme-new .btn-bottom-toolbar {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 10px 16px !important;
    }
}

/* Notice / message text inside the toolbar (e.g. "Você tem alterações
   não salvas") - keep readable on the new card surface */
body.theme-new .btn-bottom-toolbar .btn-toolbar-notice,
body.theme-new .btn-bottom-toolbar small,
body.theme-new .btn-bottom-toolbar span {
    color: var(--text-muted);
}
