/**
 * Activity Log Pro — Live Sessions page styles
 */

/* -------------------------------------------------------------------------
   White container — intro, lockdown, settings (matches Activity Logs layout)
   ---------------------------------------------------------------------- */

.alp-live-sessions-wrap .alp-sessions-intro {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #e5e5e5;
}

.alp-live-sessions-wrap .alp-sessions-intro h2 {
    margin: 0 0 8px;
    padding: 0;
    font-size: 1.3em;
    line-height: 1.3;
    color: #1d2327;
}

.alp-live-sessions-wrap .alp-container > .alp-lockdown-bar:first-child {
    padding-top: 20px;
}

.alp-live-sessions-wrap .alp-page-description {
    color: #666;
    font-size: 13px;
    margin: 0 0 12px;
    max-width: none;
}

.alp-live-sessions-wrap .alp-sessions-status-note {
    margin-bottom: 0;
    padding: 10px 12px;
    background: #f6f7f7;
    border-left: 3px solid #2271b1;
    border-radius: 0 3px 3px 0;
    max-width: none;
}

.alp-live-sessions-wrap .alp-lockdown-bar {
    padding: 16px 20px;
    margin-bottom: 0;
    border-bottom: 1px solid #e5e5e5;
}

.alp-live-sessions-wrap .alp-sessions-pagination {
    padding: 0 20px 20px;
}

.alp-settings-field-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.alp-settings-field-suffix {
    font-size: 12px;
    color: #646970;
    line-height: 1;
    white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Unified controls toolbar (.alp-filters) + Session Settings panel
   ---------------------------------------------------------------------- */

.alp-live-sessions-wrap .alp-sessions-controls {
    border-bottom: none;
}

.alp-live-sessions-wrap .alp-sessions-filter-row {
    align-items: flex-end;
}

.alp-live-sessions-wrap .alp-sessions-settings-item .button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
}

.alp-settings-toggle-arrow {
    font-size: 9px;
    color: #646970;
    margin-left: 2px;
}

/* Settings panel expands inside the grey filters strip */
.alp-live-sessions-wrap .alp-sessions-settings-panel-wrap {
    border-top: 1px solid #e5e5e5;
    background: #fff;
    margin-top: 12px;
    padding: 0 0 4px;
}

.alp-sessions-settings-panel {
    padding: 14px 0 0;
}

.alp-sessions-settings-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.alp-settings-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 160px;
}

.alp-settings-field label {
    font-weight: 600;
    font-size: 12px;
    color: #3c434a;
    display: flex;
    align-items: center;
    gap: 4px;
}

.alp-settings-field-locked label {
    color: #8c8f94;
}

.alp-settings-field-locked .dashicons-lock {
    color: #8c8f94;
    font-size: 14px;
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-left: 4px;
}

.alp-settings-field-locked select:disabled {
    color: #8c8f94;
    cursor: not-allowed;
}

/* Ensure the alp-help-icon inside settings panel labels aligns */
.alp-settings-field .alp-help-icon {
    margin-left: 1px;
    flex-shrink: 0;
}

.alp-sessions-settings-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f1;
}

.alp-settings-save-status {
    font-size: 12px;
    font-weight: 500;
}

.alp-status-ok {
    color: #00a32a;
}

.alp-status-error {
    color: #d63638;
}

/* -------------------------------------------------------------------------
   Lockdown bar
   ---------------------------------------------------------------------- */

.alp-lockdown-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alp-lockdown-bar:has(.alp-premium-setting-container) {
    display: block;
}

.alp-btn-danger {
    background: #d63638 !important;
    border-color: #c22d2f !important;
    color: #fff !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.alp-btn-danger:hover,
.alp-btn-danger:focus {
    background: #b32d2e !important;
    border-color: #9b292a !important;
    color: #fff !important;
}

.alp-btn-danger.alp-loading {
    opacity: 0.6;
    cursor: wait;
}

.alp-lockdown-desc {
    color: #646970;
    font-size: 13px;
}

.alp-live-sessions-wrap .alp-checkbox-label-inline {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 400;
    color: #3c434a;
    margin-bottom: 0;
}

/* Reserve width so the status text does not shift the checkbox when toggled */
.alp-sessions-live-indicator-slot {
    display: inline-flex;
    align-items: center;
    min-width: 175px;
    flex-shrink: 0;
    margin-left: 8px;
}

#alp-sessions-live-indicator {
    display: inline-flex;
    align-items: center;
    color: #46b450;
    font-size: 12px;
    gap: 4px;
}

#alp-sessions-live-indicator .spinner {
    margin: 0;
}

/* -------------------------------------------------------------------------
   Meta row — session count + last-updated timestamp
   ---------------------------------------------------------------------- */

.alp-live-sessions-wrap .alp-sessions-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e5e5e5;
    font-size: 12px;
    color: #646970;
    overflow: visible;
}

.alp-sessions-meta-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-width: 0;
    overflow: visible;
}

.alp-sessions-meta-sep {
    color: #c3c4c7;
    font-size: 12px;
    line-height: 1;
    user-select: none;
}

.alp-sessions-meta-live {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.alp-sessions-meta-live .alp-checkbox-label-inline {
    font-size: 12px;
    font-weight: 500;
}

.alp-sessions-meta-live .alp-sessions-live-monitor-help {
    flex-shrink: 0;
    margin-left: 0;
}

.alp-lockdown-bar .alp-lockdown-help {
    flex-shrink: 0;
    margin-left: 0;
}

#alp-sessions-count-label {
    font-weight: 600;
    color: #1d2327;
}

#alp-sessions-updated {
    color: #646970;
    font-style: italic;
}

.alp-sessions-meta-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Refresh icon button */
.alp-sessions-refresh-btn {
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    color: #8c8f94;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
}

.alp-sessions-refresh-btn:hover {
    color: #2271b1;
    background: #f0f0f1;
}

.alp-sessions-refresh-btn svg {
    display: block;
}

/* Spin animation while refreshing */
@keyframes alp-spin {
    from { transform: rotate( 0deg ); }
    to   { transform: rotate( 360deg ); }
}

.alp-sessions-refresh-btn.alp-spinning svg {
    animation: alp-spin 0.6s linear;
}

/* -------------------------------------------------------------------------
   Sessions table
   ---------------------------------------------------------------------- */

/* Table container — matches .alp-logs-container on Activity Logs screen */
.alp-sessions-container {
    padding: 15px;
    position: relative;
    overflow-x: auto;
}

.alp-sessions-table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 20px;
}

.alp-sessions-table th {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid #e5e5e5;
    font-weight: 600;
    background: #f6f7f7;
}

.alp-sessions-table td {
    padding: 12px 10px;
    vertical-align: top;
    border-bottom: 1px solid #f1f1f1;
}

.alp-sessions-table tr:last-child td {
    border-bottom: none;
}

/* Column widths — scoped to sessions table (overrides global .alp-col-user from alp-admin.css) */
.alp-sessions-table .alp-col-user {
    width: 22%;
    min-width: 200px;
}

.alp-sessions-table .alp-col-status {
    width: 8%;
    white-space: nowrap;
}

.alp-sessions-table .alp-col-role {
    width: 10%;
}

/* Status pills — mirrors severity-badge pattern */
.alp-session-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.6;
    white-space: nowrap;
    cursor: default;
}

.alp-session-status-active {
    background-color: #00a32a;
    color: #fff;
}

.alp-session-status-idle {
    background-color: #dcdcde;
    color: #1d2327;
}
.alp-sessions-table .alp-col-ip {
    width: 11%;
    font-family: monospace;
    font-size: 12px;
}

.alp-sessions-table .alp-col-location {
    width: 12%;
}

.alp-sessions-table .alp-col-browser {
    width: 12%;
}

.alp-sessions-table .alp-col-login {
    width: 12%;
    white-space: nowrap;
}

.alp-sessions-table .alp-col-actions {
    width: 13%;
    white-space: nowrap;
}

/* Current user row highlight */
.alp-session-self {
    background-color: #f0f6fc !important;
}

.alp-session-you {
    display: inline-block;
    background: #2271b1;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Session ID sub-row */
.alp-user-cell-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}

.alp-session-id-row {
    margin-top: 6px;
    font-size: 12px;
    color: #646970;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.alp-session-id-controls {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
}

.alp-session-expiry-row {
    margin-top: 4px;
    flex-wrap: wrap;
}

.alp-session-expiry-value {
    color: #3c434a;
}

.alp-session-id-label {
    font-weight: 600;
    color: #3c434a;
    white-space: nowrap;
}

.alp-session-id-value {
    font-family: monospace;
    font-size: 12px;
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 2px;
    color: #3c434a;
    white-space: nowrap;
    min-width: 0;
}

/* Copy-to-clipboard button */
.alp-session-id-copy {
    background: none;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    color: #8c8f94;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 2px;
}

.alp-session-id-copy:hover {
    color: #2271b1;
    background: #f0f0f1;
}

.alp-session-id-copy svg {
    display: block;
    width: 14px;
    height: 14px;
}

/* Copy success — checkmark state (no layout shift) */
.alp-session-id-copy.alp-copied {
    color: #00a32a;
    cursor: default;
}

.alp-session-id-copy.alp-copied:hover {
    color: #00a32a;
    background: #edfaef;
}

/* Help icon — match standard alp-help-icon size (was overridden smaller) */
.alp-session-id-help {
    width: 16px;
    height: 16px;
    margin-left: 0;
    flex-shrink: 0;
}

.alp-session-id-help svg {
    width: 16px;
    height: 16px;
}

/* New session highlight animation */
@keyframes alp-session-new-pulse {
    0%   { background-color: #fff8c5; }
    70%  { background-color: #fff8c5; }
    100% { background-color: transparent; }
}

.alp-session-highlight {
    animation: alp-session-new-pulse 3s ease-out;
}

/* User avatar */
.alp-session-avatar {
    border-radius: 50%;
    vertical-align: middle;
    width: 24px;
    height: 24px;
    margin-right: 6px;
}

.alp-session-login {
    color: #646970;
    font-size: 12px;
}

/* Location link — inherits IP popup trigger styles but removes the dotted underline */
.alp-location-link {
    border-bottom: none !important;
    color: inherit !important;
    text-decoration: none;
}
.alp-location-link:hover {
    color: #2271b1 !important;
    border-bottom: none !important;
}

/* Country code badge */
.alp-country-code {
    display: inline-block;
    background: #e7e9ec;
    color: #3c434a;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 2px;
    letter-spacing: 0.5px;
    margin-right: 4px;
    text-transform: uppercase;
    vertical-align: middle;
    font-family: monospace;
}

/* Locked feature cell (free users) */
.alp-col-locked {
    color: #8c8f94;
}

.alp-locked-feature {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #8c8f94;
}

.alp-locked-feature .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.alp-upgrade-link {
    color: #2271b1;
    text-decoration: none;
    font-size: 12px;
}

.alp-upgrade-link:hover {
    text-decoration: underline;
}

/* -------------------------------------------------------------------------
   Action buttons
   ---------------------------------------------------------------------- */

.alp-btn-activity {
    display: inline-flex !important;
    align-items: center;
    gap: 3px;
    font-size: 12px !important;
}

.alp-btn-activity .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.alp-btn-terminate {
    display: inline-flex !important;
    align-items: center;
    gap: 3px;
    font-size: 12px !important;
    color: #d63638 !important;
    border-color: #d63638 !important;
}

.alp-btn-terminate:hover:not(:disabled) {
    background: #d63638 !important;
    color: #fff !important;
}

.alp-btn-terminate.alp-btn-locked {
    color: #8c8f94 !important;
    border-color: #c3c4c7 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.alp-btn-terminate .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.alp-btn-terminate.alp-loading,
.alp-btn-activity.alp-loading {
    opacity: 0.6;
    cursor: wait;
}

/* -------------------------------------------------------------------------
   State rows
   ---------------------------------------------------------------------- */

.alp-sessions-loading,
.alp-sessions-empty,
.alp-sessions-error {
    text-align: center;
    padding: 30px 20px !important;
    color: #646970;
}

.alp-sessions-loading .spinner {
    vertical-align: middle;
}

.alp-sessions-error {
    color: #d63638;
}

/* -------------------------------------------------------------------------
   Pagination
   ---------------------------------------------------------------------- */

.alp-sessions-pagination {
    margin-top: 0;
}

.alp-pager {
    display: flex;
    align-items: center;
    gap: 8px;
}

.alp-pager-info {
    color: #646970;
    font-size: 13px;
}

/* -------------------------------------------------------------------------
   Inline notices (success/error feedback)
   ---------------------------------------------------------------------- */

.alp-sessions-notice {
    margin: 0 0 10px 0 !important;
}

/* -------------------------------------------------------------------------
   Responsive — mirrors Activity Logs .alp-logs-table @ 782px (alp-admin.css)
   ---------------------------------------------------------------------- */

@media screen and (max-width: 782px) {

    .alp-live-sessions-wrap .alp-lockdown-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .alp-live-sessions-wrap .alp-sessions-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .alp-live-sessions-wrap .alp-sessions-controls .alp-filter-item select,
    .alp-live-sessions-wrap .alp-sessions-controls .alp-filter-item input[type="search"] {
        width: 100%;
        max-width: none;
    }

    .alp-sessions-live-indicator-slot {
        min-width: 0;
    }

    .alp-live-sessions-wrap .alp-sessions-meta-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .alp-sessions-meta-left {
        flex-direction: column;
        align-items: flex-start;
    }

    .alp-sessions-meta-sep {
        display: none;
    }

    .alp-live-sessions-wrap .alp-sessions-table {
        display: block;
    }

    .alp-live-sessions-wrap .alp-sessions-table thead,
    .alp-live-sessions-wrap .alp-sessions-table tbody,
    .alp-live-sessions-wrap .alp-sessions-table th,
    .alp-live-sessions-wrap .alp-sessions-table td,
    .alp-live-sessions-wrap .alp-sessions-table tr {
        display: block;
    }

    .alp-live-sessions-wrap .alp-sessions-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .alp-live-sessions-wrap .alp-sessions-table tr.alp-session-row,
    .alp-live-sessions-wrap .alp-sessions-table tr.alp-session-self {
        border: 1px solid #e5e5e5;
        margin-bottom: 10px;
    }

    .alp-live-sessions-wrap .alp-sessions-table tr.alp-session-self {
        border-color: #2271b1;
    }

    .alp-live-sessions-wrap .alp-sessions-table td {
        border: none;
        border-bottom: 1px solid #f1f1f1;
        position: relative;
        padding-left: 40%;
        min-height: 30px;
        width: auto;
        min-width: 0;
        white-space: normal;
    }

    .alp-live-sessions-wrap .alp-sessions-table td:before {
        position: absolute;
        top: 12px;
        left: 10px;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: #646970;
    }

    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(1):before { content: "User"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(2):before { content: "Status"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(3):before { content: "Role"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(4):before { content: "IP Address"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(5):before { content: "Location"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(6):before { content: "Browser / OS"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(7):before { content: "Logged In"; }
    .alp-live-sessions-wrap .alp-sessions-table td:nth-of-type(8):before { content: "Actions"; }

    .alp-live-sessions-wrap .alp-sessions-table td.alp-sessions-loading,
    .alp-live-sessions-wrap .alp-sessions-table td.alp-sessions-empty,
    .alp-live-sessions-wrap .alp-sessions-table td.alp-sessions-error {
        padding-left: 12px;
        padding-right: 12px;
        min-height: auto;
    }

    .alp-live-sessions-wrap .alp-sessions-table td.alp-sessions-loading:before,
    .alp-live-sessions-wrap .alp-sessions-table td.alp-sessions-empty:before,
    .alp-live-sessions-wrap .alp-sessions-table td.alp-sessions-error:before {
        display: none !important;
        content: none !important;
    }

    .alp-live-sessions-wrap .alp-sessions-table .alp-col-actions {
        white-space: normal;
    }

    .alp-live-sessions-wrap .alp-sessions-table .alp-col-actions .button {
        margin: 0 6px 6px 0;
    }

    .alp-live-sessions-wrap .alp-sessions-table .alp-col-login {
        white-space: normal;
    }

    .alp-live-sessions-wrap .alp-session-expiry-value {
        word-break: normal;
    }
}
