/* style.css - Shared styles for all pages */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Container for auth pages (login, register) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 10px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.auth-card h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
}

.auth-card h2 {
    text-align: center;
    font-size: 16px;
    font-weight: normal;
    color: #666;
    margin-bottom: 30px;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: #1a202c;
    color: white;
    position: fixed;
    height: 100vh;
}

.logo {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 1px solid #2d3748;
}

.logo h2 {
    color: #667eea;
    font-size: 24px;
}

.logo p {
    font-size: 12px;
    color: #a0aec0;
    margin-top: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 24px;
    color: #cbd5e0;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-item:hover {
    background: #2d3748;
    color: white;
}

.nav-item.active {
    background: #667eea;
    color: white;
}

.nav-item span {
    margin-right: 12px;
    font-size: 20px;
}

.user-section {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 20px;
    border-top: 1px solid #2d3748;
}

.user-section p {
    margin-bottom: 10px;
    color: #cbd5e0;
}

.user-section strong {
    color: white;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-logout:hover {
    background: #c53030;
}

.main-content {
    margin-left: 280px;
    padding: 30px;
    width: 100%;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.section-title {
    font-weight: 600;
    color: #667eea;
    margin: 20px 0 15px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #667eea;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.checkbox-group input {
    width: 20px;
    height: 20px;
}

.checkbox-group label {
    margin-bottom: 0;
    flex: 1;
    cursor: pointer;
}

.checkbox-group .hint {
    font-size: 12px;
    color: #999;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 20px;
}

.btn-primary:hover {
    background: #5a67d8;
}

.btn-secondary {
    background: #48bb78;
}

.btn-secondary:hover {
    background: #38a169;
}

/* Message Styles */
.message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 5px;
    display: none;
}

.message.success {
    background: #c6f6d5;
    color: #22543d;
    display: block;
}

.message.error {
    background: #fed7d7;
    color: #742a2a;
    display: block;
}

.message.info {
    background: #bee3f8;
    color: #2c5282;
    display: block;
}

/* Table Styles */
.table-container {
    background: white;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
}

th:hover {
    background: #edf2f7;
}

tr:hover {
    background: #f7fafc;
}

.sort-icon {
    margin-left: 5px;
    font-size: 12px;
}

/* Device Card Styles (for dashboard) */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.device-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.device-card h3 {
    color: #2d3748;
    margin-bottom: 5px;
}

.device-location {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

.level-row {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    align-items: center;
}

.level-label {
    font-weight: 500;
    width: 60px;
}

.level-bar {
    flex: 1;
    margin: 0 10px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.level-fill {
    height: 24px;
    background: #48bb78;
    border-radius: 10px;
    transition: width 0.3s;
}

.level-fill.warning { background: #ecc94b; }
.level-fill.critical { background: #e53e3e; }

.level-value {
    font-weight: 500;
    min-width: 45px;
    text-align: right;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #c6f6d5;
    color: #22543d;
}

.status-inactive {
    background: #fed7d7;
    color: #742a2a;
}

.last-update {
    font-size: 12px;
    color: #999;
    margin-top: 15px;
    text-align: right;
}

.api-key-display {
    background: #2d3748;
    color: #48bb78;
    font-family: monospace;
    padding: 10px;
    border-radius: 5px;
    word-break: break-all;
    font-size: 12px;
    margin: 10px 0;
}

.copy-btn {
    background: #48bb78;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
}

/* Controls */
.sort-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.sort-controls select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }
    .sidebar .logo h2, .sidebar .logo p, .sidebar .user-section p {
        display: none;
    }
    .main-content {
        margin-left: 80px;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}