﻿:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --bg-color: #f4f6f9;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --navbar-bg: #2c3e50;
    --navbar-text: #ffffff;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --text-muted: #a0a0a0;
    --border-color: #333333;
    --light-color: #2c2c2c;
    --navbar-bg: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    /* Prevent horizontal page scroll */
    width: 100%;
    max-width: 100vw;
    /* Never exceed viewport width */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* Layout */
.container {
    max-width: 1400px;
    /* Increased from 1200px for more space */
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header & Navbar */
header {
    background-color: var(--navbar-bg);
    box-shadow: var(--shadow-md);
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navbar-text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo img {
    height: 40px;
}

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

.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    padding: 0.5rem 0;
    /* Remove horizontal padding for cleaner look */
    margin: 0 1rem;
    border-radius: 0;
    transition: all 0.3s ease;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background-color: transparent;
    /* Remove background block */
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 50%;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
    left: 50%;
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--navbar-text);
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background-color: var(--navbar-bg);
        box-shadow: var(--shadow-md);
        padding: 1rem;
    }

    .nav-links.show {
        display: flex;
    }

    .menu-toggle {
        display: block;
    }
}

/* Main Content */
main {
    padding: 2rem 0;
    flex: 1;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Forms & Filters */
.filter-section {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Custom Radio Buttons as Tags */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.radio-group input[type="radio"] {
    display: none;
}

.radio-group label {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--text-color);
}

.radio-group input[type="radio"]:checked+label {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.radio-group label:hover {
    background-color: #e2e6ea;
}

.radio-group input[type="radio"]:checked+label:hover {
    background-color: var(--primary-hover);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    font-size: 0.95rem;
    min-width: 100px;
    /* Ensure consistent size */
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 123, 255, 0.2);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: var(--bg-color);
}

/* Tables */
.table-container {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.table th,
.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.table thead th {
    background-color: var(--bg-color);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.85rem;
    white-space: nowrap;
    /* Prevent wrapping */
}

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

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    display: inline-block;
    vertical-align: middle;
}

/* Footer */
footer {
    background-color: var(--navbar-bg);
    color: rgba(255, 255, 255, 0.8);
    padding: 3rem 0;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    color: #fff;
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.8rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.6);
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #fff;
    text-decoration: none;
}

.footer-bottom {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 2rem;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s;
}

.page-link:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.badge {
    padding: 0.25em 0.6em;
    font-size: 75%;
    font-weight: 700;
    border-radius: 0.25rem;
}

.badge-success {
    background-color: var(--success-color);
    color: white;
}

.badge-warning {
    background-color: var(--warning-color);
    color: #212529;
}

/* Flags */
.flag {
    display: inline-block;
    width: 16px;
    height: 11px;
    background: url('../img/flags.png') no-repeat;
    vertical-align: middle;
    margin-right: 5px;
}

/* Speed Bar */
.speed-bar {
    height: 6px;
    background-color: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    width: 80px;
    display: inline-block;
    vertical-align: middle;
}

.speed-bar-fill {
    height: 100%;
    border-radius: 3px;
}

/* Mini CTA (New) */
.mini-cta {
    background: linear-gradient(to right, #667eea, #764ba2);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.mini-cta-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mini-cta-btn {
    background-color: white;
    color: #764ba2;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.mini-cta-btn:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
}


/* Refined Button Styles */
.btn {
    border-radius: 4px;
    /* Less rounded */
}

.logo img {
    height: 40px;
    /* Increased from 32px to match navbar height better */
    width: auto;
}

.btn-outline {
    background-color: #6c757d;
    /* Medium gray for better visibility */
    border: 1px solid #6c757d;
    color: #fff;
}

.btn-outline:hover {
    background-color: #5a6268;
    color: #fff;
    border-color: #545b62;
}

/* Refined Form Styles */
.form-control {
    border-radius: 4px;
}

.radio-group label {
    border-radius: 4px;
}

/* Table Tweaks */
.table td {
    white-space: nowrap;
}

/* Specific column width constraints */
.table th:nth-child(1),
.table td:nth-child(1) {
    width: 130px;
}

/* IP Address - slightly reduced */
.table th:nth-child(2),
.table td:nth-child(2) {
    width: 65px;
}

/* Port */
.table th:nth-child(3),
.table td:nth-child(3) {
    width: 170px;
}

/* Country */
.table th:nth-child(4),
.table td:nth-child(4) {
    width: 110px;
}

/* City */
.table th:nth-child(5),
.table td:nth-child(5) {
    width: 130px;
}

/* Speed */
.table th:nth-child(6),
.table td:nth-child(6) {
    width: 180px;
    /* Increased to fit multiple badges */
}

/* Type */
.table th:nth-child(7),
.table td:nth-child(7) {
    width: 85px;
}

/* Anonymity */
.table th:nth-child(8),
.table td:nth-child(8) {
    width: 120px;
    min-width: 120px;
}

/* Last Check - always visible */

/* Keep Type badges in one line */
.table td:nth-child(6) {
    white-space: nowrap;
}

/* Make badges more compact */
.table td:nth-child(6) .badge {
    display: inline-block;
    margin-right: 3px;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}

.country-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-truncate {
    max-width: 180px;
}

/* Pagination Tweaks */
.page-link {
    border-radius: 4px;
}

/* ===== PORT PAGE STYLES ===== */
.port-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.5rem;
}

.port-grid-compact {
    grid-template-columns: repeat(8, 1fr);
    gap: 1.2rem;
}

.port-card {
    position: relative;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.port-card-featured {
    color: white;
    min-height: 140px;
}

.port-card-featured:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.3);
}

.port-card-standard {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    min-height: 100px;
}

.port-card-standard:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.port-number {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
}

.port-card-standard .port-number {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.port-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.count-label {
    font-size: 0.7rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.count-value {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.2rem 0.8rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
}

.port-card-standard .count-value {
    background: var(--primary-color);
    color: white;
    font-size: 0.9rem;
}

.port-rank {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-weight: 600;
}

/* ===== MOBILE RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {

    /* Prevent page-level horizontal scroll */
    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    * {
        max-width: 100%;
    }

    /* Container */
    .container {
        padding: 0 0.5rem;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Cards should not overflow */
    .card {
        padding: 1rem;
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Filter section */
    .filter-section {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Only table container should scroll horizontally */
    .table-container {
        overflow-x: hidden;
        max-width: 100%;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        margin: 0 -0.5rem;
        /* Extend to card edges */
        padding: 0 0.5rem;
    }

    /* Hide some table columns on mobile */
    .table th:nth-child(4),
    /* City */
    .table td:nth-child(4),
    .table th:nth-child(7),
    /* Anonymity */
    .table td:nth-child(7) {
        display: none;
    }

    /* Adjust remaining columns - use fixed pixel widths */
    .table {
        min-width: 600px;
        /* Set minimum table width to ensure scrollability */
        font-size: 0.85rem;
    }

    .table th:nth-child(1),
    .table td:nth-child(1) {
        width: 110px;
        font-size: 0.85rem;
    }

    /* IP */
    .table th:nth-child(2),
    .table td:nth-child(2) {
        width: 50px;
        font-size: 0.85rem;
    }

    /* Port */
    .table th:nth-child(3),
    .table td:nth-child(3) {
        width: 130px;
        font-size: 0.85rem;
    }

    /* Country */
    .table th:nth-child(5),
    .table td:nth-child(5) {
        width: 100px;
    }

    /* Speed */
    .table th:nth-child(6),
    .table td:nth-child(6) {
        width: 90px;
    }

    /* Type */
    .table th:nth-child(8),
    .table td:nth-child(8) {
        width: 90px;
        font-size: 0.8rem;
    }

    /* Last Check */

    .table th,
    .table td {
        padding: 0.5rem 0.3rem;
    }

    /* Simplify speed display on mobile */
    .speed-bar {
        width: 40px !important;
        height: 6px;
    }

    /* Make Type badges smaller */
    .table td:nth-child(6) .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.3rem;
        margin-right: 2px;
    }

    /* Filter section - stack elements vertically */
    .filter-section .d-flex {
        flex-direction: column !important;
        gap: 15px !important;
    }

    .filter-section .form-group {
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
    }

    /* Radio buttons - wrap on mobile */
    .radio-group {
        flex-wrap: wrap;
        gap: 8px;
    }

    .radio-group label {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    /* Buttons */
    .filter-section .btn {
        width: 100%;
    }

    /* Mini CTA - stack vertically */
    .mini-cta {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
        gap: 1rem;
    }

    .mini-cta-content {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    /* Card */
    .card {
        padding: 1rem;
    }

    /* Pagination - smaller on mobile */
    .pagination {
        gap: 4px;
    }

    .page-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Country cell - ensure no wrapping */
    .country-cell .text-truncate {
        max-width: 80px;
    }

    /* Footer - stack columns */
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-section {
        margin-bottom: 1.5rem;
    }

    /* Port page mobile adjustments */
    .port-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.8rem;
    }

    .port-grid-compact {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.6rem;
    }

    .port-card {
        padding: 1rem 0.5rem;
        min-height: 110px !important;
    }

    .port-card-standard {
        min-height: 85px !important;
    }

    .port-number {
        font-size: 1.4rem;
    }

    .port-card-standard .port-number {
        font-size: 1.2rem;
    }

    .count-value {
        font-size: 0.9rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {

    /* Further reduce table column widths */
    .table th:nth-child(1),
    .table td:nth-child(1) {
        width: 100px;
    }

    /* IP */
    .table th:nth-child(3),
    .table td:nth-child(3) {
        width: 100px;
    }

    /* Country */
    .table th:nth-child(5),
    .table td:nth-child(5) {
        width: 85px;
    }

    /* Speed */
    .table th:nth-child(6),
    .table td:nth-child(6) {
        width: 70px;
    }

    /* Type */

    /* Hide Type column on very small screens */
    .table th:nth-child(6),
    .table td:nth-child(6) {
        display: none;
    }

    /* Smaller fonts */
    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.4rem 0.2rem;
    }
}