/* Variables */
:root {
    --bg-color: #efefef;
    --text-color: #777777;
    --disabled-text-color: #cccccc;
    --active-section-bg: white;
    --separator-color: #cccccc;
    --button-bg: #dddddd;
    --button-text: #333333;
    --button-highlight: #f0f0f0;
    --info-bg: #d0d0d0;
    --tesla-blue: #0077ff;
    --tesla-red: #ff0000;
    --button-radius: 13px;
    --weather-switch-slider: #ffffff;
    --weather-warning-color: #ff7700;
    --status-poor: #E65100;
    --status-good: #0fa215;
    --status-unavailable: #888888;
    --status-rain: #00a1ff;
    --heading-font-size: 17pt;
    --heading-font-weight: 500;
    --stock-up: #0fa215;
    --stock-down: #dc3545;
    --stock-neutral: #888888;
    --notification-bg: rgba(255, 255, 255, 0.9);
    --notification-success-bg: rgba(255, 255, 255, 0.9);
    --notification-error-bg: rgba(255, 255, 255, 0.9);
    --notification-info-bg: rgba(255, 255, 255, 0.9);
    --notification-text: #333333;
    --notification-text-alt: #333333;
}

body.dark-mode {
    --bg-color: #1d1d1d;
    --disabled-text-color: #444444;
    --active-section-bg: #333333;
    --separator-color: #444444;
    --button-bg: #333333;
    --button-text: #d6d6d6;
    --button-highlight: #bdbdbd;
    --info-bg: #302f39;
    --weather-switch-slider: #222222;
    --weather-warning-color: #ff9900;
    --status-poor: #ffcd27;
    --status-good: #5eff19;
    --status-unavailable: #888888;
    --status-rain: #4fb8ff;
    --stock-up: #3ad45b;
    --stock-down: #ff4d5e;
    --stock-neutral: #888888;
    --notification-bg: rgba(70, 70, 70, 0.9);
    --notification-success-bg: rgba(70, 70, 70, 0.9);
    --notification-error-bg: rgba(70, 70, 70, 0.9);
    --notification-info-bg: rgba(70, 70, 70, 0.9);
    --notification-text: #ffffff;
    --notification-text-alt: #ffffff;
}

/* Basic HTML Elements */
* {
    font-family: "Inter";
    font-optical-sizing: auto;
    font-variant-ligatures: all;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16pt;
    padding: 0;
    text-align: left;
}

a {
    color: var(--tesla-blue);
    text-decoration: none;
    font-weight: 500;
}

h1 {
    color: var(--button-text);
    font-size: 19pt;
    margin: 0 0 15px 0;
    font-weight: 250;
}

h2 {
    color: var(--button-text);
    font-size: var(--heading-font-size);
    margin: 28px 0 9px 0;
    font-weight: var(--heading-font-weight);
}

h3 {
    color: var(--button-text);
    font-size: calc(var(--heading-font-size) - 1pt);
    font-weight: calc(var(--heading-font-weight) - 100);
    margin: 16px 0 7px 0;
}

p {
    margin: 12px 0;
    text-align: justify;
    max-width: 980px;
}

ul {
    padding-left: 25px;
    margin: 0;
    text-align: justify;
    max-width: 940px;
}

li {
    margin: 11px 0;
}

hr {
    border: 0;
    border-top: 1px solid var(--separator-color);
    margin: 28px 0;
}

/* Layout */
.frame-container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

.left-frame {
    width: 300px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 10px 10px 5px 15px;
    box-sizing: border-box;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
}

.right-frame {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    padding: 20px 45px 20px 15px;
    box-sizing: border-box;
    scrollbar-width: thin;
    position: relative;
}

/* Scroll indicators */
.scroll-indicator {
    position: fixed;
    left: 300px;
    right: 10px;
    height: 64px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.top-fade {
    top: 0;
    background: linear-gradient(to bottom, var(--bg-color), transparent);
}

.bottom-fade {
    bottom: 0;
    background: linear-gradient(to top, var(--bg-color), transparent);
}

/* Scroll-to-top arrow for mobile */
.scroll-to-top {
    display: none;
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    z-index: 1000;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

@media only screen and (min-width: 901px) {
    .scroll-to-top {
        display: none !important;
    }
}

.section {
    display: none;
}

.hidden {
    display: none !important;
}

/* External site container */
#external-site {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

#external-site iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
    padding: 0;
    margin: 0;
}

/* Navigation */
.section-buttons {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    box-sizing: border-box;
}

.section-button {
    color: var(--text-color);
    border-radius: var(--button-radius);
    font-weight: 600;
    background-color: var(--bg-color);
    font-size: 19pt;
    padding: 16px 20px;
    border: none;
    cursor: pointer;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    transition: background-color 0.3s, color 0.3s;
}

.section-button.disabled {
    color: var(--disabled-text-color) !important;
    cursor: not-allowed;
}

.section-button.disabled:hover {
    background-color: var(--bg-color);
}

.logout-button {
    color: var(--button-text);
    background-color: var(--button-bg);
    border-radius: var(--button-radius);
    font-size: 16pt;
    font-weight: 600;
    padding: 16px 20px;
    border: none;
    cursor: pointer;
    text-align: center;
    margin-top: 15px;
    transition: background-color 0.3s;
}

.logout-button:hover {
    background-color: var(--active-section-bg);
}

.button-icon {
    width: 24px;
    height: 24px;
    margin-right: 14px;
    stroke: currentColor;
}

.section-button.active,
.section-button:hover {
    background-color: var(--active-section-bg);
    color: var(--button-text);
}

/* Notification dot */
.section-button.has-notification {
    position: relative;
}

.section-button.has-notification::after {
    content: attr(data-count);
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    min-width: 20px;
    height: 26px;
    background-color: var(--tesla-blue);
    border-radius: 13px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 12pt;
    font-weight: 750;
    padding: 0 9px;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.section-button.notification-transition::after {
    opacity: 0;
}

/* Weather alert dot */
.section-button.has-weather-alert {
    position: relative;
}

.section-button.has-weather-alert::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-color: #ff0000;
    border-radius: 50%;
    opacity: 1;
}

/* Link Button Lists */
.button-list {
    list-style: none;
    padding: 0;
    margin-top: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, 280px);
    gap: 15px;
    justify-content: start;
    max-width: calc(280px * 5 + 16px * 4);
}

.button-list li {
    margin: 0;
}

.button-list a {
    color: var(--button-text);
    background-color: var(--button-bg);
    border-radius: var(--button-radius);
    display: flex;
    padding: 23px 5px;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    gap: 11px;
}

.button-list a img {
    height: 36px;
    width: auto;
    border-radius: 7px;
}

/* Enhanced Image Visibility Classes */
.img-adaptive,
.img-adaptive-light-invert,
.img-adaptive-dark-invert {
    filter: grayscale(100%) contrast(1.5);
    transition: filter 0.3s;
}

body:not(.dark-mode) .img-adaptive,
body:not(.dark-mode) .img-adaptive-light-invert {
    filter: invert(100%);
}

body.dark-mode .img-adaptive-dark-invert {
    filter: invert(100%);
}

.img-white-transparent {
    mix-blend-mode: multiply;
    transition: filter 0.3s;
}

body.dark-mode .img-white-transparent {
    mix-blend-mode: screen;
    filter: invert(100%) brightness(125%);
}

/* Indicator container */
.control-container {
    position: fixed;
    top: -3px;
    right: 11px;
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    border-radius: 5px;
    padding: 8px 2px;
    z-index: 100;
    opacity: 0.80;
    transition: transform 0.2s ease-out;
    transform-origin: right center;
    will-change: transform;
}

.status-indicator {
    height: 24px;
    margin-right: 11px;
    margin-left: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

/* Network Status Indicator */
.network-icon {
    height: 16px;
    filter: invert(0%);
    transition: filter 0.3s ease;
}

/* Dark mode: white icon */
body.dark-mode .network-icon {
    filter: invert(70%);
}

.network-status .network-bar {
    transition: fill 0.3s ease;
}

.network-status.unavailable .network-bar {
    fill: var(--status-unavailable);
}

.network-status.poor .bar-1 {
    fill: var(--status-poor);
}

.network-status.poor .bar-2,
.network-status.poor .bar-3,
.network-status.poor .bar-4 {
    fill: var(--status-unavailable);
}

.network-status.fair .bar-1,
.network-status.fair .bar-2 {
    fill: var(--status-poor);
}

.network-status.fair .bar-3,
.network-status.fair .bar-4 {
    fill: var(--status-unavailable);
}

.network-status.good .bar-1,
.network-status.good .bar-2,
.network-status.good .bar-3 {
    fill: var(--status-good);
}

.network-status.good .bar-4 {
    fill: var(--status-unavailable);
}

.network-status.excellent .bar-1,
.network-status.excellent .bar-2,
.network-status.excellent .bar-3,
.network-status.excellent .bar-4 {
    fill: var(--status-good);
}

/* GPS Status Indicator */
.gps-status.unavailable {
    color: var(--status-unavailable);
}

.gps-status.poor {
    color: var(--status-poor);
}

.gps-status.good {
    color: var(--status-good);
}

.gps-status {
    color: var(--status-unavailable);
}

/* Rain Status Indicator */
.rain-status {
    color: var(--weather-warning-color);
    animation: pulse-rain 2s infinite;
    display: flex;
    align-items: center;
    gap: 3px;
}

.rain-status #rain-timing-text {
    color: var(--weather-warning-color);
    font-size: 10pt;
    font-weight: 700;
    white-space: nowrap;
}

@keyframes pulse-rain {
    0% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.7;
    }
}

/* Stock Status Indicator */
.stock-status {
    width: auto;
    font-size: 11pt;
    font-weight: 600;
    transition: color 0.3s ease;
    font-variant-numeric: tabular-nums;
}

.stock-status.up {
    color: var(--status-good);
}

.stock-status.down {
    color: var(--stock-down);
}

.stock-status.neutral {
    color: var(--stock-neutral);
}

/* Data Display */
.data-info, .data-info-column {
    row-gap: 18px;
    width: auto;
}

.data-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, 240px);
    column-gap: 28px;
}

.data-info-column {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
}

.data-info-column .data-item {
    margin-right: 0;
    width: auto;
}

.data-item {
    color: var(--button-text);
    font-weight: 600;
    font-size: var(--heading-font-size);
    display: block;
    margin-right: 0;
    padding-top: 0px;
}

.data-item:last-child {
    margin-right: 0;
    margin-bottom: 0;
}

.data-item h2 {
    color: var(--text-color);
    margin-top: 0px;
    margin-bottom: 4px;
}

/* Stats  */
.nav-container {
    display: flex;
    gap: 50px;
    margin: 30px 0px -25px 0px;
    align-items: flex-start;
}

.nav-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 10px 0 0 0;
    width: 400px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: left;
    min-width: 200px;
    height: 125px;
}

.value-container {
    display: flex;
    align-items: center;
}

.stat-value {
    color: var(--button-text);
    font-size: 52pt;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.stat-unit {
    color: var(--text-color);
    font-size: 24pt;
    font-weight: 600;
    font-family: sans-serif;
    margin-left: 5px;
}

.stat-label {
    color: var(--text-color);
    font-size: 13pt;
    font-weight: 500;
    margin-top: 0px;
    display: block;
    clear: both;
}

/* Dashboard Display */
.radar-container {
    position: relative;
    padding-top: 30px;
    margin-right: 30px;
}

.radar-title {
    position: absolute;
    top: 0px;
    left: 24px;
    text-align: center;
    margin: 0;
}

#radarDisplay {
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.1);
}

.dark-mode #radarDisplay {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Waze frame */
.teslawaze-container {
    height: calc(100vh - 370px);
    min-height: 280px;
    margin-bottom: 0;
    position: relative;
}

#teslawaze {
    border-radius: var(--button-radius);
    width: 100%;
    height: 100%;
    border: none;
}

/* Modal Login Dialog */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    font-size: 14pt;
    background-color: var(--bg-color);
    border-radius: var(--button-radius);
    padding: 25px;
    padding-top: 0px;
    max-width: 90%;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.75);
}

/* Login form */
.login-form {
    margin-top: 20px;
}

.login-form label {
    font-weight: 500;
    font-size: 14pt;
    width: 80px;
    margin-right: 15px;
    margin-bottom: 10px;
    color: var(--button-text);
    vertical-align: middle;
}

.login-form input {
    font-size: 16px;
    width: calc(100% - 90px);
    padding: 12px 15px;
    border: 2px solid var(--separator-color);
    border-radius: 8px;
    background-color: var(--active-section-bg);
    color: var(--button-text);
    box-sizing: border-box;
    vertical-align: middle;
}

.button-container {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-button {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.modal-button.cancel {
    background-color: var(--button-bg);
    color: var(--button-text);
}

.modal-button.submit {
    background-color: var(--tesla-blue);
    color: white;
}

.error-message {
    color: var(--tesla-red);
    margin-bottom: 20px;
    font-size: 14px;
    min-height: 20px;
}

/* Settings Section Styles */
.settings-controls {
    margin-top: -9px;
    display: grid;
    grid-template-columns: repeat(auto-fill, 470px);
    gap: 0px 11px;
}

.settings-toggle-item {
    display: flex;
    align-items: center;
    background-color: var(--button-bg);
    border-radius: var(--button-radius);
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 12px;
    padding-bottom: 12px;
    margin-top: 9px;
    max-width: 480px;
    font-weight: 550;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

.settings-toggle-item label {
    flex-grow: 1;
    cursor: inherit;
}

.settings-toggle-item input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-toggle-item span.settings-toggle-slider {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
    flex-shrink: 0;
}

.settings-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #aaa;
    transition: .4s;
    border-radius: 30px;
}

.settings-toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.settings-description {
    margin-top: 2pt;
    font-size: 12.5pt;
    font-style: italic;
    margin-left: 11pt;
    text-align: right;
}

input:checked + .settings-toggle-slider {
    background-color: var(--tesla-blue);
}

input:focus + .settings-toggle-slider {
    box-shadow: 0 0 1px var(--tesla-blue);
}

input:checked + .settings-toggle-slider:before {
    transform: translateX(26px);
}

/* Settings Text Item */
.settings-text-item {
    cursor: initial;
}

.settings-text-item input[type="text"] {
    opacity: 100%;
    width: 320px;
    height: 19px;
    position: relative;
    padding: 8px 14px;
    border-width: 0px;
    border-radius: 9px;
    background: var(--bg-color);
    color: var(--button-text);
    font-size: 14pt;
    font-weight: 500;
    text-align: right;
}

body.dark-mode .settings-text-item input[type="text"]:disabled {
    background: #333333;
    color: #555555;
}

.settings-text-item input[type="text"]:focus {
    outline: var(--tesla-blue) solid 2px;
}

#in-map-toggle {
    position: absolute;
    margin: 0;
    padding: 7px;
    z-index: 10;
    background-color: transparent;
    opacity: 0.8;
}

#in-map-toggle .option-switch {
    background-color: var(--button-bg);
}

#in-map-toggle .option-button {
    font-size: 12pt;
    font-weight: 700;
}

/* Option Switch (Two-option selector) */
.option-switch-container {
    padding-right: 15px;
    padding-top: 11px;
    padding-bottom: 11px;
    cursor: initial;
}

.option-switch {
    display: flex;
    border-radius: calc(var(--button-radius) - 2px);
    overflow: hidden;
    background-color: var(--button-highlight);
}

.option-button {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 14px;
    color: var(--text-color);
    font-size: 14pt;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

.option-button.active {
    background-color: var(--tesla-blue);
    color: white;
}

.option-button:hover:not(.active) {
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .option-button:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Landscape Mode */
@media only screen and (max-width: 900px) {
    :root {
        --heading-font-size: 14pt;
        --heading-font-weight: 500;
        --button-radius: 9px;
    }
    
    body {
        font-size: 12pt;
    }

    p {
        text-align: left;
    }

    ul {
        padding-left: 20px;
        text-align: left;
    }

    .logout-button {
        border-radius: var(--button-radius);
        font-size: 12pt;
        font-weight: 600;
        padding: 7px 20px;
        border: none;
        cursor: pointer;
        text-align: center;
        margin-top: 15px;
        transition: background-color 0.3s;
    }
    
    /* Hide control div */
    .control-container {
        display: none;
    }
    
    /* Layout adjustment */
    .frame-container {
        flex-direction: column;
        position: static;
        height: auto;
        overflow: visible;
    }

    /* Adjust scroll indicator placement */
    .scroll-indicator {
        left: 0;
        right: 0;
    }
    
    /* Convert left menu to horizontal top menu */
    .left-frame {
        width: 100%;
        height: auto;
        max-height: none;
        padding: 3px;
        overflow: visible;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .left-frame::-webkit-scrollbar {
        display: none;
    }
    
    /* Convert section buttons to horizontal layout */
    .section-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        overflow: visible;
    }
    
    .section-buttons h1 {
        display: none;
    }
    
    .section-button {
        font-size: 13pt;
        padding: 0px 9px;
        white-space: nowrap;
        height: 32px;
    }

    .section-button.has-notification {
        padding-right: 42px !important;
    }

    .section-button.has-notification::after {
        right: 6px;
        min-width: 12px;
        height: 18px;
        border-radius: 9px;
        font-size: 8pt;
        padding: 0 5px;
    }

    .button-icon {
        width: 16px;
        height: 16px;
        margin-right: 8px;
    }
    
    /* Right frame takes remaining space */
    .right-frame {
        height: auto;
        padding: 1px 3px;
        overflow: visible;
    }
    
    /* Dashboard adjustments */
    .nav-container {
        gap: 20px;
        margin: 10px 0px -15px 0px;
        flex-direction: column;
        align-items: stretch;
    }

    .nav-stats {
        width: 100%;
    }

    .data-info-column {
        width: 100%;
    }

    .data-info-column .data-item span {
        display: block;
        word-break: break-word;
    }

    .radar-container {
        padding-top: 20px;
        margin-right: 0;
    }
    
    #radarDisplay {
        width: 150px;
        height: 150px;
    }
    
    .stat-box {
        height: 90px;
    }
    
    .stat-value {
        font-size: 36pt;
    }
    
    .stat-unit {
        font-size: 18pt;
    }
    
    .stat-label {
        font-size: 12pt;
    }
    
    /* Teslawaze container adjustment */
    .teslawaze-container {
        height: calc(100vh - 300px);
        min-height: 200px;
    }
    
    /* Button lists */
    .button-list {
        grid-template-columns: repeat(auto-fill, 220px);
        gap: 10px;
    }
    
    .button-list a {
        padding: 15px 5px;
        height: 30px;
        font-size: 12pt;
    }
    
    /* News-related mobile adjustments moved to css/news.css */
    
    /* Settings adjustments */
    .settings-controls {
        grid-template-columns: repeat(auto-fill, 300px);
    }
    
    .settings-toggle-item {
        padding: 8px 10px;
        font-size: 11pt;
    }
    
    .settings-toggle-item span.settings-toggle-slider {
        width: 50px;
        height: 26px;
    }
    
    .settings-toggle-slider:before {
        height: 20px;
        width: 20px;
    }
    
    input:checked + .settings-toggle-slider:before {
        transform: translateX(22px);
    }
    
    /* Text input fields in settings */
    .settings-text-item input[type="text"] {
        width: 200px;
        height: 16px;
        padding: 6px 12px;
        font-size: 12pt; 
    }
    
    /* Option Switch adjustments for mobile */
    .option-button {
        font-size: 9pt;
        padding: 5px 8px;
    }

    .option-switch-container {
        padding: 6px 8px;
    }

    /* Settings section headers */
    h2 {
        font-size: 13pt;
        margin-top: 18px;
        margin-bottom: 3px;
    }

    h3 {
        font-size: 12pt;
        margin-top: 7px;
        margin-bottom: 7px;
    }

    /* Fix external site iframe positioning in mobile mode */
    #external-site {
        position: fixed;
        top: 120px; /* Space for horizontal section menu */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
    }

    #external-site iframe {
        width: 100%;
        height: 100%;
    }
}
