/* === RESET (minimal from w3.css) === */
*, *::before, *::after { box-sizing: border-box; }
html { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: Montserrat, sans-serif; font-weight: 700; }
img { border-style: none; }

/* === W3 utility classes used === */
.w3-container { padding: 0.01em 16px; }
.w3-padding { padding: 8px 16px; }
.w3-text-grey { color: #9e9e9e; }
.w3-main { position: relative; }

/* === BASE === */
html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 0;
}

body {
    color: #fff;
    overflow: hidden;
    min-height: 100vh;
    max-height: 100vh;
    background: #1a2a1a url("/media/green.jpg") center / cover no-repeat;
    font-family: Montserrat, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

main {
    min-height: 100vh;
}

section {
    min-height: 100vh;
    position: relative;
    padding: 8px;
    display: none;
}

section.active {
    display: block;
}

/* === GRID === */
.grid-container {
    display: grid;
    gap: 8px;
    overflow: hidden;
}

.grid-columns {
    grid-template-columns: repeat(3, 1fr);
}

.grid-item {
    position: relative;
}

/* === BOX === */
.box {
    background-color: rgba(100, 100, 100, 0.25);
    width: 100%;
    text-align: center;
    border-radius: 4px;
}

.box > span {
    font-weight: bold;
}

/* === FLEX === */
.flex-container {
    display: flex;
}

.flex-vertical-center {
    align-items: center;
    justify-content: center;
}

.flex-item-right {
    margin-left: auto;
}

.flex-item-auto-width {
    flex: 1;
}

/* === TYPOGRAPHY === */
.grid-main h2 {
    padding: 16px 0;
}

.grid-item > h3:first-child {
    margin-top: 0;
}

.grid-item > h3 {
    text-align: center;
    padding: 16px 0;
    background-color: rgba(200, 200, 200, 0.25);
    margin: 8px 0;
    border-radius: 4px;
}

.xs_text { font-size: 1em; }
.s_text { font-size: 1.2em; }
.m_text { font-size: 1.4em; }
.l_text { font-size: 1.6em; }
.xl_text { font-size: 1.8em; }
.xxl_text { font-size: 2em; }
.xxxl_text { font-size: 4em; }

/* === ICONS === */
img.icon {
    width: 48px;
}

img.icon.icon2x {
    width: 96px;
}

.fa-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    display: inline-block;
}

.lamp_icon .fa-icon,
.area_icon .fa-icon {
    width: 2em;
    height: 2em;
}

/* === WEATHER === */
.weather_forecast {
    text-align: center;
}

.w_icon {
    padding-right: 16px;
}

/* === LIGHTS === */
.lamps, .areas {
    overflow-y: auto;
    max-height: calc(50vh - 110px);
}

.lamp_name {
    height: 30px;
}

.area, .lamp {
    height: 100%;
    padding: 8px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 4px;
}

.area:hover, .lamp:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.area[data-state="true"], .lamp[data-state="true"] {
    background-color: orange;
}

/* === CHARTS === */
#myChart {
    width: 98% !important;
}

/* === CLOCK SECTION === */
section#clock {
    padding: 64px 16px 16px 16px;
}

.clock-container {
    text-align: center;
}

.clock-inner {
    font-size: 14em;
    font-weight: bold;
}

.date-inner {
    font-size: 4em;
    font-weight: bold;
    color: #f1f1f1;
}

#clock-footer {
    font-size: 4em;
    font-weight: bold;
    color: #f1f1f1;
}

.energy-inner {
    margin-left: auto;
}

/* === TRANSITIONS === */
.lamp, .area, .box {
    transition: background-color 0.3s ease;
}
/* === TOAST NOTIFICATIONS === */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9em;
    color: #fff;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    pointer-events: auto;
    max-width: 360px;
    backdrop-filter: blur(8px);
}

.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-error {
    background-color: rgba(220, 53, 69, 0.9);
}

.toast-success {
    background-color: rgba(40, 167, 69, 0.9);
}

.toast-info {
    background-color: rgba(23, 162, 184, 0.9);
}

.toast-icon {
    margin-right: 8px;
    font-weight: bold;
}

/* === STATUS INDICATOR === */
.status-dot {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 9999;
    transition: background-color 0.3s ease;
}

.status-ok {
    background-color: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
}

.status-error {
    background-color: #dc3545;
    box-shadow: 0 0 6px rgba(220, 53, 69, 0.6);
    animation: pulse-error 2s infinite;
}

@keyframes pulse-error {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
