/* Global Styles */
:root {
    --primary-color: #0066cc;
    --secondary-color: #00a651;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark: #212529;
    --light: #f8f9fa;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    max-height: 900px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.app-title {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chip-icon {
    font-size: 28px;
}

.device-info {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 14px;
}

.device-status {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
}

.device-status.connected {
    background: rgba(76, 175, 80, 0.3);
}

.device-status.disconnected {
    background: rgba(244, 67, 54, 0.3);
}

.connect-button {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.connect-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.connect-button.connected {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Navigation */
.nav-tabs {
    background: var(--light);
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.nav-tab {
    background: none;
    border: none;
    padding: 15px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--primary-color);
    background: rgba(0,102,204,0.05);
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #fafbfc;
}

.page-content {
    display: none;
}

.page-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--dark);
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.status-label {
    color: #666;
    font-size: 13px;
}

.status-value {
    font-weight: 500;
    font-size: 13px;
}

/* Port Grid */
.port-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.port-status {
    background: var(--light);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s;
}

.port-status.up {
    border-color: var(--secondary-color);
    background: rgba(0, 166, 81, 0.05);
}

.port-status.down {
    border-color: var(--danger-color);
    background: rgba(220, 53, 69, 0.05);
}

.port-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
}

.port-state {
    font-size: 11px;
    color: #666;
}

.port-speed {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,102,204,0.3);
}

.action-btn:active {
    transform: translateY(0);
}

/* Statistics Chart */
.stats-container {
    padding: 10px;
    background: var(--light);
    border-radius: 8px;
}

#stats-chart {
    width: 100%;
    height: auto;
}

/* Footer */
.app-footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
}

/* Modal */
.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;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}

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

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

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

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 2000;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: var(--secondary-color);
}

.notification.error {
    background: var(--danger-color);
}

.notification.info {
    background: var(--info-color);
}

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

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.table th {
    background: var(--light);
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: var(--light);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: none;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .app-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-tabs {
        padding: 0 10px;
    }
    
    .main-content {
        padding: 20px;
    }
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Code Editor */
.code-editor {
    font-family: 'Consolas', 'Monaco', monospace;
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
}

.code-editor pre {
    margin: 0;
}
