/* Custom Styles for Web Console */

/* 🔥 性能优化：减少全局过渡效果，只在需要的元素上应用 */
/* 移除全局 * 选择器，改为具体元素 */
button, a, .tab-button, .device-card {
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* Tab styles */
.tab-button {
    transition: all 0.2s ease;
}

.tab-button.active {
    color: #2563eb;
    border-color: #2563eb;
}

.tab-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Device card styles */
.device-card {
    /* 🔥 性能优化：使用 will-change 提示浏览器优化 */
    will-change: transform, box-shadow;
}

.device-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

/* Status indicator */
.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-online {
    background-color: #10b981; /* 绿色-在线 */
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-offline {
    background-color: #ef4444; /* 红色-离线 */
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.status-streaming {
    background-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Log viewer styles */
.log-viewer {
    background-color: #1f2937;
    color: #e5e7eb;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 1rem;
    border-radius: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.log-entry {
    margin-bottom: 0.25rem;
    word-wrap: break-word;
}

.log-error {
    color: #ef4444;
}

.log-warning {
    color: #f59e0b;
}

.log-info {
    color: #10b981;
}

.log-debug {
    color: #60a5fa;
}

/* Scrollbar styles */
.log-viewer::-webkit-scrollbar {
    width: 8px;
}

.log-viewer::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 4px;
}

.log-viewer::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 4px;
}

.log-viewer::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Button styles */
.btn-primary {
    background-color: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* 🔥 修复：防止按钮点击时变透明 */
.btn-primary:active:not(:disabled),
button:active:not(:disabled) {
    opacity: 1 !important;
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
}

/* 🔥 修复：防止按钮点击时变透明 */
.btn-success:active:not(:disabled),
.btn-danger:active:not(:disabled),
.btn-secondary:active:not(:disabled) {
    opacity: 1 !important;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #4b5563;
}

/* Form styles */
.form-group {
    margin-bottom: 0rem;
}

.form-label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.error {
    border-color: #ef4444;
}

.form-error {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Notification styles */
.notification {
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
    max-width: 400px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-success {
    background-color: #d1fae5;
    border-left: 4px solid #10b981;
    color: #065f46;
}

.notification-error {
    background-color: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.notification-warning {
    background-color: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.notification-info {
    background-color: #dbeafe;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 50;
    animation: scaleIn 0.2s ease-out;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes scaleIn {
    from {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Stats card styles */
.stats-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.stats-number {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

/* Responsive utilities */

/* Mobile devices (< 768px) */
@media (max-width: 767px) {
    /* Vertical stacking */
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Log viewer */
    .log-viewer {
        max-height: 300px;
        font-size: 0.75rem;
        padding: 0.75rem;
    }
    
    /* Notifications */
    .notification {
        min-width: auto;
        max-width: calc(100vw - 2rem);
        font-size: 0.875rem;
    }
    
    /* Touch-friendly buttons */
    button, .btn-primary, .btn-secondary, .btn-success, .btn-danger {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Form inputs */
    .form-input, select, input[type="text"], input[type="number"] {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Device cards */
    .device-card {
        margin-bottom: 1rem;
    }
    
    /* Stats cards */
    .stats-number {
        font-size: 1.5rem;
    }
    
    /* Tables */
    table {
        font-size: 0.75rem;
    }
    
    table th, table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Modal */
    .modal-content {
        max-width: 95vw;
        padding: 1rem;
    }
    
    /* Tab buttons */
    .tab-button {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Filter controls */
    .flex-wrap {
        gap: 0.5rem !important;
    }
}

/* Tablet devices (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Adjust grid columns */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-cols-5 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Font sizes */
    .stats-number {
        font-size: 1.75rem;
    }
    
    /* Tables */
    table {
        font-size: 0.875rem;
    }
}

/* Desktop devices (≥ 1024px) */
@media (min-width: 1024px) {
    /* Optimal spacing */
    .container {
        max-width: 1280px;
        margin: 0 auto;
    }
    
    /* Hover effects */
    .device-card:hover {
        transform: translateY(-4px);
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .log-viewer {
        max-height: 200px;
    }
    
    .modal-content {
        max-height: 80vh;
    }
}

/* Print styles */
@media print {
    .tab-button, button, .btn-primary, .btn-secondary {
        display: none;
    }
    
    .log-viewer {
        max-height: none;
        background-color: white;
        color: black;
    }
    
    .device-card {
        break-inside: avoid;
    }
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Editable label */
.editable-label {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.editable-label:hover {
    background-color: #f3f4f6;
}

.editable-label.editing {
    background-color: white;
    border: 1px solid #3b82f6;
}

/* Volume slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #d1d5db;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

/* 🔥 实时弹幕数据动画效果 */
.new-message-highlight {
    animation: messageFadeIn 0.5s ease-out;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-fade-in {
    animation: messageFadeIn 0.3s ease-out;
}
