/* Professional Bluetooth LE Throughput Tester Styles */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-secondary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Dark mode variables */
[data-theme="dark"] {
    --background: #0f172a;
    --surface: #1e293b;
    --surface-secondary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #475569;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.header-text {
    text-align: left;
    flex: 1;
}

.header-controls {
    display: flex;
    align-items: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Lesson Link Styles */
.lesson-link {
    margin-top: 16px;
}

.lesson-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.lesson-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.lesson-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    text-decoration: none;
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.lesson-btn:hover::before {
    left: 100%;
}

.lesson-btn:active {
    transform: translateY(-1px);
}

.lesson-icon {
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.lesson-text {
    font-weight: 500;
    letter-spacing: 0.025em;
}

.lesson-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    margin-left: 4px;
}

.lesson-btn:hover .lesson-arrow {
    transform: translateX(4px);
}

/* Dark mode adjustments for lesson button */
[data-theme="dark"] .lesson-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .lesson-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
}

main {
    display: grid;
    gap: 30px;
}

.control-panel {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

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

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

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-icon {
    font-size: 1.2rem;
}

.status-section {
    display: grid;
    gap: 20px;
}

.status-card {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.status-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.status-indicator {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-indicator.connected {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator.disconnected {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-indicator.connecting {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.device-info {
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.data-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.throughput-display {
    background: var(--surface);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    text-align: center;
}

.throughput-display h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.throughput-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
}

.throughput-unit {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.packets-per-sec {
    margin-bottom: 24px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.packets-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--success-color);
    font-family: 'Courier New', monospace;
    margin-right: 8px;
}

.packets-unit {
    font-size: 1rem;
    color: var(--success-color);
    font-weight: 500;
}

.throughput-stats {
    display: grid;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.data-display {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.data-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-secondary);
}

.data-section-header h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.data-format-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary-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);
}

.format-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.data-container {
    height: 300px;
    overflow-y: auto;
}

.data-output {
    padding: 16px 24px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
}

.data-packet {
    padding: 8px 12px;
    margin: 4px 0;
    background: var(--surface-secondary);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

.packet-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.packet-data {
    color: var(--text-secondary);
    word-break: break-all;
}

.graph-section {
    background: var(--surface);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.graph-header h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.graph-controls {
    display: flex;
    gap: 8px;
}

.graph-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#throughputCanvas {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: linear-gradient(to bottom, var(--surface) 0%, var(--surface-secondary) 100%);
    min-height: 200px;
}

.graph-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    pointer-events: none;
    border-radius: 8px;
}

.y-axis-labels {
    position: absolute;
    left: -15px;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding: 8px 0;
}

.y-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--surface);
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

.x-axis-labels {
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.x-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.y-axis-label {
    position: absolute;
    top: 50%;
    left: -60px;
    transform: rotate(-90deg);
    transform-origin: center;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.x-axis-label {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 600;
}

.graph-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.log-section {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.log-section h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.log-container {
    height: 200px;
    overflow-y: auto;
    background: var(--surface-secondary);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.log-entry {
    margin-bottom: 8px;
    padding: 4px 0;
}

.log-timestamp {
    color: var(--text-secondary);
    margin-right: 12px;
}

.log-level-info {
    color: var(--primary-color);
}

.log-level-success {
    color: var(--success-color);
}

.log-level-error {
    color: var(--error-color);
}

.log-level-warning {
    color: var(--warning-color);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: var(--surface);
    margin: 15% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 15px;
    cursor: pointer;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--error-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .lesson-btn {
        font-size: 0.8rem;
        padding: 8px 12px;
        gap: 6px;
    }
    
    .lesson-text {
        display: block;
    }
    
    .data-section {
        grid-template-columns: 1fr;
    }
    
    .throughput-value {
        font-size: 3rem;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: center;
    }
    
    .graph-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .graph-controls {
        align-self: stretch;
        justify-content: center;
    }
    
    #throughputCanvas {
        height: 200px;
        min-height: 150px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Animation for throughput value changes */
.throughput-value {
    transition: color 0.3s ease;
}

.throughput-value.updating {
    color: var(--success-color);
}

/* Dark Mode Toggle Styles */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.theme-toggle input[type="checkbox"] {
    display: none;
}

.theme-slider {
    position: relative;
    width: 50px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.theme-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 3px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle input[type="checkbox"]:checked + .theme-slider {
    background-color: rgba(255, 255, 255, 0.4);
}

.theme-toggle input[type="checkbox"]:checked + .theme-slider::before {
    transform: translateX(25px);
}

.theme-label {
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover .theme-slider {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Smooth transitions for theme changes */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Connection Details Styling */
.connection-details {
    margin-top: 16px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.connection-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-label {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 120px;
}

.detail-value {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--primary-color);
    text-align: right;
}

/* Responsive connection details */
@media (max-width: 768px) {
    .connection-detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .detail-value {
        text-align: left;
        width: 100%;
    }
}

/* Responsive adjustments for header */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .header-text {
        text-align: center;
    }
}
