/* Speed Test Page Styling - Following Standby Theme Pattern */

/* Speed test specific styles only - all shared variables in themes.css */

/* Reset and base styles to match status page */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 20px;
}

/* Header styling to match status page */
.header {
    display: grid;
    grid-template-columns: var(--logo-size) 1fr var(--logo-size);
    align-items: center;
    margin-bottom: 40px;
    color: var(--text-header);
    gap: 20px;
}

.header .logo {
    grid-column: 1;
    justify-self: start;
}

.header h1 {
    grid-column: 2;
    justify-self: center;
    font-size: var(--font-size-header);
    font-weight: 300;
    margin: 0;
    line-height: var(--header-line-height);
    padding: var(--header-padding-top) 0 var(--header-padding-bottom) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(var(--font-size-header) * var(--header-line-height));
}

.logo {
    width: var(--logo-size);
    height: auto;
}

/* Ensure the entire card maintains consistent height and prevents any layout jumps */
.speed-card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--card-border-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin: 0 0 1rem 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Set minimum height to prevent layout changes */
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.speed-display {
    text-align: center;
    margin: -1px 0 2rem 0;
}

.speed-value {
    font-size: 5rem;
    font-weight: 300;
    color: var(--text-primary);
    line-height: 1;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.speed-unit {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-weight: 500;
}

.server-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.8;
    font-style: italic;
}

.server-info a {
    color: inherit;
    /* text-decoration: none; */
    transition: opacity 0.2s ease;
}

.server-info a:hover {
    opacity: 1;
    /* text-decoration: underline; */
    cursor: pointer;
}

.dealer-version {
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.8;
    font-style: italic;
    text-align: center;
    margin-top: auto;
}

.test-datetime {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.7;
    font-weight: 400;
    direction: ltr;
    text-align: center;
    min-height: 1.2em; /* Reserve space to prevent layout drift */
    visibility: hidden; /* Use visibility instead of display:none */
}

.test-datetime.visible {
    visibility: visible;
}

/* Speed graph */
.speed-graph {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.graph-title {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.5rem;
    text-align: center;
}

.graph-container {
    height: 60px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
}

/* Control zone - always visible, same height as other cards */
.control-zone {
    /* background: var(--bg-info-section); */
    /* padding: 1.5rem; */
    border-radius: 8px;
    /* margin: 1rem 0; */
    /* margin: 0.5rem 0; */
    min-height: 100px; /* Same height as other cards */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

/* Progress section and test controls - overlay each other */
.progress-section,
.test-controls {
    direction: ltr;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.progress-section {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
}

.test-controls {
    gap: 1rem;
}

/* State classes for visibility */
.control-zone.show-progress .progress-section {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0);
}

.control-zone.show-button .test-controls {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0);
}

/* Initially hide both, then animate in */
.control-zone.show-progress .test-controls,
.control-zone.show-button .progress-section {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(10px);
}

/* Results section - always visible with consistent height */
.results-section {
    background: var(--bg-info-section);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    min-height: 120px; /* Same height as control zone */
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}



/* Speed guidelines - always visible with consistent height */
.speed-guidelines {
    background: var(--bg-info-section);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    min-height: 120px; /* Same height as other cards */
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    justify-content: center;
}

.btn-primary {
    background: var(--btn-primary-start);
    background: linear-gradient(135deg, var(--btn-primary-start), var(--btn-primary-end));
    color: var(--text-white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: var(--btn-primary-start);
    background: linear-gradient(135deg, var(--btn-primary-start), var(--btn-primary-end));
    color: var(--text-white);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.btn-icon {
    font-size: 1.2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-info-section);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--btn-primary-start);
    background: linear-gradient(90deg, var(--btn-primary-start), var(--btn-primary-end));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1rem 0;
}

.info-item {
    background: var(--bg-info-section);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.info-value {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.result-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 6px;
}

.result-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.result-value {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

/* Fix RTL display for peak speed - force LTR for number + unit */
#peak-speed {
    direction: ltr;
    text-align: center;
}

/* Make status result-item span across both columns in the results grid */
.result-item-status {
    grid-column: 1 / -1;
}

/* Soften result values during testing to indicate no data yet */
.testing .result-value {
    color: var(--text-muted);
    opacity: 0.5;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.speed-guidelines h4 {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.guidelines-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.help-button {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--btn-primary-start);
    background: linear-gradient(135deg, var(--btn-primary-start), var(--btn-primary-end));
    color: var(--text-white);
    border: none;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.help-button:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.guidelines-list {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    text-align: center;
}

.guidelines-horizontal {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.guideline-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.quality-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.quality-indicator.excellent {
    background-color: var(--status-active);
}

.quality-indicator.good {
    background-color: var(--status-standby);
}

.quality-indicator.poor {
    background-color: var(--status-error);
}

.guideline-text {
    color: var(--text-secondary);
    font-weight: 500;
}

.quality-good {
    color: var(--status-active);
    font-weight: 600;
}

.quality-ok {
    color: var(--status-standby);
    font-weight: 600;
}

.quality-poor {
    color: var(--status-error);
    font-weight: 600;
}

.quality-unknown {
    color: var(--text-muted);
}

/* Animation for the running test */
.testing .speed-value {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        grid-template-columns: var(--logo-size-mobile) 1fr var(--logo-size-mobile);
        margin-bottom: 30px; /* Force consistent spacing */
        min-height: calc(var(--logo-size-mobile) + 10px); /* Ensure consistent header height */
    }
    
    .header h1 {
        font-size: var(--font-size-header-mobile);
        line-height: var(--header-line-height-mobile);
        padding: var(--header-padding-top-mobile) 0 var(--header-padding-bottom-mobile) 0;
        min-height: calc(var(--font-size-header-mobile) * var(--header-line-height-mobile));
        margin: 0; /* Reset any inherited margins */
    }
    
    .logo {
        width: var(--logo-size-mobile);
    }
    
    .speed-card {
        padding: 1.5rem;
        margin: 1rem 0;
    }
    
    .speed-value {
        font-size: 3.5rem;
    }
    
    .test-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .guidelines-list {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .guidelines-horizontal {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 1.5rem;
    }
}

/* Help Modal Styles */
.help-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.help-modal-content {
    position: relative;
    background: var(--bg-card);
    margin: 10% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-modal-header h3 {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.help-close {
    background: none;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.help-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.help-modal-body {
    padding: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-modal-body p {
    margin: 0 0 1rem 0;
}

.help-modal-body ul {
    margin: 0.5rem 0 0 0;
    padding-left: 0;
    list-style: none;
}

.help-modal-body li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.help-quality {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.help-quality.excellent {
    background-color: var(--status-active);
}

.help-quality.good {
    background-color: var(--status-standby);
}

.help-quality.poor {
    background-color: var(--status-error);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
