/**
 ******************************************************************************
 * @file    style.css
 * @author  JanPNP Development Team
 * @brief   Main stylesheet for JanPNP web console
 *          Provides comprehensive styling for the entire web application
 *          including theme variables, layout, navigation, forms, tables,
 *          modals, and responsive design for desktop and mobile devices.
 ******************************************************************************
 * @attention
 *
 * Copyright (c) 2026 JanPNP Development Team. All rights reserved.
 *
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 *
 ******************************************************************************
 */

:root {
    --primary-color: #519ABA;
    --primary-dark: #1A8BB0;
    --primary-light: #4292a2;
    --on-primary: #ffffff;
    --bg-color: #f5f7fa;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --focus-ring: rgba(81, 154, 186, 0.15);
    --hover-bg: rgba(31, 70, 72, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --primary-color: #519ABA;
    --primary-dark: #1A8BB0;
    --primary-light: #4292a2;
    --on-primary: #ffffff;
    --bg-color: #111827;
    --sidebar-bg: #1f2937;
    --card-bg: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --info-color: #3b82f6;
    --focus-ring: rgba(81, 154, 186, 0.25);
    --hover-bg: rgba(31, 70, 72, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.35);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100vh;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 28px;
    height: 28px;
}

.nav-menu {
    flex: 1;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}

.nav-item.active {
    background: var(--primary-color);
    color: var(--on-primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.theme-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.theme-btn {
    flex: 1;
    padding: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.theme-btn:hover {
    background: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

.copyright {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: var(--card-bg);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.header-info {
    display: flex;
    gap: 24px;
    align-items: center;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.datetime {
    font-family: monospace;
    font-size: 14px;
    color: var(--text-secondary);
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
}

.content::-webkit-scrollbar {
    width: 6px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.stat-icon {
    font-size: 32px;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.system-status-card,
.recent-order-card,
.current-task-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.system-status-card h3,
.recent-order-card h3,
.current-task-card h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.status-label {
    color: var(--text-secondary);
}

.status-value {
    font-weight: 500;
}

.order-table-container {
    overflow-x: auto;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
}

.order-table th,
.order-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.order-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-color);
}

.progress-bar {
    position: relative;
    width: 100px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
}

.progress-text {
    position: relative;
    display: block;
    text-align: center;
    font-size: 12px;
    line-height: 24px;
    color: var(--text-primary);
    z-index: 1;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-pending {
    background: #f59e0b;
    color: white;
}

.status-running {
    background: var(--info-color);
    color: white;
}

.status-completed {
    background: #10b981;
    color: white;
}

.status-error {
    background: #ef4444;
    color: white;
}

.status-cancelled {
    background: #6b7280;
    color: white;
}

[data-theme="dark"] .status-running {
    background: var(--info-color);
}

[data-theme="dark"] .status-cancelled {
    background: #4b5563;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--text-secondary);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 4px;
    color: var(--text-primary);
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Noto Sans CJK SC', 'Source Han Sans SC', sans-serif !important;
    font-size: 14px;
    font-style: normal !important;
    font-weight: 500;
    font-synthesis: none !important;
    font-variant: normal;
    letter-spacing: 0;
    line-height: 1.45;
    text-decoration: none;
    transition: all 0.2s;
    transform: none;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    -webkit-font-smoothing: antialiased;
}

.order-table .btn-icon {
    font-style: normal !important;
    transform: none !important;
}

.btn-icon:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}

[data-theme="dark"] .btn-icon {
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-icon:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 12px;
    padding-top: 5px;
}

#username-display {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.btn-logout {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

.theme-selector {
    display: flex;
    gap: 8px;
}

.theme-option {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-option.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary) !important;
}

[data-theme="dark"] .theme-option {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .theme-option.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary) !important;
}

[data-theme="light"] .theme-option:not(.active) {
    background: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.theme-option:hover {
    opacity: 0.8 !important;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-primary);
}

.pagination {
    margin-top: 20px;
    text-align: center;
}

.pagination-controls {
    display: inline-flex;
    gap: 8px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 4px;
    cursor: pointer;
}

.page-btn.active {
    background: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loading-text,
.empty-text {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.about-card {
    text-align: center;
}

.about-logo {
    margin-bottom: 24px;
}

.about-logo-icon {
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
}

.about-info {
    margin-bottom: 24px;
    text-align: left;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.about-info p {
    padding: 8px 0;
}

.about-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#static-ip-settings {
    display: none;
}

#color-preview {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.order-primary-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#confirm-message {
    white-space: pre-line;
}

.filters {
    display: flex;
    gap: 12px;
}

.filter-select,
.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
}

.camera-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

[data-theme="dark"] .page-btn {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .page-btn.active {
    background: var(--primary-color);
    color: var(--on-primary);
    border-color: var(--primary-color);
}

[data-theme="dark"] .page-btn:disabled {
    opacity: 0.5;
    background: var(--card-bg);
    color: var(--text-secondary);
}

.order-table td:last-child {
    white-space: nowrap;
}

.order-table .status-badge {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .btn {
        width: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .order-table-container {
        overflow-x: auto;
    }

    .order-table {
        min-width: 100%;
    }

    .order-table .status-badge {
        white-space: nowrap;
        display: inline-block;
        min-width: 60px;
        text-align: center;
    }

    .order-table .progress-bar {
        width: 80px;
        min-width: 80px;
    }

    .order-table td:last-child {
        white-space: nowrap;
    }

    .order-table .btn-icon {
        display: inline-block;
        margin: 0 2px;
        padding: 4px 8px;
        font-size: 11px;
    }

    .page-actions {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .order-primary-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters {
        flex-direction: column;
        gap: 8px;
    }

    .filter-select,
    .search-input {
        width: 100%;
    }

    #create-order-btn {
        width: 100%;
        justify-content: center;
    }

    .order-table th,
    .order-table td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .order-table td {
        vertical-align: middle;
    }

    .order-table .progress-text {
        font-size: 10px;
        line-height: 22px;
    }
}

@media (max-width: 480px) {

    .order-table th,
    .order-table td {
        padding: 8px 6px;
        font-size: 11px;
    }

    .order-table .status-badge {
        font-size: 10px;
        padding: 2px 6px;
        min-width: 50px;
    }

    .order-table .progress-bar {
        width: 70px;
        min-width: 70px;
        height: 22px;
    }

    .order-table .progress-text {
        font-size: 9px;
        line-height: 22px;
    }

    .order-table .btn-icon {
        padding: 3px 6px;
        font-size: 10px;
        margin: 0 1px;
    }

    .order-table td:first-child {
        font-size: 11px;
        font-family: monospace;
    }
}

.bom-table {
    width: 100%;
    border-collapse: collapse;
}

.bom-table .bom-header-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.5fr;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.bom-table .bom-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.5fr;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-primary);
}

.bom-designator {
    font-family: monospace;
    font-size: 12px;
    word-break: break-word;
}

.bom-value {
    color: var(--primary-color);
    word-break: break-word;
}

.bom-package {
    color: var(--text-secondary);
    word-break: break-word;
}

.btn-expand {
    margin-top: 12px;
    width: 100%;
    justify-content: center;
    font-size: 12px;
    padding: 8px;
}

.stat-icon-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

@media (max-width: 768px) {

    .bom-table .bom-header-row,
    .bom-table .bom-row {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        font-size: 11px;
        padding: 8px 10px;
    }

    .bom-designator {
        font-size: 11px;
    }

    .bom-value {
        font-size: 11px;
    }

    .bom-package {
        font-size: 11px;
    }
    
    .stat-icon-img {
        width: 24px;
        height: 24px;
    }
}
/* 全局进度条文字修复：避免进度文字与背景/填充色混在一起看不清 */
.progress-bar {
    position: relative;
    background: rgba(107, 114, 128, 0.24);
}

.progress-fill {
    min-width: 0;
}

.progress-text {
    position: relative;
    z-index: 2;
    color: #ffffff !important;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75), 0 0 2px rgba(0, 0, 0, 0.45);
    mix-blend-mode: normal;
}

[data-theme="dark"] .progress-bar {
    background: rgba(255, 255, 255, 0.16);
}
