@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- Base & Fonts --- */
:root {
    --bg-color: #f0f2f5;
    --bg-glow: radial-gradient(circle at 20% 10%, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0) 60%);
    --text-primary: #1c1c1e;
    --text-secondary: #4c4c52;
    --border-color: rgba(255, 255, 255, 0.4);
    --surface-color: rgba(255, 255, 255, 0.7);
    --surface-strong: rgba(255, 255, 255, 0.85);
    --shadow-color: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    --nav-bg: rgba(255, 255, 255, 0.7);
    --glow-accent: radial-gradient(circle at 80% 0%, rgba(10, 132, 255, 0.12), transparent 50%);
    --chart-grid: rgba(0, 0, 0, 0.08);
    --chart-tick: #3c3c43;
    --accent-blue: #0a84ff;
    --accent-blue-hover: #0077e6;
    --accent-red: #ff453a;
    --accent-red-hover: #ff2d21;
    --accent-green: #30d158;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Menlo', 'DejaVu Sans Mono', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1c1c1e;
        --bg-glow: radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 60%);
        --text-primary: #f0f0f5;
        --text-secondary: #a0a0a5;
        --border-color: rgba(255, 255, 255, 0.18);
        --surface-color: rgba(44, 44, 46, 0.7);
        --surface-strong: rgba(44, 44, 46, 0.85);
        --shadow-color: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
        --nav-bg: rgba(22, 22, 24, 0.7);
        --chart-grid: rgba(255, 255, 255, 0.1);
        --chart-tick: #a0a0a5;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    background-image: var(--bg-glow), var(--glow-accent);
    background-repeat: no-repeat, no-repeat;
    background-size: max(100vw, 1800px) 1200px, max(100vw, 1800px) 1200px;
    background-attachment: fixed, fixed;
    color: var(--text-primary);
    padding-top: 60px;
    padding-bottom: 24px;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Navigation --- */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.nav-container {
    max-width: 1024px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 24px;
}

.nav-logo {
    font-weight: 700;
    font-size: 20px;
    text-decoration: none;
    color: var(--text-primary);
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    margin-left: 24px;
    font-weight: 500;
    transition: color 0.2s ease-in-out;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

/* --- Layout & Cards --- */
.container {
    max-width: 1024px;
    margin: 32px auto;
    padding: 0 24px;
}

.header {
    padding: 20px 0;
}

.header h1 {
    font-size: 36px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.card {
    background-color: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
    box-shadow: var(--shadow-color);
}

.card:hover {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 18px;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

/* --- Forms & Buttons --- */
.form-inline {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.form-control {
    flex: 1;
    padding: 12px 16px;
    background-color: var(--surface-strong);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    color: var(--text-primary);
    transition: all 0.2s ease-in-out;
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.form-control:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-color: var(--accent-blue);
    color: white;
}

.btn:hover {
    background-color: var(--accent-blue-hover);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: var(--accent-red);
}

.btn-danger:hover {
    background-color: var(--accent-red-hover);
}

/* --- Rule List --- */
.rule-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
    gap: 16px;
}

.rule-item:last-child {
    border-bottom: none;
}

.rule-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.rule-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.domain {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

.target {
    color: var(--text-secondary);
    font-size: 14px;
}

.rule-status {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    box-shadow: 0 0 8px 2px var(--color);
}

.status-online {
    background-color: var(--accent-green);
    --color: var(--accent-green);
}

.status-offline {
    background-color: var(--accent-red);
    --color: var(--accent-red);
}

.last-access {
    font-size: 13px;
}

/* --- Stats & Logs --- */
#log-console {
    height: 350px;
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow-y: scroll;
    white-space: pre-wrap;
}

#log-console > div {
    padding: 2px 0;
}

canvas {
    width: 100% !important;
    height: 300px !important;
}

/* --- Disk Stats --- */
.disk-table {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.disk-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface-strong);
    border: 1px solid var(--border-color);
    gap: 16px;
    flex-wrap: wrap;
}

.disk-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.disk-title {
    font-weight: 600;
}

.disk-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
}

.disk-metrics {
    text-align: right;
    color: var(--text-secondary);
    font-size: 14px;
}

.disk-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.disk-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(10, 132, 255, 0.6), rgba(10, 132, 255, 0.9));
}

.disk-empty {
    color: var(--text-secondary);
    padding: 8px 0;
}

.country-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.country-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-strong);
}

.country-name {
    font-weight: 600;
    color: var(--text-primary);
}

.country-name span {
    font-weight: 500;
    color: var(--text-secondary);
}

.country-count {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--text-primary);
}

.ssh-current {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.ssh-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.ssh-table-head,
.ssh-row {
    display: grid;
    grid-template-columns: 1.3fr 1.2fr 1fr 0.8fr 1.2fr;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--surface-strong);
}

.ssh-table-head {
    margin-top: 8px;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.ssh-ip,
.ssh-date,
.ssh-time {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.ssh-country,
.ssh-device {
    color: var(--text-primary);
}

/* --- Maintenance Page --- */
.maintenance-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding-top: 0;
}

.maintenance {
    text-align: center;
    padding: 40px;
    border-radius: 20px;
    max-width: 520px;
    margin: 20px auto;
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-color);
    border: 1px solid var(--border-color);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .nav-container {
        padding: 0 16px;
    }

    .container {
        margin: 24px auto;
        padding: 0 16px;
    }
}

@media (max-width: 720px) {
    body {
        padding-top: 56px;
    }

    .nav {
        height: 56px;
    }

    .nav-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 8px 16px;
    }

    .nav-links a {
        margin-left: 0;
        margin-right: 16px;
    }

    .header h1 {
        font-size: 30px;
    }

    .card-body {
        padding: 20px;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }

    .rule-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
