/**
 * User History Admin Styles
 */

/* Main section container */
.user-history-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #c3c4c7;
}

.user-history-section h2 {
    font-size: 1.3em;
    margin-bottom: 10px;
}

.user-history-section .description {
    margin-bottom: 15px;
    color: #646970;
}

.user-history-count {
    background: #f0f0f1;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    margin-left: 5px;
}

/* ==========================================================================
   Consolidated Panel (single distinctive card containing all plugin UI)
   ========================================================================== */

.user-history-panel {
    margin-top: 40px;
    padding: 0;
    border: 1px solid #c3c4c7;
    border-top: 3px solid #2271b1;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.user-history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: #f6f7f7;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 15px;
}

.user-history-panel-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
}

.user-history-panel-status {
    flex-shrink: 0;
}

.user-history-panel .user-history-tabs {
    padding: 0 20px;
    margin-top: 0;
    background: #fff;
}

.user-history-panel .user-history-tab-content {
    padding: 20px;
}

/* "Actions" tab styled to draw attention */
.user-history-tab.user-history-tab-actions {
    margin-left: auto;
    color: #b32d2e;
}

.user-history-tab.user-history-tab-actions:hover {
    color: #8a1f1f;
}

.user-history-tab.user-history-tab-actions.active {
    color: #b32d2e;
}

/* Action blocks inside the Actions tab */
.user-history-action-block {
    padding: 16px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
    margin-bottom: 16px;
}

.user-history-action-block:last-child {
    margin-bottom: 0;
}

.user-history-action-block h3 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.user-history-action-block .description {
    margin: 0 0 12px;
    color: #646970;
}

.user-history-action-block p:last-child {
    margin-bottom: 0;
}

.user-history-action-danger {
    border-color: #f0c0c0;
    background: #fef7f7;
}

.user-history-action-danger h3 {
    color: #b32d2e;
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.user-history-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #c3c4c7;
    margin-bottom: 0;
}

.user-history-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    text-decoration: none;
    color: #50575e;
    font-weight: 500;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px;
    background: transparent;
    border-radius: 3px 3px 0 0;
    transition: color 0.15s;
}

.user-history-tab:hover {
    color: #135e96;
}

.user-history-tab.active {
    color: #1d2327;
    background: #f6f7f7;
    border-color: #c3c4c7;
    border-bottom-color: #fff;
}

.user-history-tab-count {
    display: inline-block;
    background: #f0f0f1;
    color: #50575e;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 18px;
    min-width: 18px;
    text-align: center;
}

.user-history-tab.active .user-history-tab-count {
    background: #2271b1;
    color: #fff;
}

.user-history-tab-content {
    display: none;
}

.user-history-tab-content.active {
    display: block;
}

/* Empty state */
.user-history-empty {
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-align: center;
    color: #666;
}

/* Registration details panel (shown above Changes table for users with captured context) */
.user-history-registration-panel {
    background: #f6f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.user-history-registration-panel h3 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #50575e;
}

.user-history-registration-info {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px 16px;
    margin: 0;
    font-size: 13px;
}

.user-history-registration-info dt {
    color: #646970;
    font-weight: 500;
    margin: 0;
}

.user-history-registration-info dd {
    margin: 0;
    color: #1d2327;
    word-break: break-word;
}

.user-history-registration-info dd a {
    text-decoration: none;
}

.user-history-registration-info dd a:hover {
    text-decoration: underline;
}

.user-history-referrer-host {
    color: #646970;
    font-size: 12px;
}

.user-history-ua-full {
    color: #646970;
    font-size: 12px;
    cursor: help;
    border-bottom: 1px dotted #a7aaad;
}

@media screen and (max-width: 782px) {
    .user-history-registration-info {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }

    .user-history-registration-info dt {
        margin-top: 8px;
    }

    .user-history-registration-info dt:first-child {
        margin-top: 0;
    }
}

/* History table */
.user-history-table {
    margin-top: -1px;
    border-collapse: collapse;
    border-bottom-width: 2px !important;
}

.user-history-table th {
    text-align: left;
    background: #f6f7f7;
    padding: 10px 12px;
    font-weight: 600;
}

.user-history-table td {
    padding: 12px;
    vertical-align: top;
    border-bottom: 1px solid #f0f0f1;
}

.user-history-table tr:hover td {
    background: #f9f9f9;
}

/* Column widths */
.user-history-table .column-date {
    width: 140px;
}

.user-history-table .column-field {
    width: 150px;
}

.user-history-table .column-by {
    width: 120px;
}

/* Date display */
.history-date {
    display: block;
    font-weight: 500;
}

.history-time {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* Change values */
.history-old-value {
    color: #a00;
    text-decoration: line-through;
    background: #fef7f7;
    padding: 2px 6px;
    border-radius: 3px;
}

.history-arrow {
    color: #666;
    margin: 0 4px;
}

.history-new-value {
    color: #080;
    background: #f0fff0;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Self badge */
.history-self {
    background: #e5e5e5;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    color: #555;
}

/* Entry types */
.user-history-entry.type-create .column-field strong {
    color: #0073aa;
}

.user-history-entry.type-create .history-new-value {
    background: #e8f4fc;
    color: #0073aa;
}

/* History actions (Load More, Clear Log) */
.user-history-actions {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-history-actions .button {
    min-width: 100px;
}

.user-history-actions .button.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.user-history-clear-log {
    color: #a00;
    border-color: #a00;
}

.user-history-clear-log:hover,
.user-history-clear-log:focus {
    color: #dc3232;
    border-color: #dc3232;
}

/* Responsive adjustments */
@media screen and (max-width: 782px) {
    .user-history-table .column-date,
    .user-history-table .column-field,
    .user-history-table .column-by {
        width: auto;
    }

    .user-history-table th,
    .user-history-table td {
        padding: 8px;
        font-size: 13px;
    }

    .history-old-value,
    .history-new-value {
        display: block;
        margin: 2px 0;
    }

    .history-arrow {
        display: block;
        text-align: center;
    }
}

/* ==========================================================================
   Change Username Feature
   ========================================================================== */

.user-history-change-username-link {
    margin-left: 10px;
    text-decoration: none;
}

.user-history-change-username-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-history-change-username-form .user-history-new-username {
    min-height: 30px;
}

.user-history-change-username-message {
    display: none;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 13px;
    margin-left: 5px;
}

.user-history-change-username-message.success {
    background: #d4edda;
    color: #155724;
}

.user-history-change-username-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* ==========================================================================
   Lock/Unlock User Feature
   ========================================================================== */

/* Lock badge - used on user edit page and users list */
.user-history-lock-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.user-history-lock-badge.locked {
    background: #fef0f0;
    color: #b32d2e;
    border: 1px solid #f0c0c0;
}

.user-history-lock-badge.active {
    color: #787c82;
}

/* Lock + Delete buttons inside the Actions tab */
.user-history-action-block .button-link-delete {
    color: #b32d2e;
    border-color: #b32d2e;
    background: #fff;
}

.user-history-action-block .button-link-delete:hover,
.user-history-action-block .button-link-delete:focus {
    color: #fff;
    background: #b32d2e;
    border-color: #b32d2e;
}

/* Lock toggle message */
.user-history-lock-message {
    display: none;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 13px;
    margin-left: 10px;
}

.user-history-lock-message.success {
    background: #d4edda;
    color: #155724;
}

.user-history-lock-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* Lock/Unlock history entry types */
.user-history-entry.type-lock .column-field strong {
    color: #b32d2e;
}

.user-history-entry.type-lock .history-new-value {
    background: #fef0f0;
    color: #b32d2e;
}

.user-history-entry.type-unlock .column-field strong {
    color: #0a6b2e;
}

.user-history-entry.type-unlock .history-new-value {
    background: #d4edda;
    color: #0a6b2e;
}

/* ==========================================================================
   Login Events
   ========================================================================== */

.history-event-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
}

.history-event-label.event-login {
    background: #d4edda;
    color: #0a6b2e;
}

.history-event-label.event-logout {
    background: #f0f0f1;
    color: #50575e;
}

.history-event-label.event-login_failed {
    background: #fef0f0;
    color: #b32d2e;
}

.user-history-table .column-event {
    width: 120px;
}

.user-history-table .column-browser {
    width: 180px;
}

/* ==========================================================================
   Sessions Tab
   ========================================================================== */

.user-history-entry.session-current td {
    background: #f0f6fc;
}

.session-current-badge {
    display: inline-block;
    font-size: 11px;
    color: #2271b1;
    font-weight: 600;
    margin-left: 4px;
}

.session-expired-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    background: #fef0f0;
    color: #b32d2e;
}

.user-history-table .column-expires {
    width: 180px;
}

.user-history-destroy-sessions {
    color: #a00;
    border-color: #a00;
}

.user-history-destroy-sessions:hover,
.user-history-destroy-sessions:focus {
    color: #dc3232;
    border-color: #dc3232;
}

/* Users list locked column */
.column-user_locked {
    width: 80px;
}

