* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: rgb(248, 250, 252);
    color: #333;
    line-height: 1.6;
}

.header {
    background: linear-gradient(135deg, #5d7a99, #7b97b8);
    color: white;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo {
    height: 60px;
    width: auto;
}

.header h1 {
    font-size: 2rem;
    font-weight: 600;
}

.site-selector-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.site-selector-container label {
    font-weight: 500;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

.filter-container input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-container label {
    cursor: pointer;
    font-weight: 500;
}

#siteSelector {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 2px solid white;
    border-radius: 6px;
    background-color: white;
    color: rgb(33, 0, 110);
    cursor: pointer;
    min-width: 200px;
}

#siteSelector:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.device-container {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    max-width: 1600px;
    margin: 0 auto;
}

.device-card {
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.device-card-header {
    margin-bottom: 0.5rem;
}

.device-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    word-break: break-word;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
}

.device-card-title.status-online {
    background-color: #10b981;
}

.device-card-title.status-offline {
    background-color: #ef4444;
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.device-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.device-info-label {
    font-weight: 600;
    color: rgb(33, 0, 110);
    min-width: 110px;
}

.device-info-value {
    color: #555;
    word-break: break-all;
}

.ports-section {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
}

.ports-title {
    font-weight: 600;
    color: rgb(33, 0, 110);
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.port-item {
    padding: 0.3rem 0.4rem;
    background-color: rgb(248, 250, 252);
    border-radius: 3px;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
}

/* Modal Styles */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    color: rgb(33, 0, 110);
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 1rem;
    color: #555;
}

#apiKeyInput {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 1rem;
}

#apiKeyInput:focus {
    outline: none;
    border-color: rgb(218, 49, 119);
}

.modal-error {
    color: #ef4444;
    margin-bottom: 1rem;
    min-height: 1.5rem;
    font-weight: 500;
}

#submitApiKey {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, rgb(218, 49, 119), rgb(33, 0, 110));
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

#submitApiKey:hover {
    opacity: 0.9;
}

#submitApiKey:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Device Details Modal */
.device-details-modal {
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    flex: 1;
    padding-right: 1rem;
}

.close-button {
    background: none;
    border: none;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: color 0.2s;
    flex-shrink: 0;
}

.close-button:hover {
    color: rgb(218, 49, 119);
}

#deviceDetailsContent {
    overflow-y: auto;
    max-height: calc(85vh - 150px);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid rgb(218, 49, 119);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    grid-column: 1 / -1;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: rgb(33, 0, 110);
    margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .logo {
        height: 45px;
    }

    .device-container {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .site-selector-container {
        flex-direction: column;
        align-items: flex-start;
    }

    #siteSelector {
        width: 100%;
    }

    .filter-container {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .logo {
        height: 35px;
    }

    .device-card {
        padding: 0.5rem;
    }

    .device-info-row {
        flex-direction: column;
    }

    .device-info-label {
        min-width: auto;
    }
}
