* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #2ecc71;
    --success-dark: #27ae60;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --warning: #f39c12;
    --warning-dark: #d35400;
    --admin: #9b59b6;
    --admin-dark: #8e44ad;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --dark-gray: #7f8c8d;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    min-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.header {
    background: var(--dark);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
}

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

.user-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}

.user-avatar.admin {
    background: var(--admin);
}

.user-name {
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e0e0e0;
    color: #555;
}

.user-role.admin {
    background: var(--admin);
    color: white;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.auth-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background: #3498db;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.auth-btn:hover {
    background: #2980b9;
}

.auth-btn.logout {
    background: #e74c3c;
}

.auth-btn.logout:hover {
    background: #c0392b;
}

.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.auth-modal.active {
    opacity: 1;
    visibility: visible;
}

.auth-form {
    background: white;
    border-radius: 10px;
    padding: 30px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #777;
    cursor: pointer;
    transition: all 0.3s;
}

.close-modal:hover {
    color: var(--danger);
}

.auth-header {
    text-align: center;
    margin-bottom: 20px;
}

.auth-header h2 {
    color: var(--dark);
    margin-bottom: 10px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.auth-tab.active {
    border-bottom: 3px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s;
}

.form-group input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.5;
}

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

.form-btn.cancel {
    background: var(--gray);
}

.form-btn.cancel:hover {
    background: var(--dark-gray);
}

.form-error {
    color: var(--danger);
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

.form-error.active {
    display: block;
}

/* 管理员面板样式 */
.admin-panel {
    background: #f9f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #e0e0e0;
}

.admin-panel h4 {
    color: var(--admin);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-panel h4 i {
    font-size: 20px;
}

.user-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    background: white;
}

.user-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item:last-child {
    border-bottom: none;
}

.user-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-item-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.user-item-avatar.admin {
    background: var(--admin);
}

.user-item-name {
    font-weight: 600;
}

.user-item-devices {
    font-size: 14px;
    color: var(--dark-gray);
}

.admin-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.admin-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background: var(--admin);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.admin-btn:hover {
  background: var(--admin-dark);
}

/* 状态栏样式 */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
    font-weight: 600;
    flex-wrap: wrap;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e74c3c;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #2ecc71;
    animation: none;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.device-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

.status-online {
    background: #d4edda;
    color: #155724;
}

.status-offline {
    background: #f8d7da;
    color: #721c24;
}

.device-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 5px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
}

.stat-online {
    color: #27ae60;
}

.stat-offline {
    color: #e74c3c;
}

.stat-total {
    color: #3498db;
}

.stat-count {
    font-weight: bold;
    font-size: 16px;
}

.control-panel {
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 30px;
}

.control-group {
    margin-bottom: 25px;
    padding: 20px;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    background: #f8f9fa;
    min-height: 200px;
}

.control-group h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-card {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    flex: 1;
    margin: 0 10px;
}

.stat-card.online {
    background: #e8f6ef;
    border-left: 4px solid #2ecc71;
}

.stat-card.offline {
    background: #fdedec;
    border-left: 4px solid #e74c3c;
}

.stat-card.total {
    background: #eaf2f8;
    border-left: 4px solid #3498db;
}

.stat-number {
    font-size: 28px;
    font-weight: bold;
    margin: 10px 0;
}

.stat-label {
    font-size: 14px;
    color: #7f8c8d;
}

.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background: #3498db;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 600;
    min-width: 120px;
    flex: 1;
    min-width: 0;
}

button:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.off {
    background: #e74c3c;
}

button.off:hover:not(:disabled) {
    background: #c0392b;
}

button.on {
    background: #2ecc71;
}

button.on:hover:not(:disabled) {
    background: #27ae60;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.slider {
    flex: 1;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    min-width: 200px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
}

.brightness-value {
    min-width: 60px;
    text-align: center;
    font-weight: bold;
    color: #3498db;
    font-size: 18px;
}

.flash-control {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 15px 0;
    flex-wrap: wrap;
}

input[type="number"], input[type="text"] {
    padding: 10px;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    width: 120px;
    min-width: 100px;
    font-size: 16px;
}

input[type="number"]:focus, input[type="text"]:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.log-container {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    min-height: 150px;
}

.log-entry {
    padding: 8px 0;
    border-bottom: 1px solid #333;
}

.log-time {
    color: #6c757d;
    margin-right: 10px;
}

.log-info {
    color: #28a745;
}

.log-error {
    color: #dc3545;
}

.log-warning {
    color: #ffc107;
}

.log-success {
    color: #17a2b8;
}

.device-management {
    grid-column: 1 / -1;
}

.device-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #e9f7fe;
    border-radius: 8px;
}

.device-form input {
    width: 100%;
}

.device-list {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    min-height: 150px;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    transition: all 0.3s;
}

.device-item:last-child {
    border-bottom: none;
}

.device-item.removing {
    background-color: #ffebee;
    transform: translateX(-100%);
    opacity: 0;
}

.device-info {
    flex: 1;
}

.device-imei {
    font-weight: bold;
    color: #2c3e50;
}

.device-sim {
    color: #7f8c8d;
    font-size: 14px;
}

.device-user {
    font-size: 12px;
    color: var(--admin);
    font-weight: bold;
    margin-top: 5px;
}


.device-firmware {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.device-last-seen {
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}

.device-actions {
    display: flex;
    gap: 10px;
}



.device-select {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #bdc3c7;
    width: 100%;
    font-size: 16px;
}

.no-devices {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    font-style: italic;
}

.device-search {
    margin-bottom: 15px;
    position: relative;
}

.device-search input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s;
}

.device-search input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.device-search::after {
    content: "🔍";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c8d;
    pointer-events: none;
}

.search-results-info {
    margin-top: 5px;
    font-size: 14px;
    color: #7f8c8d;
    text-align: right;
}

.highlight {
    background-color: #fffacd;
    font-weight: bold;
    padding: 0 2px;
    border-radius: 3px;
}

.sort-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.sort-btn {
    padding: 8px 15px;
    background: #e0e0e0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.sort-btn:hover {
    background: #d0d0d0;
}

.sort-btn.active {
    background: #3498db;
    color: white;
}

.sort-label {
    font-weight: bold;
    color: #555;
}

/* 添加重置密码模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 10px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    /* 添加居中定位 */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #777;
}

.close-modal:hover {
    color: #e74c3c;
}

/* 用户操作按钮样式 */
.user-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.reset-password-btn {
    background: #f39c12;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.reset-password-btn:hover {
    background: #e67e22;
}

.reset-password-btn i {
    font-size: 14px;
}

/* 添加设备状态面板样式 */
#deviceStatusPanel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.status-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.status-label {
    font-weight: 600;
    color: #6c757d;
}

#deviceStatus {
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 14px;
}

.status-online {
    background: #d4edda;
    color: #155724;
}

.status-offline {
    background: #f8d7da;
    color: #721c24;
}

#deviceBrightness {
    font-weight: bold;
    color: #3498db;
    font-size: 18px;
}

#paneldeviceLastOperation {
    font-weight: bold;
    color: #9b59b6;
}

#panellastOperationTime {
    color: #e67e22;
    font-weight: 600;
}

@media (max-width: 1500px) {
    .container {
        max-width: 95%;
    }
    
    .control-panel {
        grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
        gap: 25px;
    }
}

@media (max-width: 1200px) {
    .control-panel {
        grid-template-columns: 1fr;
    }
    
    .device-management {
        grid-column: 1;
    }
    
    .status-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .device-stats {
        justify-content: flex-start;
        width: 100%;
    }
    
    .button-group {
        justify-content: center;
    }
    
    button {
        min-width: 120px;
        flex: 0 1 auto;
    }
}

@media (max-width: 992px) {
    body {
        padding: 10px;
    }
    
    .container {
        min-width: 100%;
        border-radius: 10px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .control-panel {
        padding: 20px;
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .control-group {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .stats-card {
        flex-direction: column;
    }
    
    .stat-card {
        margin: 5px 0;
    }
    
    .button-group {
        gap: 10px;
    }
    
    button {
        padding: 10px 15px;
        font-size: 13px;
        min-width: 100px;
    }
    
    .slider-container, .flash-control {
        gap: 10px;
    }
    
    input[type="number"], input[type="text"] {
        width: 100px;
        min-width: 90px;
    }
    
    .device-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header {
        padding-top: 60px;
    }
    
    .user-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .control-group h3 {
        font-size: 18px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .slider-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .flash-control {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    input[type="number"], input[type="text"] {
        width: 100%;
    }
    
    .sort-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 576px) {
    .header h1 {
        font-size: 20px;
    }
    
    .status-bar {
        padding: 10px;
    }
    
    .control-panel {
        padding: 15px;
    }
    
    .control-group {
        padding: 12px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .stat-item {
        font-size: 12px;
        padding: 3px 8px;
    }
    
    .stat-count {
        font-size: 14px;
    }
}
