/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #f8f8f2;
    background: #000;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* CSS Variables for theme */
:root {
    --primary: #bd93f9;
    --secondary: #ff79c6;
    --success: #50fa7b;
    --danger: #ff5555;
    --dark-bg: rgba(20, 20, 30, 0.92);
    --card-bg: rgba(40, 42, 54, 0.95);
    --border: #44475a;
    --text: #f8f8f2;
    --text-secondary: #d0d0d0;
}

/* 3D forward dots background canvas */
#spaceCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* Main container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    background: var(--dark-bg);
    border-radius: 12px; /* Reduced from 16px */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
    padding: 15px; /* Reduced from 25px */
    margin-top: 12px; /* Reduced from 20px */
    border: 1px solid var(--border);
}

/* Header styling - kept minimal to reduce vertical space */
header {
    text-align: center;
    margin-bottom: 10px; /* Reduced from 15px */
    padding-bottom: 1px; /* Reduced from 10px */
    border-bottom: 1px solid var(--border);
}

header img {
    height: 90px; /* Increased 3x from 30px */
    width: auto;
    border-radius: 20%;
    margin-bottom: 0px; /* Increased 3x from 1px */
}

h1 {
    font-size: 2rem; /* Reduced from 1.4rem (35% reduction) */
    margin-bottom: 1px; /* Reduced from 5px */
    color: var(--primary);
    letter-spacing: 1px;
}

.subtitle {
    font-size: 1rem; /* Reduced from 0.7rem (35% reduction) */
    color: var(--secondary);
    margin-bottom: 3px; /* Reduced from 4px */
}

/* App title area in results page */
.app-title-area {
    text-align: center;
    margin-bottom: 7px; /* Reduced from 10px (35% reduction) */
    padding-bottom: 4px; /* Reduced from 6px (35% reduction) */
    border-bottom: 1px solid var(--border);
}

.app-title-area h1 {
    font-size: 1rem; /* Reduced from 1.4rem (35% reduction) */
    color: var(--primary);
    margin: 0;
}

/* Results header (satellite name only) */
.results-header {
    text-align: center;
    margin-bottom: 6px; /* Reduced from 9px (35% reduction) */
    padding-bottom: 4px; /* Reduced from 6px (35% reduction) */
    border-bottom: 1px solid var(--border);
    color: var(--primary);
}

/* Form section */
.form-section {
    background: var(--card-bg);
    padding: 12px; /* Reduced from 18px (35% reduction) */
    border-radius: 5px; /* Reduced from 8px (35% reduction) */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px; /* Reduced from 15px (35% reduction) */
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 10px; /* Reduced from 15px (35% reduction) */
}

label {
    display: block;
    margin-bottom: 7px; /* Reduced from 10px (35% reduction) */
    font-weight: 600;
    color: var(--text);
    font-size: 0.8rem; /* Reduced from 1.1rem (35% reduction) */
}

input, textarea {
    width: 100%;
    padding: 5px; /* Reduced from 7px (35% reduction) */
    border: 1px solid var(--border);
    border-radius: 3px; /* Reduced from 5px (35% reduction) */
    font-size: 12px; /* Reduced from 14px (35% reduction) */
    transition: all 0.3s;
    background: rgba(30, 30, 40, 0.7);
    color: var(--text);
}

input:focus, textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 1px rgba(189, 147, 249, 0.4);
}

textarea {
    height: 60px; /* Reduced from 70px (35% reduction) */
    resize: vertical;
    font-family: monospace;
    line-height: 1.3; /* Reduced from 1.4 */
}

/* TLE input with special styling */
#tle-input {
    border: 1px solid var(--secondary); /* Reduced from 2px */
    font-weight: 500;
}

#tle-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(189, 147, 249, 0.4);
}

/* Buttons */
button {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: #f8f8f2;
    padding: 5px 10px; /* Reduced from 7px 15px (35% reduction) */
    border: none;
    border-radius: 3px; /* Reduced from 5px (35% reduction) */
    cursor: pointer;
    font-size: 12px; /* Reduced from 14px (35% reduction) */
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 6px rgba(189, 147, 249, 0.3);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(189, 147, 249, 0.5);
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Submit button */
#submit-btn {
    display: block;
    margin: 8px auto; /* Reduced from 12px (35% reduction) */
    width: 150px; /* Reduced from 180px (35% reduction) */
    font-size: 13px; /* Reduced from 15px (35% reduction) */
    padding: 6px; /* Reduced from 9px (35% reduction) */
    min-height: 30px;
}

/* Current location info */
#current-location-info {
    text-align: center;
    margin: 8px auto; /* Reduced from 12px (35% reduction) */
    padding: 6px; /* Reduced from 9px (35% reduction) */
    background: rgba(68, 71, 90, 0.4);
    border-radius: 3px; /* Reduced from 5px (35% reduction) */
    border: 1px solid var(--border);
    font-size: 0.8rem; /* Reduced from 0.9rem (35% reduction) */
    max-width: 800px;
}

/* Two location selection cards side by side */
.location-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Two equal columns */
    gap: 6px; /* Reduced from 9px (35% reduction) */
    margin: 10px 0; /* Reduced from 15px (35% reduction) */
    max-width: 100%;
    position: relative; /* Ensure proper stacking context for overlay */
}

.location-option {
    background: var(--card-bg);
    padding: 10px; /* Reduced from 15px (35% reduction) */
    border-radius: 4px; /* Reduced from 6px (35% reduction) */
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 110px; /* Reduced from 170px (35% reduction) */
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.location-option:hover {
    transform: translateY(-3px); /* Reduced from -5px (35% reduction) */
    box-shadow: 0 5px 13px rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.location-option h3 {
    margin: 0 0 7px; /* Reduced from 10px (35% reduction) */
    color: var(--primary);
    font-size: 0.9rem; /* Reduced from 1.2rem (35% reduction) */
    align-self: center;
}

.location-option p {
    margin: 3px 0; /* Reduced from 5px (35% reduction) */
    color: var(--text-secondary);
    font-size: 0.7rem; /* Reduced from 0.8rem (35% reduction) */
    align-self: center;
}

.location-option button {
    align-self: center;
    margin: 3px 0; /* Reduced from 5px (35% reduction) */
    padding: 4px 8px; /* Reduced from 6px 12px (35% reduction) */
    font-size: 10px; /* Reduced from 12px (35% reduction) */
    width: 100%;
    max-width: 140px; /* Reduced from 160px (35% reduction) */
    min-height: 30px;
}

#use-default-location {
    margin-top: 6px; /* Reduced from 9px (35% reduction) */
}

#use-browser-location {
    margin-bottom: 9px; /* Reduced from 15px */
}



/* Manual coordinates layout - lat/lon side by side, altitude below */
.coordinates {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns for lat/lon */
    grid-template-rows: auto auto; /* Two rows - one for inputs, one for altitude */
    gap: 8px;
    align-items: start;
    margin: 10px 0 12px;
    width: 100%;
}

.coordinates > div:first-child {  /* Latitude */
    grid-column: 1;
    grid-row: 1;
}

.coordinates > div:nth-child(2) {  /* Longitude */
    grid-column: 2;
    grid-row: 1;
}

.coordinates > div:nth-child(3) {  /* Altitude */
    grid-column: 1 / span 2; /* Span both columns */
    grid-row: 2;
    width: 100%;
}

.coordinates label {
    text-align: center;
    font-weight: normal;
    font-size: 0.7rem;
    margin-bottom: 2px;
    color: var(--text-secondary);
    width: 100%;
}

.coordinates input {
    width: 100%;
    padding: 4px;
    font-size: 11px;
    max-width: 100%;
}

/* Time selection layout */
.time-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 10px 0 12px;
    width: 100%;
}

.date-time-container {
    display: flex;
    gap: 6px;
    width: 100%;
    justify-content: space-between;
}

.date-field, .time-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-selection label {
    text-align: center;
    font-weight: normal;
    font-size: 0.7rem;
    margin-bottom: 2px;
    color: var(--text-secondary);
    width: 100%;
}

.time-selection input {
    width: 100%;
    padding: 4px;
    font-size: 11px;
    max-width: 100%;
}

/* Results section */
.results-section {
    background: var(--card-bg);
    padding: 12px; /* Reduced from 18px (35% reduction) */
    border-radius: 5px; /* Reduced from 7px (35% reduction) */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    margin: 8px 0; /* Reduced from 12px (35% reduction) */
    border: 1px solid var(--border);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Reduced from 280px */
    gap: 8px; /* Reduced from 12px (35% reduction) */
    margin-bottom: 10px; /* Reduced from 15px (35% reduction) */
}

.coordinates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns side by side */
    gap: 8px; /* Reduced from 12px (35% reduction) */
    margin-bottom: 10px; /* Reduced from 15px (35% reduction) */
}

/* Ensure the geodetic and observer cards use the same height */
.geodetic-coords,
.observer-info {
    min-height: auto;
}

.manual-location-card {
    margin-top: 10px; /* Reduced from 15px (35% reduction) */
}

.result-card {
    background: rgba(30, 30, 40, 0.7);
    padding: 8px; /* Reduced from 12px (35% reduction) */
    border-radius: 4px; /* Reduced from 6px (35% reduction) */
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
    border-left: 2px solid var(--primary); /* Reduced from 3px (35% reduction) */
    transition: transform 0.3s;
    border: 1px solid var(--border);
    text-align: center;
}

.result-card:hover {
    transform: translateY(-2px); /* Reduced from -3px (35% reduction) */
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.4);
}

.result-card h3 {
    margin-bottom: 6px; /* Reduced from 9px (35% reduction) */
    color: var(--primary);
    font-size: 0.9rem; /* Reduced from 1rem (35% reduction) */
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px; /* Reduced from 6px (35% reduction) */
}

.result-card p {
    margin-bottom: 4px; /* Reduced from 6px (35% reduction) */
    font-size: 0.8rem; /* Reduced from 0.9rem (35% reduction) */
    color: var(--text);
}

.result-card p strong {
    display: block;
    color: var(--secondary);
    margin-bottom: 2px; /* Reduced from 3px (35% reduction) */
}

/* Live update controls */
.live-update-controls {
    background: var(--card-bg);
    padding: 8px; /* Reduced from 12px (35% reduction) */
    border-radius: 4px; /* Reduced from 6px (35% reduction) */
    text-align: center;
    margin: 10px 0; /* Reduced from 15px (35% reduction) */
    border: 1px solid var(--border);
}

#toggle-live-update {
    background: linear-gradient(135deg, var(--success), #4af56c);
    padding: 5px 10px; /* Reduced from 7px 15px (35% reduction) */
    font-size: 12px; /* Reduced from 14px (35% reduction) */
    margin-bottom: 6px; /* Reduced from 9px (35% reduction) */
    min-height: 30px;
}

#toggle-live-update.running {
    background: linear-gradient(135deg, var(--danger), #ff6b8b);
}

#back-to-input, #new-satellite {
    margin: 0 4px; /* Reduced from 6px (35% reduction) */
    background: linear-gradient(135deg, #6272a4, #44475a);
    padding: 5px 10px; /* Reduced from 7px 15px (35% reduction) */
    min-height: 30px;
}

/* TLE display */
.tle-display {
    margin: 8px 0; /* Reduced from 12px (35% reduction) */
    padding: 6px; /* Reduced from 9px (35% reduction) */
    background: rgba(30, 30, 40, 0.7);
    border-radius: 3px; /* Reduced from 5px (35% reduction) */
    border: 1px solid var(--border);
    font-family: monospace;
    font-size: 0.7rem; /* Reduced from 0.8rem (35% reduction) */
    line-height: 1.3; /* Reduced from 1.4 */
}

.tle-display p {
    margin: 6px 0; /* Reduced from 10px */
    word-break: break-all;
}

/* Help section */
.help-section {
    background: var(--card-bg);
    padding: 15px; /* Reduced from 25px */
    border-radius: 7px; /* Reduced from 12px */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); /* Reduced from 8px 25px */
    margin-top: 12px; /* Reduced from 20px */
    border: 1px solid var(--border);
}

.tle-format {
    background: rgba(30, 30, 40, 0.7);
    color: var(--text);
    padding: 9px; /* Reduced from 15px */
    border-radius: 5px; /* Reduced from 8px */
    margin: 9px 0; /* Reduced from 15px */
    font-family: monospace;
    font-size: 12px; /* Reduced from 14px */
    line-height: 1.4; /* Reduced from 1.5 */
    overflow-x: auto;
    border: 1px solid var(--border);
    margin-left: 15px; /* Add left margin to move content away from border */
}

.tle-format p {
    margin-bottom: 6px; /* Reduced from 10px */
}

/* Add padding for list items in help section */
.help-section ul {
    padding-left: 20px; /* Add proper padding for list items */
    margin: 10px 0;
}

.help-section li {
    margin-bottom: 5px;
}

/* Error and success messages */
.error {
    color: var(--danger);
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 85, 85, 0.15);
    border-radius: 6px;
    border-left: 4px solid var(--danger);
}

.success {
    color: var(--success);
    margin-top: 12px;
    padding: 12px;
    background: rgba(80, 250, 123, 0.15);
    border-radius: 6px;
    border-left: 4px solid var(--success);
}

/* Additional helper classes */
.tle-instructions {
    margin: 8px 0 15px;
    font-size: 0.95rem;
    color: var(--primary);
}

.location-info {
    text-align: center;
    margin: 20px auto;
    padding: 15px;
    background: rgba(68, 71, 90, 0.4);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 1rem;
    max-width: 800px;
}

/* Wrapper for location section to allow overlay */
.location-section-wrapper {
    position: relative;
}

.location-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 20, 30, 0.85); /* Dark semi-transparent background */
    border-radius: 8px; /* Match the container's border radius */
    text-align: center;
    z-index: 10;
    display: flex; /* Always use flex display */
    flex-direction: column; /* Stack spinner and text vertically */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px); /* Blur effect */
    -webkit-backdrop-filter: blur(4px); /* Safari support */
    border: 1px solid var(--border);
    opacity: 0; /* Hidden by default */
    pointer-events: none; /* Don't capture events when hidden */
}

.location-loading-overlay.show {
    opacity: 1; /* Visible when shown */
    pointer-events: auto; /* Capture events when visible */
}

.location-spinner {
    width: 24px;
    height: 24px;
    margin: 0 auto 6px;
}

/* Loading spinner */
.loading-spinner {
    border: 4px solid rgba(45, 45, 58, 0.5);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
    margin: 12px auto;
}

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

/* Loading overlay */
#loading {
    display: none;
    text-align: center;
    margin: 20px auto;
    padding: 25px;
    background: var(--card-bg);
    border-radius: 10px;
    color: var(--text);
    max-width: 600px;
    border: 1px solid var(--border);
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .container {
        padding: 20px;
        margin-top: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    header img {
        height: 80px;
    }
    
    .form-section, .results-section, .help-section {
        padding: 20px;
    }
    
    .location-section {
        grid-template-columns: 1fr; /* Single column on mobile */
    }
    
    .coordinates {
        grid-template-columns: 1fr;
    }
    
    .results-grid,
    .coordinates-grid {
        grid-template-columns: 1fr;
    }
    
    #submit-btn {
        width: 100%;
        max-width: 100%;
    }
    
    .location-option button {
        width: 100%;
    }
    
    #back-to-input, #new-satellite {
        display: block;
        margin: 10px auto;
        width: 80%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .form-section, .results-section, .help-section {
        padding: 15px;
    }
    
    .location-section {
        grid-template-columns: 1fr; /* 1 column on mobile */
    }
    
    .result-card h3 {
        font-size: 1.1rem;
    }
    
    .result-card p {
        font-size: 1rem;
    }
}

/* Links section */
.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    background: rgba(68, 71, 90, 0.3);
    border: 1px solid var(--border);
}

.footer-link:hover {
    color: var(--secondary);
    text-decoration: underline;
    background: rgba(68, 71, 90, 0.5);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--dark-bg);
    margin: 2% auto;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.7);
}

.modal-content h2 {
    color: var(--primary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.close {
    color: var(--danger);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close:hover,
.close:focus {
    color: #ff0000;
    text-decoration: none;
}

.modal-body {
    margin-bottom: 20px;
}

.about-text {
    margin-bottom: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.highlight {
    color: var(--primary);
    font-weight: 500;
}

.developer-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.developer-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    text-align: center;
}

.developer-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    flex-shrink: 0;
}

.developer-text {
    color: var(--text-secondary);
    text-align: justify;
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.social-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.social-link:hover {
    color: var(--primary);
    background: rgba(40, 42, 54, 0.7);
}

.back-btn {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    margin-left: auto;
}

.back-btn:hover {
    background: var(--primary);
    color: var(--dark-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Copyright */
.copyright {
    text-align: center;
    padding: 20px 0 10px 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 20px;
    border-top: 1px solid var(--border);
}

/* Help section specific styles */
.tle-format {
    background: var(--card-bg);
    color: var(--text);
    padding: 12px;
    border-radius: 6px;
    margin: 12px 0;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-x: auto;
    border: 1px solid var(--border);
}

/* Modal specific list styling */
.modal-body ul {
    padding-left: 25px;
    margin: 10px 0;
}

.modal-body li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* Responsive modal adjustments */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .footer-link {
        width: 100%;
        text-align: center;
    }
    
    .social-links[style*="flex-direction: row"] {
        flex-direction: column !important;
    }
    
    .social-links[style*="flex-direction: row"] .social-link {
        width: 100% !important;
        max-width: none !important;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 10% auto;
        width: 98%;
    }
    
    .tle-format {
        font-size: 11px;
        padding: 8px;
    }
    
    .back-btn {
        width: 100%;
        justify-content: center;
    }
}

