:root {
    --bg-blur: 8px; /* Background blur effect */
    --bg-brightness: 0.7; /* Background brightness */
    --container-bg-opacity: 0.5; /* Opacity of the main container background */
    --card-bg-opacity: 0.7; /* Opacity of device card backgrounds */
    --text-color-primary: #333;
    --text-color-secondary: #555;
    --border-color: #e0e0e0;
    --header-bg-start: #2c3e50;
    --header-bg-end: #34495e;
    --online-color: #4caf50;
    --offline-color: #f44336;
    --maybe-color: #ff9800;
    --screen-off-color: #ef6c00;
    --locked-color: #1565c0;
    --info-label-color: #666;
    --footer-text-color: #777;
    --link-color: #fba414;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('https://img.zerowolf.cn/auto');
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    background-repeat: no-repeat;
    filter: blur(var(--bg-blur)) brightness(var(--bg-brightness));
    transition: filter 0.8s ease, opacity 0.8s ease;
    z-index: -1;
    opacity: 0.9; /* Slightly reduce background image opacity */
}

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

a:hover {
    opacity: 0.8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: transparent; /* Changed to transparent to show the pseudo-element background */
    color: var(--text-color-primary);
    min-height: 100vh;
    padding: 20px;
    position: relative;
    line-height: 1.6; /* Improved readability */
    border-radius: 10px; /* Softer look for the body */
}

.container {
    max-width: 1200px;
    margin: 20px auto; /* Add margin to top/bottom */
    background-color: rgba(255, 255, 255, var(--container-bg-opacity)); /* Glassmorphism effect */
    backdrop-filter: blur(10px); /* Glassmorphism blur */
    border-radius: 15px; /* Softer rounded corners */
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25); /* More pronounced shadow */
    overflow: hidden;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.3); /* Subtle border for glass effect */
}

header {
    background: linear-gradient(135deg, var(--header-bg-start), var(--header-bg-end)); /* Gradient background */
    color: white;
    padding: 30px 25px; /* Increased padding */
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

h1 {
    font-size: 3rem; /* Larger heading */
    margin-bottom: 12px;
    letter-spacing: 1px; /* Slightly more spaced out */
}

.subtitle {
    font-size: 1.3rem; /* Slightly larger subtitle */
    opacity: 0.95;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300; /* Lighter font weight */
}

.status-container {
    padding: 30px; /* Consistent padding */
    display: flex;
    flex-direction: column;
    gap: 25px; /* Spacing between sections */
}

.online-status,
.maybe-status,
.offline-status,
.error-status {
    background-color: rgba(255, 255, 255, var(--card-bg-opacity)); /* Use opacity variable */
    border-left: 5px solid;
    padding: 22px;
    margin-bottom: 0; /* Remove margin-bottom as gap handles spacing */
    border-radius: 10px; /* Slightly more rounded */
    display: flex;
    align-items: center;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1); /* Refined shadow */
    transition: all 0.3s ease; /* Smooth transitions */
}

.online-status { border-color: var(--online-color); }
.maybe-status { border-color: var(--maybe-color); }
.offline-status { border-color: var(--offline-color); }
.error-status { border-color: var(--offline-color); }

.status-icon {
    font-size: 3rem; /* Larger icons */
    margin-right: 25px;
}

.status-text {
    font-size: 1.5rem; /* Larger status text */
    font-weight: bold;
    color: var(--text-color-primary);
}

.status-detail {
    margin-top: 6px; /* Adjusted margin */
    font-size: 1.05rem;
    font-weight: normal;
    opacity: 0.85;
    color: var(--text-color-secondary);
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); /* Slightly wider cards */
    gap: 25px; /* Increased gap */
}

.device-card {
    background: rgba(255, 255, 255, var(--card-bg-opacity)); /* Glassmorphism background */
    border-radius: 12px; /* More rounded corners */
    padding: 25px; /* Increased padding */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); /* Enhanced shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.4); /* Subtle glass border */
    backdrop-filter: blur(8px); /* Card-specific glassmorphism blur */
}

.device-card:hover {
    transform: translateY(-7px); /* More pronounced lift effect */
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.2);
    background-color: rgba(255, 255, 255, calc(var(--card-bg-opacity) + 0.1)); /* Slight opacity increase on hover */
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px; /* Adjusted margin */
    border-bottom: 1px solid var(--border-color); /* Use variable */
    padding-bottom: 12px; /* Adjusted padding */
}

.device-name-container {
    display: flex;
    align-items: center;
    gap: 10px; /* Increased gap */
}

.device-name {
    font-size: 1.4rem; /* Larger device name */
    font-weight: bold;
    color: var(--text-color-primary);
}

.ignored-label {
    font-size: 0.95rem;
    color: var(--text-color-secondary);
    font-weight: normal;
    opacity: 0.7;
}

.device-status {
    padding: 6px 14px;
    border-radius: 25px;
    font-size: 0.95rem; /* Slightly larger font */
    font-weight: bold;
    text-transform: uppercase; /* Uppercase for status */
    letter-spacing: 0.5px;
    white-space: nowrap; /* Prevent status text from wrapping */
}

.online {
    background-color: rgba(76, 175, 80, 0.15); /* Softer background */
    color: var(--online-color);
}

.offline {
    background-color: rgba(244, 67, 54, 0.15);
    color: var(--offline-color);
}

.screen-off {
    background-color: rgba(255, 152, 0, 0.15);
    color: var(--screen-off-color);
}

.locked {
    background-color: rgba(21, 101, 192, 0.15);
    color: var(--locked-color);
}

.heartbeat-timeout {
    background-color: rgba(244, 67, 54, 0.15);
    color: var(--offline-color);
    border: 1px dashed var(--offline-color); /* Dashed border for emphasis */
}

.device-info {
    margin-top: 20px; /* Increased margin */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Spacing between info items */
}

.info-item {
    margin-bottom: 0; /* Remove default margin */
    display: flex;
    align-items: center; /* Vertically align items */
    gap: 15px; /* Spacing between label and value */
}

.info-label {
    font-weight: 600; /* Slightly bolder */
    min-width: 100px; /* Adjusted min-width for consistency */
    color: var(--info-label-color);
    font-size: 0.95rem;
}

.info-value {
    flex: 1;
    word-break: break-word;
    color: var(--text-color-primary);
    font-size: 0.95rem;
}

.battery-low {
    color: var(--offline-color);
    font-weight: bold;
}

.battery-charging {
    color: var(--maybe-color);
    font-weight: bold;
}

.battery-charged {
    color: var(--online-color);
    font-weight: bold;
}

.battery-normal {
    color: var(--text-color-primary);
}

footer {
    text-align: center;
    padding: 25px 20px; /* Adjusted padding */
    color: var(--footer-text-color);
    margin-top: 40px; /* Increased margin */
    font-size: 0.95rem;
    opacity: 0.9; /* Slightly softer text */
}

@media (max-width: 768px) {
    .devices-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .device-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px; /* Adjusted gap */
    }

    .device-name-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px; /* Adjusted gap */
    }

    .status-icon {
        font-size: 2.5rem;
    }

    .status-text {
        font-size: 1.3rem;
    }

    .status-detail {
        font-size: 0.95rem;
    }

    .device-card {
        padding: 20px;
    }

    .device-name {
        font-size: 1.2rem;
    }

    .info-label {
        min-width: 90px;
    }
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.3rem;
    color: var(--text-color-secondary);
}

.refresh-btn {
    background-color: var(--header-bg-start); /* Use header color */
    color: white;
    border: none;
    padding: 12px 25px; /* Increased padding */
    border-radius: 8px; /* More rounded */
    cursor: pointer;
    font-size: 1.05rem;
    margin-top: 20px; /* Adjusted margin */
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.refresh-btn:hover {
    background-color: var(--header-bg-end); /* Darker on hover */
    transform: translateY(-2px);
}

.refresh-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.refresh-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: translateY(0);
    box-shadow: none;
}

.next-update {
    text-align: center;
    margin-top: 18px; /* Adjusted margin */
    font-size: 1rem;
    color: var(--info-label-color);
    font-weight: 500;
}

#countdown {
    font-weight: bold;
    color: var(--text-color-primary);
}