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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.7; transform: scale(1); }
}

/* Smooth value transition */
.stat-number, .metric-value {
    transition: all 0.3s ease;
}

.stat-number.updating, .metric-value.updating {
    background: rgba(40, 167, 69, 0.1);
    transform: scale(1.02);
}

.header {
    text-align: left;
    margin-bottom: 30px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
}

/* Desktop-specific styles */
@media (min-width: 769px) {
    .logo-title-container {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 20px;
    }
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.last-updated {
    opacity: 0.8;
    font-size: 0.9em;
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.logout-button {
    background: rgba(244, 67, 54, 0.8);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.logout-button:hover {
    background: rgba(244, 67, 54, 1);
}

.refresh-button {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.refresh-button:hover {
    background: rgba(76, 175, 80, 1);
}

.admin-link-button {
    background: rgba(33, 150, 243, 0.8);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.admin-link-button:hover {
    background: rgba(33, 150, 243, 1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    opacity: 0.8;
    font-size: 0.9em;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.device-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}


.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(33, 150, 243, 0.2);
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 15px auto 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.detail-link {
    display: block;
    width: 100%;
    margin-top: 15px;
    padding: 12px 16px;
    background: rgba(76, 175, 80, 0.8);
    color: white;
    text-decoration: none;
    text-align: center;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.detail-link:hover {
    background: rgba(76, 175, 80, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.device-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--status-color);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.device-name {
    font-size: 1.3em;
    font-weight: bold;
}

.status-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}

.online {
    background: #4CAF50;
    --status-color: #4CAF50;
}

.warning {
    background: #FF9800;
    --status-color: #FF9800;
}

.offline {
    background: #F44336;
    --status-color: #F44336;
}

.device-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 15px;
}

.metric {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.metric-value {
    font-size: 1.2em;
    font-weight: bold;
}

.metric-label {
    font-size: 0.8em;
    opacity: 0.8;
}

/* Color coding for operational metrics */
.metric.status-good {
    background: rgba(76, 175, 80, 0.9);
    border: 2px solid rgba(76, 175, 80, 1);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(76, 175, 80, 0.3);
}

.metric.status-warning {
    background: rgba(255, 152, 0, 0.9);
    border: 2px solid rgba(255, 152, 0, 1);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(255, 152, 0, 0.3);
}

.metric.status-critical {
    background: rgba(244, 67, 54, 0.9);
    border: 2px solid rgba(244, 67, 54, 1);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(244, 67, 54, 0.3);
}

.metric.status-good .metric-value,
.metric.status-good .metric-label {
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.metric.status-warning .metric-value,
.metric.status-warning .metric-label {
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.metric.status-critical .metric-value,
.metric.status-critical .metric-label {
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

/* Enhanced location display styling */
.location-display {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
}

.location-icon {
    font-size: 16px;
    line-height: 1;
    margin-top: 1px;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
}

.location-content {
    flex: 1;
    min-width: 0; /* Allows text to truncate */
}

.location-name {
    font-size: 0.9em;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    line-height: 1.3;
    margin-bottom: 3px;
    word-wrap: break-word;
}

.location-time {
    font-size: 0.75em;
    opacity: 0.8;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    font-style: italic;
}

/* Custom marker label overlay styling */
.marker-label-overlay {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 1000;
    white-space: nowrap;
    pointer-events: none; /* Allows clicking through to map */
}

.data-table {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

.collapsible-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: opacity 0.2s;
}

.collapsible-header:hover {
    opacity: 0.8;
}

.expand-icon {
    font-size: 1.2em;
    transition: transform 0.3s ease;
    margin-left: 10px;
}

.expand-icon.expanded {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-content.expanded {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar styling */
.collapsible-content::-webkit-scrollbar {
    width: 10px;
}

.collapsible-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.collapsible-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

.collapsible-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

table {
    width: 100%;
    border-collapse: collapse;
    position: relative;
    z-index: 2;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
    background: rgba(255, 255, 255, 0.1);
    font-weight: bold;
}

tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.2em;
}

.error {
    background: rgba(244, 67, 54, 0.2);
    color: #ffcdd2;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.main-content {
    display: none;
}

.main-content.logged-in {
    display: block;
}

.logo-container img {
    max-width: 100%;
    height: auto;
    transition: transform 0.3s ease;
    background-color: white;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.logo-container img:hover {
    transform: scale(1.05);
}

.header-logo {
    height: 80px;
    transition: all 0.3s ease;
    background-color: white;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-logo {
    height: 24px;
    margin-right: 10px;
    background-color: white;
    border-radius: 4px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Desktop-specific: Show time display in header middle */
@media (min-width: 769px) {
    #headerTimeDisplay {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    /* Hide time display on mobile to save space */
    #headerTimeDisplay {
        display: none !important;
    }
    
    /* User info header responsive styles */
    .user-info-header .container {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .user-info-header .logo-title-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }
    
    .user-info-header .user-info {
        align-items: center;
        text-align: center;
    }
    
    .user-info-header .user-info + div {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .user-info-header button,
    .user-info-header .admin-link-button {
        width: 100%;
        min-height: 44px; /* Better touch target */
        justify-content: center;
    }
    
    /* Legacy header styles kept for compatibility */
    .header {
        flex-direction: column;
        gap: 15px;
        align-items: center;
        text-align: center;
    }
    
    .header-left {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
    
    .logo-title-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .devices-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-logo {
        height: 60px;
        padding: 6px;
    }
    
    .logo-container img {
        max-width: 150px;
        padding: 8px;
    }
    
    .user-logo {
        height: 20px;
        padding: 2px;
    }
}

