/* ================================================
   SPEEDTEST - MODERN STYLE
   ================================================ */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #43e97b;
    --warning-color: #fee140;
    --danger-color: #f5576c;
    --info-color: #4facfe;
    --dark: #2d3748;
    --light: #f7fafc;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 25px;
    padding: 40px;
    box-shadow: 0 25px 80px var(--shadow-lg);
    animation: fadeIn 0.5s ease-in;
}

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

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    color: var(--primary-color);
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px var(--shadow);
}

.subtitle {
    color: #666;
    font-size: 1.2em;
    font-weight: 300;
}

/* Location Information Section */
.location-info, .server-location-info {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 40px;
    box-shadow: 0 10px 40px var(--shadow);
    animation: slideDown 0.6s ease-out;
}

.server-location-info {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

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

.location-info h3, .server-location-info h3 {
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

.location-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.location-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.location-item:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);
}

.location-item strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    opacity: 0.9;
}

.location-item span {
    font-size: 1.1em;
    font-weight: 500;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Speed Display Section */
.speed-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.speed-box {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 40px var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.speed-box::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.speed-box:hover::before {
    opacity: 1;
}

.speed-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 50px var(--shadow-lg);
}

.speed-box.ping {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.speed-box.jitter {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.speed-box.download {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.speed-box.upload {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.speed-icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.speed-box h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    opacity: 0.95;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.speed-value {
    font-size: 3.5em;
    font-weight: bold;
    margin: 15px 0;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.speed-value.updating {
    animation: speedPulse 0.5s ease-in-out;
}

@keyframes speedPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.speed-unit {
    font-size: 1.3em;
    opacity: 0.85;
    font-weight: 300;
}

.speed-quality {
    margin-top: 10px;
    font-size: 0.9em;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: inline-block;
}

/* Progress Bar */
.progress-container {
    margin: 30px 0;
    display: none;
}

.progress-container.active {
    display: block;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px var(--shadow);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-label {
    text-align: center;
    margin-top: 10px;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1em;
}

/* Status Text */
.status-text {
    text-align: center;
    color: #666;
    font-size: 1.2em;
    margin: 20px 0;
    min-height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-icon {
    margin-right: 10px;
    font-size: 1.5em;
}

/* Control Buttons */
.controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 40px 0;
    flex-wrap: wrap;
}

.start-button,
.history-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.3em;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.start-button:hover,
.history-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.start-button:active,
.history-button:active {
    transform: translateY(-1px);
}

.start-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.history-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.button-icon {
    font-size: 1.2em;
}

/* History Section */
.history-section {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 20px;
    margin: 40px 0;
    animation: fadeIn 0.5s ease-in;
}

.history-section h3 {
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.5em;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px var(--shadow);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 6px 20px var(--shadow);
}

.history-metric {
    text-align: center;
}

.history-metric strong {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.history-metric span {
    color: var(--primary-color);
    font-size: 1.3em;
    font-weight: 600;
}

.history-date {
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    font-size: 0.85em;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.no-history {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}

.clear-history {
    display: block;
    margin: 20px auto 0;
    padding: 12px 30px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.clear-history:hover {
    background: #d43f5a;
    transform: scale(1.05);
}

/* Server Information */
.server-info {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    margin-top: 40px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.server-detail {
    text-align: center;
    color: #666;
    font-size: 1em;
}

.server-detail strong {
    color: var(--dark);
    margin-right: 8px;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    color: #999;
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 25px;
    }

    .header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 1em;
    }

    .speed-display {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .speed-value {
        font-size: 2.5em;
    }

    .speed-icon {
        font-size: 2em;
    }

    .controls {
        flex-direction: column;
    }

    .start-button,
    .history-button {
        width: 100%;
        justify-content: center;
        padding: 15px 30px;
        font-size: 1.1em;
    }

    .location-details {
        grid-template-columns: 1fr;
    }

    .server-info {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .speed-display {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8em;
    }
}

/* Custom Scrollbar */
.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.testing {
    animation: pulse 2s ease-in-out infinite;
}
