:root {
    --bg-dark: #050505; /* Black Background */
    --card-bg-online: rgba(16, 185, 129, 0.08); /* Faint green panel */
    --card-border-online: rgba(16, 185, 129, 0.5); /* Green border */
    
    --card-bg-offline: rgba(239, 68, 68, 0.12); /* Faint red panel */
    --card-border-offline: rgba(239, 68, 68, 0.6); /* Red border */
    
    --text-primary: #ececec;
    --text-secondary: #a1a1aa;
    
    --accent-orange: #f2921d; /* Orange for headers/brands */
    --accent-hover: #e9a13e;
    
    /* Status Colors */
    --status-online: #10b981;
    --status-offline: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

h1, h2, h3, .logo h1 {
    font-weight: 700;
}

/* Base Scaling for Large Screens (TVs) */
@media (min-width: 2500px) {
    :root {
        font-size: 18px; /* Slightly less aggressive for high-res monitors */
    }
}

@media (min-width: 3800px) {
    :root {
        font-size: 22px; /* 4K TV territory */
    }
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

.hide { display: none !important; }
.active { display: flex !important; }

/* Login Container */
#login-container {
    padding: 3rem;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 0.5s ease-out;
    background: rgba(40, 40, 40, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    max-height: 5rem;
    width: auto;
    object-fit: contain;
    margin-bottom: 1.5rem;
}

.login-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-orange);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    background: #121212;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 2px rgba(242, 146, 29, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 0.9rem;
    border-radius: 8px;
    background: var(--accent-orange);
    color: #111;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.error-msg {
    color: var(--status-offline);
    font-size: 0.85rem;
    margin-top: 1rem;
    text-align: center;
}

/* Dashboard Layout */
.dashboard {
    width: 100%;
    height: 100vh;
    flex-direction: column;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2rem;
    border-top: none;
    border-left: none;
    border-right: none;
    border-radius: 0 0 16px 16px;
    margin-bottom: 2rem;
    background: #111111;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.company-logo {
    max-height: 2.5rem;
    width: auto;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.8rem;
    color: var(--accent-orange);
}

.stats {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.stat-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-weight: 600;
}

.stat-item.online-stat { color: var(--status-online); }
.stat-item.offline-stat { color: var(--status-offline); }

.stat-item.pagination-stat {
    background: rgba(242, 146, 29, 0.15);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
    font-size: 0.95rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--accent-orange);
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--status-offline);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
    margin-left: 1rem;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 2rem;
    padding: 0 2rem 2rem 2rem;
    overflow-y: auto;
    width: 100%;
    align-content: start;
}

/* Device Cards */
.device-card {
    padding: 2rem 2.5rem;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
    min-height: 220px;
    justify-content: center;
}

.device-card.online {
    background: var(--card-bg-online);
    border: 1px solid var(--card-border-online);
}

.device-card.offline {
    background: var(--card-bg-offline);
    border: 1px solid var(--card-border-offline);
}

.device-card:hover {
    transform: translateY(-4px);
}

.device-card.online:hover {
    box-shadow: 0 12px 30px 0 rgba(16, 185, 129, 0.2);
}

.device-card.offline:hover {
    box-shadow: 0 12px 30px 0 rgba(239, 68, 68, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.device-info {
    min-width: 0;
    flex: 1;
}

.device-info h3 {
    font-size: clamp(1.8rem, 2.5vw, 2.2rem);
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.domain-label {
    font-size: clamp(1.1rem, 1.5vw, 1.3rem);
    font-weight: 600;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-body {
    display: flex;
    flex-direction: column;
    margin-top: 0.2rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 500;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.data-row .label {
    color: var(--text-secondary);
}

.data-row .value {
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.device-status {
    padding: 0.6rem 1.5rem;
    border-radius: 9999px;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.device-status.online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--status-online);
}

.device-status.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--status-offline);
}

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

.pulse-ring {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    position: relative;
}

.pulse-ring.green {
    background-color: var(--status-online);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite;
}

.pulse-ring.red {
    background-color: var(--status-offline);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 2rem 3rem;
    border-radius: 16px;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 100;
    color: var(--text-primary);
    background: rgba(10,10,10,0.8);
    border: 1px solid rgba(255,255,255,0.1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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