/* ============ GLOBAL STYLES ============ */
* {
    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;
}

/* ============ NAVBAR STYLES ============ */
.navbar {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.nav-brand i {
    margin-right: 10px;
}

.nav-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-item {
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.nav-item:hover {
    background: #f0f0f0;
}

.nav-item.active {
    background: #667eea;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border-radius: 25px;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.logout-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
}

/* ============ CONTAINER & CARDS ============ */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
}

.weight-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.weight-display {
    font-size: 4rem;
    font-weight: bold;
    margin: 1rem 0;
    font-family: monospace;
    text-align: center;
}

.live-badge {
    background: #ff4444;
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-block;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.device-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.online {
    color: #4caf50;
}

.offline {
    color: #f44336;
}

.device-info {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 10px;
    margin: 0.5rem 0;
    font-size: 0.875rem;
    border-left: 3px solid #00b09b;
}

.device-info p {
    margin: 0.25rem 0;
    color: #555;
}

/* ============ BUTTONS ============ */
.btn-group {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-gross {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.btn-tare {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.btn-net {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.btn-save {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.btn-refresh {
    background: linear-gradient(135deg, #ff9800, #f44336);
}

/* ============ TABLES ============ */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

th {
    background: #667eea;
    color: white;
    padding: 1rem;
    text-align: left;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    border-radius: 15px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ============ STATUS BADGES ============ */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    color: white;
    font-size: 0.875rem;
    display: inline-block;
}

.status-admin { background: #9c27b0; }
.status-operator { background: #2196f3; }
.status-viewer { background: #ff9800; }
.status-active { background: #4caf50; }
.status-inactive { background: #f44336; }
.status-online { background: #4caf50; }
.status-offline { background: #f44336; }

/* ============ CURRENT WEIGHT INFO ============ */
.current-weight-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    border: 2px dashed #667eea;
}

.current-weight-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* ============ LOGIN PAGE ============ */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    color: #667eea;
    margin-bottom: 2rem;
    text-align: center;
}

.login-box input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.login-box button {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.login-box .error {
    color: #f44336;
    margin-top: 1rem;
    text-align: center;
}

/* ============ DEVICE LIST ============ */
.device-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.device-item {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    border-left: 4px solid #4caf50;
}

.device-item:hover {
    transform: translateY(-2px);
}

.last-update {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
    text-align: center;
}

.weight-history {
    max-height: 300px;
    overflow-y: auto;
}

.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.875rem;
    color: white;
}

.edit-btn { background: #2196f3; }
.delete-btn { background: #f44336; }
.permission-btn { background: #9c27b0; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    .dashboard {
        grid-template-columns: 1fr;
    }
    .btn-group {
        flex-direction: column;
    }
    .btn-group .btn {
        margin-bottom: 10px;
    }
    .nav-menu {
        justify-content: center;
    }
}