:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4cc9f0;
    --text-color: #2b2d42;
    --bg-color: #f8f9fa;
    --card-color: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
}

[data-theme="dark"] {
    --primary-color: #4cc9f0;
    --secondary-color: #4361ee;
    --accent-color: #3f37c9;
    --text-color: #f8f9fa;
    --bg-color: #121212;
    --card-color: #1e1e1e;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    color: var(--primary-color);
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

@media (min-width: 768px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
}

.card {
    background-color: var(--card-color);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

.speed-test-card {
    grid-column: 1 / -1;
}

.test-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-box {
    text-align: center;
    padding: 20px;
    border-radius: var(--border-radius);
    background-color: rgba(67, 97, 238, 0.1);
    border: 1px solid rgba(67, 97, 238, 0.2);
}

.result-box h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.result-unit {
    font-size: 1rem;
    color: var(--text-color);
    opacity: 0.7;
}

.progress-container {
    margin: 30px 0;
}

.progress-bar {
    height: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    width: 0;
    transition: width 0.5s ease;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
}

.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn i {
    font-size: 1.2rem;
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

.history-card h2, .speed-test-card h2, .info-card h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    position: relative;
    padding-bottom: 10px;
}

.history-card h2::after, .speed-test-card h2::after, .info-card h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 3px;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    font-weight: 600;
}

.history-speed {
    display: flex;
    gap: 15px;
}

.speed-value {
    font-weight: 600;
    color: var(--primary-color);
}

.chart-container {
    height: 200px;
    margin-top: 20px;
    position: relative;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    padding: 15px;
    background-color: rgba(67, 97, 238, 0.1);
    border-radius: var(--border-radius);
}

.info-item h3 {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.info-item p {
    font-size: 1.1rem;
    font-weight: 600;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 10px;
    border-radius: var(--border-radius);
    background-color: rgba(76, 201, 240, 0.1);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #4ade80;
}

.status-indicator.offline {
    background-color: #f87171;
}

.tooltip {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--card-color);
    color: var(--text-color);
    text-align: center;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    font-weight: normal;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Animation for the test in progress */
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.testing {
    animation: pulse 1.5s infinite;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .test-results {
        grid-template-columns: 1fr;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}