/* ============================================
   文件名: web\webview\admin.css
   智香App - 智能气体控制系统
   版本: v2.0
   版权所有 (c) 2024-2026 北京智达惠通科技有限公司 保留所有权利
   
   本软件为北京智达惠通科技有限公司的专有信息。
   未经书面授权，不得复制、传播或使用。
   ============================================ */

﻿/* ============================================
   Theme Variables (loaded from API)
   ============================================ */
:root {
    --primary-color: #e94560;
    --secondary-color: #ff6b6b;
    --header-gradient-start: #1a1a2e;
    --header-gradient-end: #16213e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    padding: 20px;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Screens */
.screen {
    display: none;
}

    .screen.active {
        display: block;
    }

/* Login Card */
.login-card {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
}

.logo {
    font-size: 3rem;
    margin-bottom: 15px;
}

.login-card h2 {
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
}

/* Admin Header */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    flex-wrap: wrap;
    gap: 10px;
}

    .admin-header h1 {
        font-size: 1.5rem;
    }

.btn-back {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    padding: 8px 16px;
    border-radius: 6px;
}

    .btn-back:hover {
        background: rgba(233, 69, 96, 0.1);
    }

.btn-logout {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    padding: 8px 16px;
    border-radius: 6px;
}

    .btn-logout:hover {
        background: rgba(233, 69, 96, 0.1);
    }

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.stat-number {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    color: #666;
    margin-top: 5px;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 20px;
    background: white;
    padding: 10px;
    border-radius: 12px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.2s;
}

    .tab-btn.active {
        background: var(--primary-color);
        color: white;
    }

    .tab-btn:hover:not(.active) {
        background: #f0f0f0;
    }

/* Tab Content */
.tab-content {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 12px;
}

    .tab-content.active {
        display: block;
    }

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

    .tab-header h3 {
        font-size: 1.2rem;
    }

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
}

tr:hover {
    background: #fafafa;
}

/* Buttons */
.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-small {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

    .btn-primary:hover {
        opacity: 0.85;
    }

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

    .btn-secondary:hover {
        background: #d0d0d0;
    }

.btn-danger {
    background: #dc3545;
    color: white;
}

    .btn-danger:hover {
        background: #c82333;
    }

.btn-small {
    background: var(--primary-color);
    color: white;
    font-size: 0.8rem;
    padding: 5px 12px;
}

    .btn-small:hover {
        opacity: 0.85;
    }

/* Input Groups */
.input-group {
    margin-bottom: 15px;
}

    .input-group label {
        display: block;
        margin-bottom: 5px;
        font-weight: 500;
    }

    .input-group input,
    .input-group select,
    .input-group textarea {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid #ddd;
        border-radius: 6px;
        font-size: 0.9rem;
        font-family: inherit;
    }

        .input-group input:focus,
        .input-group select:focus,
        .input-group textarea:focus {
            outline: none;
            border-color: var(--primary-color);
        }

    .input-group textarea {
        font-family: monospace;
        resize: vertical;
    }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

    .modal.hidden {
        display: none;
    }

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

    .modal-header h3 {
        font-size: 1.2rem;
    }

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #eee;
}

    .modal-footer .btn {
        flex: 1;
    }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

    .modal-close:hover {
        color: #333;
    }

/* Error Message */
.error-message {
    background: #ffe0e0;
    color: var(--primary-color);
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
}

.hidden {
    display: none;
}

/* Buttons Grid (Admin) */
.buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.button-card {
    background: #f8f9fa;
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #eee;
}

    .button-card:hover {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

/* Ports Editor */
.port-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

.port-label {
    width: 50px;
    font-weight: bold;
}

.port-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
}

    .port-input:focus {
        outline: none;
        border-color: var(--primary-color);
    }

/* Content Editor */
.content-editor {
    max-width: 800px;
}

    .content-editor select {
        margin-bottom: 20px;
        padding: 8px 12px;
        border: 1px solid #ddd;
        border-radius: 6px;
        width: 100%;
        max-width: 300px;
    }

/* Settings Form */
.settings-form {
    max-width: 500px;
}

/* Color Input */
.color-input {
    width: 60px;
    height: 40px;
    padding: 2px;
    cursor: pointer;
}

/* Admin Badge */
.admin-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    display: inline-block;
}

/* Theme Preview */
.theme-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.theme-color-box {
    width: 30px;
    height: 30px;
    border-radius: 4px;
}

.theme-active-badge {
    background: #06d6a0;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        text-align: center;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    th, td {
        padding: 8px;
        font-size: 0.8rem;
    }

    .buttons-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .modal-content {
        width: 95%;
    }

    .admin-header h1 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .button-card {
        padding: 8px;
        font-size: 0.75rem;
    }
}

/* ============================================
   Monitor Status
   ============================================ */
.monitor-status {
    background: #1a1a2e;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-on {
    color: #06d6a0;
    font-weight: bold;
}

.status-off {
    color: #e94560;
    font-weight: bold;
}

.last-poll {
    color: #888;
    font-size: 0.8rem;
}

/* ============================================
   3D Simulator for Admin
   ============================================ */
.simulator-container {
    background: linear-gradient(145deg, #1a1a2e 0%, #0f0f1a 100%);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.simulator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.simulator-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sim-icon {
    font-size: 1.2rem;
}

.simulator-ports {
    margin: 20px 0;
}

.ports-grid {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.sim-port {
    text-align: center;
    width: 80px;
}

.port-3d {
    position: relative;
    width: 70px;
    height: 90px;
    margin: 0 auto;
}

.port-top {
    width: 100%;
    height: 15px;
    background: linear-gradient(145deg, #3a3a5e, #2a2a3e);
    border-radius: 10px 10px 0 0;
}

.port-body {
    width: 100%;
    height: 55px;
    background: linear-gradient(145deg, #2d2d44, #1e1e2e);
    border-radius: 0 0 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

.port-led {
    width: 35px;
    height: 35px;
    background: #2a2a3e;
    border-radius: 50%;
    margin-bottom: 5px;
    transition: all 0.05s ease;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

    .port-led.light-on {
        background: #ff3366;
        box-shadow: 0 0 20px #ff3366, 0 0 40px rgba(255,51,102,0.5);
    }

    .port-led.vibration {
        background: transparent;
        box-shadow: none;
        position: relative;
    }

        .port-led.vibration::before {
            content: "~~~";
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: #06d6a0;
            font-size: 1.2rem;
            animation: vibrate 0.2s infinite;
        }

    .port-led.sound {
        background: transparent;
        box-shadow: none;
        position: relative;
    }

        .port-led.sound::before {
            content: "◄►";
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: #ffd166;
            font-size: 1rem;
            animation: soundWave 0.3s ease-out;
        }

@keyframes vibrate {
    0% {
        transform: translate(-50%, -50%) translateX(0);
    }

    25% {
        transform: translate(-50%, -50%) translateX(-3px);
    }

    75% {
        transform: translate(-50%, -50%) translateX(3px);
    }

    100% {
        transform: translate(-50%, -50%) translateX(0);
    }
}

@keyframes soundWave {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2);
    }
}

.port-label {
    color: #aaa;
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.port-bottom {
    width: 100%;
    height: 20px;
    background: linear-gradient(145deg, #2a2a3e, #1a1a2e);
    border-radius: 0 0 5px 5px;
}

.port-status {
    font-size: 0.6rem;
    margin-top: 8px;
    color: #888;
}

.simulator-info {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 15px;
    margin: 20px 0;
}

.current-command, .execution-status {
    display: flex;
    gap: 10px;
    padding: 5px 0;
}

.info-label {
    color: #888;
    font-size: 0.8rem;
    width: 80px;
}

.command-value {
    color: #ffd166;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
    flex: 1;
}

.countdown {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes glowPulse {
    0% {
        text-shadow: 0 0 0 #ffd166;
    }

    50% {
        text-shadow: 0 0 10px #ffd166;
    }

    100% {
        text-shadow: 0 0 0 #ffd166;
    }
}

/* External logs table */
#externalLogsList tr {
    cursor: pointer;
    transition: background 0.2s;
}

    #externalLogsList tr:hover {
        background: #f0f0f0;
    }

    #externalLogsList tr.selected {
        background: #e8f5e9;
        border-left: 3px solid #06d6a0;
    }
.home-link-top {
    text-align: right;
    margin-bottom: 10px;
}

    .home-link-top a {
        color: var(--primary-color, #e94560);
        text-decoration: none;
        font-size: 0.85rem;
    }

        .home-link-top a:hover {
            text-decoration: underline;
        }