/* Material Design Button Styles */
.toggle-user-status {
    margin-left: 12px;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    width: 90px;
    text-align: center;
    line-height: 1.5;
    height: 32px;
    font-size: 13px;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Button State Change Animation */
.toggle-user-status {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-user-status::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: currentColor;
    opacity: 0;
    border-radius: inherit;
    transform: scale(1.3);
    pointer-events: none;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out;
}

.toggle-user-status.state-changing::before {
    animation: stateChange 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes stateChange {
    0% {
        opacity: 0;
        transform: scale(1.3);
    }
    30% {
        opacity: 0.15;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* Status Text Styles */
.status-active, .status-deactive {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    min-width: 70px;
    justify-content: center;
    position: relative;
    letter-spacing: 0.3px;
}

.status-active {
    background: #f1f8f1;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    box-shadow: 
        0 1px 2px rgba(46, 125, 50, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.status-deactive {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    box-shadow: 
        0 1px 2px rgba(220, 38, 38, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Status Icon Styles */
.status-active:before,
.status-deactive:before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
    transition: all 0.3s ease;
}

.status-active:before {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.status-deactive:before {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* Deactive Button Style */
.status-active + .toggle-user-status {
    background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
    box-shadow: 
        0 2px 4px rgba(220, 38, 38, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-active + .toggle-user-status:hover:not(.loading) {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 6px rgba(220, 38, 38, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-active + .toggle-user-status:active:not(.loading) {
    background: linear-gradient(180deg, #b91c1c 0%, #991b1b 100%);
    transform: translateY(1px);
    box-shadow: 
        0 1px 2px rgba(220, 38, 38, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Active Button Style */
.status-deactive + .toggle-user-status {
    background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
    color: #fff;
    box-shadow: 
        0 2px 4px rgba(22, 163, 74, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-deactive + .toggle-user-status:hover:not(.loading) {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 6px rgba(22, 163, 74, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-deactive + .toggle-user-status:active:not(.loading) {
    background: linear-gradient(180deg, #15803d 0%, #166534 100%);
    transform: translateY(1px);
    box-shadow: 
        0 1px 2px rgba(22, 163, 74, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Status Icon Column */
.column-status_icon {
    width: 40px !important;
    text-align: center !important;
    vertical-align: middle !important;
    padding: 8px 0 !important;
}

.status-icon-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    position: relative;
    margin: 0 auto;
}

.status-icon-active,
.status-icon-deactive {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    position: relative;
    transition: all 0.3s ease;
    transform-origin: center center;
    margin: 0 auto;
}

.status-icon-header::before,
.status-icon-active::before,
.status-icon-deactive::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    transition: transform 0.3s ease;
}

.status-icon-header::before {
    background-image: url('../images/shield-header.svg');
    opacity: 0.7;
}

.status-icon-active::before {
    background-image: url('../images/shield-active.svg');
    opacity: 0.9;
}

.status-icon-deactive::before {
    background-image: url('../images/shield-deactive.svg');
    opacity: 0.9;
}

.status-icon-active:hover::before,
.status-icon-deactive:hover::before {
    transform: scale(1.1);
}

/* Center align the entire column */
.widefat td.column-status_icon,
.widefat th.column-status_icon {
    text-align: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Animation for status icon change */
.status-icon-animate::before {
    animation: iconPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes iconPop {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0.9;
    }
}

/* Remove old shield overlay */
.shield-overlay {
    display: none;
}

/* Deactivated User Row Styling */
.user-deactive-row td {
    transition: background-color 0.3s ease;
}

.user-deactive-row:nth-child(odd) td {
    background: transparent;
}

.user-deactive-row:hover td {
    background: rgba(0, 0, 0, 0.02);
}

/* Loading Animation */
.toggle-user-status.loading {
    cursor: wait;
    pointer-events: none;
    position: relative;
    min-width: 110px;  /* Increased width to accommodate longer text */
    transition: min-width 0.3s ease;
}

.toggle-user-status.loading span {
    opacity: 0.9;
    font-size: 12px;
    font-style: normal;
    letter-spacing: 0px;
}

.toggle-user-status.loading::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    animation: loading-pulse 1s ease-in-out infinite;
}

@keyframes loading-pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.3;
    }
    100% {
        opacity: 0.6;
    }
}

/* Status Icon Transition */
.status-icon {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.status-icon.updating {
    transform: scale(0.8);
    opacity: 0;
}

/* Row alignment for status and button */
.column-user_status {
    vertical-align: middle !important;
    height: 100%;
    position: relative;
}

.column-user_status > * {
    vertical-align: middle;
}

/* Ensure table cell alignment */
.wp-list-table td {
    vertical-align: middle !important;
}

/* Ripple Effect */
.toggle-user-status::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 70%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.4s ease-out, opacity 0.3s ease-out;
}

.toggle-user-status:active::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    transition: transform 0s, opacity 0.1s;
}

/* Focus state for accessibility */
.toggle-user-status:focus {
    outline: none;
    box-shadow: 0 0 0 1px #fff, 0 0 0 3px #2271b1;
}

/* Add a subtle left border to indicate deactive status */
.user-deactive-row td:first-child {
    box-shadow: inset 2px 0 0 #d63638;
    transition: box-shadow 0.3s ease;
}

/* Status Icons with 3D Effect */
.status-icon-active, .status-icon-deactive {
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    position: relative;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.1),
        -1px -1px 3px rgba(255, 255, 255, 0.7);
}

.status-icon-active {
    color: #43a047;
    background: linear-gradient(145deg, #f0f9f1, #e8f5e9);
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}

.status-icon-deactive {
    color: #e53935;
    background: linear-gradient(145deg, #fff1f1, #ffebee);
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.8);
}

/* Row transition animation */
tr {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.user-deactive-row.row-transition {
    animation: rowDisable 0.5s ease;
}

.user-enabled-row.row-transition {
    animation: rowEnable 0.5s ease;
}

@keyframes rowDisable {
    0% {
        background-color: transparent;
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes rowEnable {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
    100% {
        transform: scale(1);
    }
}

/* Animation for status icon change */
.status-icon-animate {
    animation: iconFlip 0.5s ease;
}

@keyframes iconFlip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

/* Processing animation styles */
.toggle-user-status.process-success,
.toggle-user-status.process-error {
    position: relative;
    overflow: hidden;
}

.toggle-user-status.process-success::after,
.toggle-user-status.process-error::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    animation: processing-pulse 1.2s ease-out;
    pointer-events: none;
    border-radius: inherit;
    z-index: 2;
}

.toggle-user-status.process-success::after {
    background: rgba(46, 125, 50, 0.3);
}

.toggle-user-status.process-error::after {
    background: rgba(220, 38, 38, 0.3);
}

@keyframes processing-pulse {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.02);
    }
    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}

/* Loading animation */
.toggle-user-status.loading {
    cursor: wait;
    opacity: 0.8;
}