:root {
    --primary-white: #e7e7e7;
    --seconday-highlight: #ffffff52;
    --primary-dark: #120f25;
    --seconday-dark: #1d2b41;
    --border-size: 20px;
    --border-style: 2px solid var(--primary-white);
}

body {
    color: var(--primary-white);
    font-family: "Source Code Pro", monospace;
    overflow: overlay;
    min-height: calc(100vh - 20px);
    margin: 10px 0;
    position: relative;
    background-color: var(--primary-dark);
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 300vh;
    z-index: -1;
    pointer-events: none;
    margin-top: -50vh;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><rect x='49' y='0' width='1' height='50' fill='%23253650'/><rect x='0' y='49' width='50' height='1' fill='%23253650'/></svg>") repeat,
        linear-gradient(to bottom right, var(--primary-dark), var(--seconday-dark));
    background-size: 50px 50px, 100% 200%;
    background-position: var(--x-offset) -70px, 0 0;
    transform: translateY(var(--parallax-offset, 0px));
}

main {
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    border: 3px solid var(--primary-white);
    padding: 20px;
    border-radius: var(--border-size);
    width: 80vw;
    min-width: 280px;
    max-width: 1200px;
    box-sizing: border-box;
    backdrop-filter: blur(3px);
    background-color: #120f2599;
}

h1 {
    text-align: center;
    width: 100%;
    margin-bottom: 20px;
}

.box {
    border: var(--border-style);
    border-radius: var(--border-size);
    padding: 20px;
    margin-bottom: 20px;
}

fieldset {
    flex-direction: column;
    display: flex;
    padding: 20px;
}

legend {
    font-size: 1.2em;
    font-weight: bold;
    padding: 0 10px;
}

p {
    margin-top: 0px;
    font-size: 1.4em;
}

.col {
    display: flex;
    width: 100%;
    flex-direction: column;
}

.row {
    display: flex;
    flex-direction: row;
}

.widgets {
    width: 100%;
}

.widget {
    display: flex;
    width: 100%;
    height: fit-content;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

.widget-link {
    text-decoration: none;
    color: inherit;
}

.widget-link .widget {
    transition: background-color 0.2s ease-in-out;
}

.widget-link:hover .widget {
    background-color: var(--seconday-dark);
}

.pfp {
    width: 60px;
    height: 60px;
    object-fit: cover;
    margin-right: 15px;
    flex-shrink: 0;
}

.col h3 {
    font-size: 1.5em;
    margin: 0;
}

.profile {
    margin-left: 10px;
}

.stat-item {
    margin-bottom: 15px;
}

.stat-item p {
    margin: 0;
    font-size: 1.1em;
    color: #c0c0c0;
}

.stat-item .value {
    font-size: 2em;
    font-weight: bold;
    color: var(--primary-white);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-header .stat-item {
    margin-bottom: 0;
}

.graph-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.graph-toggle-btn {
    background-color: transparent;
    border: 1px solid var(--primary-white);
    color: var(--primary-white);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-family: inherit;
    font-size: 0.9em;
}

.graph-toggle-btn:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.graph-toggle-btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-left-width: 0;
}

.graph-toggle-btn.active,
.graph-toggle-btn:hover {
    background-color: var(--primary-white);
    color: var(--primary-dark);
}

.fleet-players {
    font-size: 1em !important;
    color: #c0c0c0;
    margin-top: 4px;
}

.error-message {
    color: #ff5252;
    background-color: rgba(255, 82, 82, 0.1);
    border: 1px solid #ff5252;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    width: 100%;
}

.back-link {
    font-size: 1.2em;
    text-decoration: none;
    color: var(--primary-white);
    margin-bottom: 20px;
    display: inline-block;
}

.back-link:hover {
    text-decoration: underline;
}

.stations-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.region-group {
    padding: 20px;
    background-color: #1d2b4152;
}

.region-group summary {
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2em;
    list-style: none;
    margin: -20px -20px 15px;
    padding: 20px;
}

.region-group summary::-webkit-details-marker { display: none; }

.region-group summary::before {
    content: '▼';
    margin-right: 0.7em;
    display: inline-block;
    transition: transform 0.2s ease-in-out;
    transform: rotate(-90deg);
}

.region-group[open] summary::before { transform: rotate(0deg); }

.station-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.station-card {
    background-color: var(--seconday-dark);
    border-radius: 15px; /* Slightly smaller radius to nest nicely */
    border: 1px solid #253a52;
    transition: background-color 0.2s;
}

.station-card:hover { background-color: #253650; }

.station-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
}

.station-name { font-weight: bold; color: var(--primary-white); }
.station-ip {
    font-family: 'Source Code Pro', monospace;
    color: #a0c2e3;
    font-size: 0.9em;
}
.station-icons {
    display: flex;
    gap: 0.8rem;
    font-size: 1.2em;
    justify-content: center;
}

.status-icon { font-size: 1.5em; line-height: 1; }
.status-icon.online { color: #28a745; }
.status-icon.offline { color: #dc3545; }
.icon-disabled { opacity: 0.3; }

.station-populations {
    padding: 0rem 0rem 1rem;
    font-size: 0.9em;
}
.station-populations summary {
    cursor: pointer;
    color: #a0c2e3;
    list-style: none;
}
.station-populations summary::-webkit-details-marker { display: none; }
.station-populations summary::before {
    content: '►';
    margin-right: 0.5em;
    font-size: 0.8em;
    display: inline-block;
    transition: transform 0.2s ease-in-out;
}
.station-populations details[open] > summary::before { transform: rotate(90deg); }

.station-populations ul {
    list-style-type: none;
    padding: 0.5rem 0 0 1.5rem;
    margin: 0;
    color: #cdd8e4;
}
.station-populations li { padding: 0.2rem 0; }


/* Media Queries */
@media only screen and (max-width: 1200px) {
    main { width: 95vw; }
}

@media only screen and (max-width: 800px) {
    body { margin: 0; }
    main {
        width: 100%;
        min-height: 100vh;
        border: 0;
        margin: 0;
        border-radius: 0;
    }
    .row { flex-direction: column; }
    .widgets { margin-left: 0; }
    .col.widgets { margin-left: 0; }
}

@media (max-width: 768px) {
    .station-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        text-align: center;
    }
}