/* File: assets/css/sticky-header.css */
/**
 * Sticky Header Styles for PayButton Plugin.
 */

/* The main sticky header container */
#cashtab-sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0; /* ensures it spans full width */
    margin: 0 auto; /* center horizontally if there's any leftover space */
    width: 100%;
    box-sizing: border-box;

    background: var(--sticky-header-bg-color, #007bff);
    color: var(--sticky-header-text-color, #fff);
    font-family: sans-serif;
    z-index: 9999;
    padding: 4px 16px; /* reduced vertical padding for a better header */

    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap; /* allow items to wrap if needed on narrower screens */
    text-align: center;
}

/* Ensures the "Login via Cashtab" paybutton is centered */
#cashtab-sticky-header #loginPaybutton {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

/* For the "Profile" & "Logout" buttons container */
.logged-in-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;

    /* let them wrap on narrow screens if needed */
    flex-wrap: wrap;
    margin: 0;
}

/* Basic styling for the Profile & Logout buttons */
.profile-button,
.logout-button {
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    display: flex;         /* added for vertical centering */
    align-items: center;   /* centers content vertically */
    justify-content: center; /* centers content horizontally */
    opacity: 1 !important;
}

/* Profile button colors */
.profile-button {
    background-color: var(--profile-button-bg-color, #ffc107);
    color: var(--profile-button-text-color, #000);
}

/* Logout button colors */
.logout-button {
    background-color: var(--logout-button-bg-color, #d9534f);
    color: var(--logout-button-text-color, #fff);
}

/* Logout button "logging out" state */
.logout-button.is-logging-out {
    position: relative;
    opacity: 0.8;
    cursor: wait;
    padding-right: 26px; /* space for spinner */
}

/* Default: show "Logout", hide "Logging out..." */
.logout-button .btn-text-logging-out {
    display: none;
}

/* When logging out: swap labels */
.logout-button.is-logging-out .btn-text-default {
    display: none;
}

.logout-button.is-logging-out .btn-text-logging-out {
    display: inline;
}

/* Simple spinner on the right side of the logout button */
.logout-button.is-logging-out::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: cashtab-spin 0.8s linear infinite;
}

/* Spinner animation */
@keyframes cashtab-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Prevent header from overlapping content */
body.pb-has-sticky-header {
    padding-top: 80px !important;
}

/* --- Mobile adjustments to ensure everything is centered and stacked --- */
@media (max-width: 480px) {
    #cashtab-sticky-header {
        flex-direction: column; /* stack items vertically on small screens */
    }
    #cashtab-sticky-header #loginPaybutton,
    .logged-in-actions {
        width: 100%;
        justify-content: center;
    }
    .profile-button, .logout-button {
        margin: 4px 0;
    }
}

/* --- Animated Slide Effect for Profile + Logout Buttons --- */

/* Base animation wrapper */
.paybutton-animated {
    position: relative;
    overflow: hidden;
    z-index: 0;
    transition: color 0.25s ease;
    font-weight: bold; /*make text bold for better visibility*/
}

/* Text wrapper stays above the animated layer */
.paybutton-animated span {
    position: relative;
    z-index: 1;
}

/* Animated overlay grows left to right */
.paybutton-animated::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    z-index: 0;
    transition: width 0.25s ease-out;
}

/* On hover, fill the whole button */
.paybutton-animated:hover::before {
    width: 100%;
}

/* --- Profile button animated variant --- */
.profile-button.paybutton-animated {
    border: 2px solid var(--profile-button-bg-color);
    color: var(--profile-button-text-color);
}

.profile-button.paybutton-animated::before {
    background-color: #808080;
    opacity: 0.3;
}

/* --- Logout button animated variant --- */
.logout-button.paybutton-animated {
    border: 2px solid var(--logout-button-bg-color);
    color: var(--logout-button-text-color, #fff);
}

.logout-button.paybutton-animated::before {
    background-color: #808080;
    opacity: 0.3;
}

/* --- Profile and Logout Button SVG Icon Style --- */
.paybutton-animated .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    width: 16px;
    height: 16px;
    position: relative;
    z-index: 1;
}

.paybutton-animated .btn-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;   /* inherits text color */
}

/* Ensure text stays above animation layer */
.paybutton-animated .btn-text {
    position: relative;
    z-index: 1;
}