/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a1d29;
    --secondary: #2d3142;
    --accent: #4f5d75;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --text: #ecf0f1;
    --text-dim: #95a5a6;
    --border: #34495e;
    --card-bg: #252935;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1d29 0%, #2d3142 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.globe-link {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.globe-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.5);
}

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

.globe-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.globe-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

header h1 {
    font-size: 2.2em;
    font-weight: 700;
    margin-bottom: 5px;
}

.tagline {
    color: var(--text-dim);
    font-size: 0.95em;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(39, 174, 96, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--success);
}

.pulse {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--accent);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.stat-card.blocked {
    border-left-color: var(--danger);
}

.stat-card.threat {
    border-left-color: var(--warning);
}

.stat-card.safe {
    border-left-color: var(--info);
}

.stat-icon {
    font-size: 2.5em;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.85em;
    color: var(--text-dim);
    margin-top: 5px;
}

/* Countries Section */
.countries-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.countries-section h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
}

.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.country-item {
    background: var(--secondary);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s;
}

.country-item:hover {
    transform: scale(1.05);
    background: var(--accent);
}

.country-flag {
    font-size: 2em;
    margin-bottom: 8px;
}

.country-name {
    font-weight: 600;
    margin-bottom: 5px;
}

.country-count {
    font-size: 1.3em;
    color: var(--info);
    font-weight: 700;
}

/* Controls */
.controls {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.search-box {
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 12px 20px;
    background: var(--secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1em;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--info);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    background: var(--secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.filter-btn.active {
    background: var(--info);
    border-color: var(--info);
}

.sort-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sort-controls label {
    font-weight: 600;
}

.sort-controls select {
    padding: 8px 15px;
    background: var(--secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9em;
}

/* Logs Section */
.logs-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5em;
}

.log-count {
    color: var(--text-dim);
    font-size: 0.9em;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

.ip-table {
    width: 100%;
    border-collapse: collapse;
}

.ip-table thead {
    background: var(--secondary);
}

.ip-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ip-table td {
    padding: 15px;
    border-top: 1px solid var(--border);
}

.ip-table tbody tr {
    transition: background 0.2s;
}

.ip-table tbody tr:hover {
    background: var(--secondary);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.status-whitelist {
    background: rgba(39, 174, 96, 0.2);
    color: var(--success);
}

.status-blacklist {
    background: rgba(231, 76, 60, 0.2);
    color: var(--danger);
}

.status-gray {
    background: rgba(149, 165, 166, 0.2);
    color: var(--text-dim);
}

.threat-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 700;
}

.threat-critical { background: #e74c3c; color: white; }
.threat-high { background: #e67e22; color: white; }
.threat-medium { background: #f39c12; color: white; }
.threat-low { background: #95a5a6; color: white; }
.threat-minimal { background: #27ae60; color: white; }

.hits-badge {
    font-weight: 700;
    color: var(--warning);
}

.details-btn {
    padding: 6px 12px;
    background: var(--info);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: background 0.2s;
}

.details-btn:hover {
    background: #2980b9;
}

.loading-row {
    text-align: center;
    padding: 40px !important;
    color: var(--text-dim);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.pagination button {
    padding: 10px 20px;
    background: var(--secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--info);
    border-color: var(--info);
}

.pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.close {
    color: var(--text-dim);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-label {
    font-weight: 600;
    color: var(--text-dim);
}

.detail-value {
    font-weight: 600;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.9em;
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filter-buttons {
        flex-direction: column;
    }

    .table-wrapper {
        font-size: 0.85em;
    }
}
