/**
 * BotFend Anti-Bot Firewall - Admin Blocklist Styles
 * 
 * Based on logs page CSS, adapted for blocklist specific needs.
 * Provides styling for IP/range display, context dropdown (3-dot menu),
 * action buttons (View Logs, Unblock, Make Permanent), and modal for details.
 */

:root {
    --botfend-primary: #2271b1;
    --botfend-border: #c3c4c7;
    --botfend-bg-light: #f6f7f7;
    --botfend-radius: 6px;
    --botfend-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --botfend-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.botfend-wrap {
    max-width: 1400px;
    margin-top: 15px;
}

.botfend-header-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    gap: 15px;
}

.botfend-page-title {
    margin: 0 !important;
    display: flex;
    align-items: center;
}

/* URL placeholder for missing URLs */
.botfend-url-placeholder {
    color: #999;
    font-style: italic;
}

.botfend-card {
    background: #fff;
    border: 1px solid var(--botfend-border);
    border-radius: var(--botfend-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--botfend-shadow-sm);
}

.botfend-mb-20 { margin-bottom: 20px; }

.botfend-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.botfend-card-title {
    margin: 0;
    font-size: 1.2rem;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 8px;
}

.botfend-card-description {
    margin: 0 0 20px 0;
    color: #646970;
    font-size: 14px;
}

/* Statistics card */
.botfend-statistics-card {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f7ff 100%);
    border-left: 4px solid var(--botfend-primary);
}

.botfend-statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.botfend-statistic-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.botfend-statistic-icon {
    width: 48px;
    height: 48px;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    color: var(--botfend-primary);
    box-shadow: var(--botfend-shadow-sm);
}

.botfend-statistic-content {
    display: flex;
    flex-direction: column;
}

/* TOR Last Updated Date Formatting */
#botfend_tor_last_updated {
    color: #46b450 !important;
    font-weight: 600;
}

.botfend-statistic-number {
    font-size: 28px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1;
}

.botfend-statistic-label {
    font-size: 13px;
    color: #646970;
    margin-top: 4px;
}

/* Filter Form */
.botfend-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.botfend-filter-group {
    display: flex;
    flex-direction: column;
}

.botfend-filter-label {
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #1d2327;
}

.botfend-filter-input,
.botfend-filter-select {
    padding: 6px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    width: 100%;
    font-size: 13px;
    line-height: 1.5;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.botfend-filter-input:focus,
.botfend-filter-select:focus {
    border-color: var(--botfend-primary);
    box-shadow: 0 0 0 1px var(--botfend-primary);
    outline: none;
}

.botfend-filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid #f0f0f1;
    padding-top: 16px;
}

/* Empty State */
.botfend-empty-state {
    background: #fff;
    border: 1px dashed #c3c4c7;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    color: #50575e;
}

.botfend-empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #a7aaad;
    margin-bottom: 15px;
}

/* Table Responsive with Horizontal Scroll */
.botfend-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    margin-bottom: 0;
}

.botfend-blocklist-table {
    min-width: 900px;
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.botfend-blocklist-table th,
.botfend-blocklist-table td {
    padding: 12px 8px;
    vertical-align: middle;
}

.botfend-blocklist-table th {
    font-weight: 600;
    background: #f6f7f7;
    border-bottom: 1px solid var(--botfend-border);
}

/* Column widths */
.botfend-col-select {
    width: 40px;
    min-width: 40px;
}

.botfend-col-ip {
    min-width: 180px;
}

.botfend-col-country {
    min-width: 80px;
}

.botfend-col-type {
    min-width: 130px;
}

.botfend-col-score {
    min-width: 70px;
}

.botfend-col-expires {
    min-width: 150px;
}

.botfend-col-context {
    width: 60px;
    min-width: 60px;
    text-align: right;
}

/* IP cell */
.botfend-ip-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.botfend-ip-address {
    background: #f0f0f1;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    color: #1d2327;
    word-break: break-all;
    display: inline-block;
    width: fit-content;
}

.botfend-cidr-badge {
    background: var(--botfend-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 5px;
    display: inline-block;
}

.botfend-perpetual-badge {
    background: #f0ad4e;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 5px;
    display: inline-block;
    font-weight: 500;
    text-transform: uppercase;
}

.botfend-ip-reason {
    font-size: 12px;
    color: #646970;
    line-height: 1.4;
    max-width: 300px;
}

/* Country cell */
.botfend-country-cell {
    display: inline-flex;
    align-items: center;
}

.botfend-country-flag {
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.botfend-unknown {
    color: #8c8f94;
    font-style: italic;
}

/* Type badge */
.botfend-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.botfend-type-manual {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.botfend-type-auto_block {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.botfend-type-iphub_block {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.botfend-type-abuseipdb_block {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.botfend-type-honeypot {
    background: #e2d9f3;
    color: #3d2c5a;
    border: 1px solid #d6c7e8;
}

.botfend-type-brute_force {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.botfend-type-404_attack {
    background: #e2d9f3;
    color: #3d2c5a;
    border: 1px solid #d6c7e8;
}

.botfend-type-advanced_404_block {
    background: #e2d9f3;
    color: #3d2c5a;
    border: 1px solid #d6c7e8;
}

.botfend-type-permanent_manual {
    background: #dc3545;
    color: white;
    border: 1px solid #b02a37;
}

.botfend-type-perpetual_offender {
    background: #f0ad4e;
    color: white;
    border: 1px solid #d98c2e;
}

/* Score badge */
.botfend-score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--score-color);
    color: white;
    font-weight: bold;
    font-size: 13px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
}

/* Expiry cell */
.botfend-expiry-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.botfend-permanent {
    color: #dc3545;
    font-weight: 500;
}

.botfend-created-at {
    font-size: 11px;
    color: #8c8f94;
}

/* Context Dropdown (3-dot menu) */
.botfend-details-dropdown {
    position: relative;
    display: inline-block;
}

.botfend-details-toggle {
    background: #f6f7f7 !important;
    border-color: #dcdcde !important;
    padding: 0 6px !important;
    min-height: 28px !important;
    line-height: 26px !important;
}

.botfend-details-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    z-index: 1000;
    width: 380px;
    background: white;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--botfend-shadow-md);
    text-align: left;
}

.botfend-details-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 13px;
}

.botfend-detail-item {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid #f0f0f1;
    padding-bottom: 8px;
}
.botfend-detail-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.botfend-detail-label {
    font-weight: 600;
    color: #50575e;
    min-width: 70px;
    flex-shrink: 0;
}

.botfend-detail-value {
    color: #1d2327;
    word-break: break-word;
}

.badge-method {
    background: #e7e7e7;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
    display: inline-block;
}

.code-path {
    font-family: monospace;
    color: #2271b1;
    word-break: break-all;
}

/* Action buttons inside context dropdown */
.botfend-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: #f6f7f7;
    padding: 12px;
    border-radius: 6px;
    margin: -5px;
}

.botfend-action-button {
    font-size: 12px !important;
    padding: 4px 8px !important;
    height: auto !important;
    line-height: 1.4 !important;
}

.botfend-action-unblock {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.botfend-action-unblock:hover {
    background: #c3e6cb;
    color: #0c4128;
}

.botfend-action-permanent {
    background: #f0f0f1;
    color: #646970;
    border-color: #c3c4c7;
}
.botfend-action-permanent:hover {
    background: #dc3545;
    color: white;
    border-color: #b02a37;
}

.botfend-badge-permanent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f8f9fa;
    border-radius: 4px;
    color: #28a745;
    cursor: default;
}
.botfend-badge-permanent .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

/* Bulk action bar */
.botfend-bulk-action-bar {
    position: sticky;
    top: 32px;
    z-index: 100;
    background: linear-gradient(135deg, var(--botfend-primary) 0%, #135e96 100%);
    color: white;
    padding: 16px 24px;
    margin: 0 0 20px 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 123, 186, 0.2);
    animation: botfendFadeIn 0.3s ease;
}

.botfend-bulk-action-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.botfend-bulk-action-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.botfend-bulk-action-info .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.botfend-bulk-action-text {
    font-size: 16px;
    font-weight: 500;
}

#botfend-selected-count {
    font-weight: 700;
    color: #ffde59;
}

.botfend-bulk-action-buttons {
    display: flex;
    gap: 10px;
}

.botfend-bulk-action-button {
    background: white;
    color: var(--botfend-primary);
    border: none;
    font-weight: 500;
    padding: 8px 16px;
    height: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.botfend-bulk-action-button:hover {
    background: #f0f7ff;
    color: #135e96;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Checkbox and table actions */
.botfend-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
}

.botfend-checkbox-label {
    font-size: 13px;
    color: #646970;
    margin-left: 6px;
    vertical-align: middle;
}

.botfend-table-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.botfend-select-all {
    display: flex;
    align-items: center;
}

/* Quick block form */
.botfend-quick-block-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: flex-end;
}

.botfend-quick-block-input-group {
    flex: 1;
}

.botfend-input-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #1d2327;
    font-size: 13px;
}

.botfend-quick-block-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    box-sizing: border-box;
}

.botfend-quick-block-input:focus {
    border-color: var(--botfend-primary);
    box-shadow: 0 0 0 1px var(--botfend-primary);
    outline: none;
}

.botfend-input-description {
    margin: 6px 0 0 0;
    font-size: 12px;
    color: #646970;
}

.botfend-quick-block-actions {
    margin-bottom: 0;
}

.botfend-quick-block-button {
    min-height: 38px;
    padding: 0 24px;
    font-weight: 500;
}

/* Modal styles */
.botfend-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.botfend-modal-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.botfend-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.botfend-modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e4e7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfcfc;
    border-radius: 12px 12px 0 0;
}

.botfend-modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.botfend-modal-close-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #787c82;
    padding: 4px;
    border-radius: 4px;
}
.botfend-modal-close-icon:hover {
    background: #f0f0f1;
    color: #d63638;
}

.botfend-modal-body {
    padding: 0;
    overflow-y: auto;
    background: #1e1e1e;
    border-radius: 0 0 12px 12px;
}

.botfend-json-view pre {
    margin: 0;
    padding: 20px;
    color: #d4d4d4;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Clearing progress overlay */
.clearing-progress {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px 32px;
    border-radius: 8px;
    box-shadow: var(--botfend-shadow-md);
    z-index: 100001;
    text-align: center;
}
.clearing-progress h3 { margin-top: 0; }

/* Admin Notices */
#botfend-admin-notices {
    margin: 20px 0;
}

.botfend-notice {
    margin: 0 0 10px 0 !important;
    border-left-color: var(--botfend-primary) !important;
    animation: botfendNoticeFadeIn 0.3s ease;
}

.botfend-notice.notice-success {
    border-left-color: #46b450 !important;
}

.botfend-notice.notice-error {
    border-left-color: #dc3232 !important;
}

.botfend-notice.notice-warning {
    border-left-color: #ffb900 !important;
}

/* Summary stats */
.botfend-summary-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Animations */
@keyframes botfendNoticeFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes botfendFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* File Permission Inline Viewer Styles */
.botfend-permission-details-container {
    background: rgba(255, 255, 255, 0.7);
    padding: 12px 15px;
    border-radius: 4px;
}

.botfend-permission-file-list li {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f5c6cb;
    font-size: 13px;
}

.botfend-permission-file-list li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.botfend-file-path {
    background: #fff;
    padding: 3px 6px;
    color: #dc3232;
    border: 1px solid #f5c6cb;
    word-break: break-all;
    display: inline-block;
    margin-bottom: 4px;
}

.botfend-file-reason {
    color: #666;
    font-style: italic;
}

.botfend-badge-fixed {
    background: #46b450;
    color: #fff;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    font-style: normal;
}

/* Mobile Responsive */
@media screen and (max-width: 782px) {
    .botfend-filter-grid {
        grid-template-columns: 1fr;
    }

    .botfend-quick-block-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .botfend-quick-block-actions {
        margin-bottom: 0;
    }

    .botfend-quick-block-button {
        width: 100%;
    }

    .botfend-bulk-action-bar {
        top: 46px;
        border-radius: 0;
        margin: -20px -20px 20px -20px;
        width: calc(100% + 40px);
    }

    .botfend-bulk-action-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .botfend-bulk-action-buttons {
        width: 100%;
    }

    .botfend-bulk-action-button {
        flex: 1;
        justify-content: center;
    }

    .botfend-action-button .botfend-action-text {
        display: none;
    }

    .botfend-action-button {
        min-width: 32px;
        padding: 4px 8px;
        justify-content: center;
    }

    .botfend-modal-content {
        max-width: calc(100vw - 40px);
    }
}

@media screen and (max-width: 600px) {
    .botfend-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .botfend-statistics-grid {
        grid-template-columns: 1fr;
    }

    .botfend-statistic-item {
        justify-content: flex-start;
    }

    .botfend-filter-actions {
        flex-direction: column;
    }

    .botfend-filter-actions .button {
        width: 100%;
        justify-content: center;
    }

    .botfend-bulk-action-buttons {
        flex-direction: column;
    }

    .botfend-details-content {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 400px;
        max-height: 80vh;
        overflow-y: auto;
        z-index: 99999;
    }

    .botfend-details-toggle {
        padding: 4px 8px !important;
    }
/* ============================================
   Firewall Menu Highlight
   Shows red background when firewall is not configured
   Previously inline in AdminCoreManager.php
   ============================================ */
#adminmenu a[href="admin.php?page=botfend-firewall"] {
    background: #d63638 !important;
    color: #fff !important;
    font-weight: 600;
}

#adminmenu a[href="admin.php?page=botfend-firewall"]:hover {
    background: #b32d2e !important;
}

#adminmenu a[href="admin.php?page=botfend-firewall"] .dashicons-shield-alt {
    color: #fff !important;
}
	
}