/* ============================================================
   Legacy Grid (kept for backward compat)
   ============================================================ */
.Grid-container {
    display         : flex;
    flex-direction  : column;
    margin          : 8px;
    gap             : 8px;
}
.Grid-elt {
    display         : grid;
    grid-template-columns: repeat(16, [col-start] 1fr);
    grid-column     : col-start / span 16;
    gap             : 8px;
    border-radius   : 8px;
    background-color: #333;
}
.Elt-title  { color:white; grid-column:span 16; padding:0 10px; }
.Row-title  { color:yellow; grid-column:2/span 2; display:flex; align-items:center; }
.Row-cell   { grid-column:span 1; display:flex; align-items:center; flex-direction:column; justify-content:center; color:white; }
.Row-column { grid-column:span 1; display:flex; align-items:center; flex-direction:column; justify-content:space-around; color:white; height:85%; }
.Row-toggle { grid-column:span 2; display:flex; align-items:center; justify-content:center; color:white; }
.Row-range  { grid-column:span 3; display:flex; align-items:center; justify-content:space-around; color:white; }


/* ============================================================
   SCADA Layout  (DataDisplay.js)
   ============================================================ */

/*
 * Outer grid wrapper — CSS grid so blocks always fill the full row width evenly.
 * The ResizeObserver in DataDisplay._addGrid scales the whole grid uniformly
 * when it overflows the viewport.
 */
.scada-grid {
    display                 : grid;
    grid-template-columns   : repeat(auto-fit, minmax(0, 1fr));
    align-content           : stretch;
    gap                     : 12px;
    padding                 : 12px;
    box-sizing              : border-box;
    width                   : 100%;
    transform-origin        : top left;
}

/*
 * Portrait mobile: force 2-column layout so section blocks sit side by side
 * (Vannes, Turbines) rather than stacking vertically.
 */
@media (orientation: portrait) and (max-width: 767px) {
    .scada-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
/* Mobile: blocks at natural size, scrollable — no stretch needed */
@media (max-width: 767px) {
    .scada-grid {
        align-content: start;
    }
}


/* Section card */
.scada-block {
    display         : flex;
    flex-direction  : column;
    background-color: #23233a;
    border          : 1px solid #3d3d5c;
    border-radius   : 10px;
    padding         : 8px 10px 10px;
    box-sizing      : border-box;
    min-width       : 180px;
}

/* Section title */
.scada-title-main {
    color           : #c8d0e0;
    font-size       : 0.8rem;
    font-weight     : 700;
    text-transform  : uppercase;
    letter-spacing  : 0.1em;
    border-bottom   : 1px solid #3d3d5c;
    padding-bottom  : 5px;
    margin-bottom   : 8px;
}

/*
 * Widget area inside a section.
 * Desktop: sub-panels stack one below the other (flex-direction: column).
 * Mobile:  CSS grid fills groups side-by-side horizontally.
 */
.scada-block-body {
    display         : flex;
    flex-direction  : column;
    gap             : 6px;
}

@media (max-width: 767px) {
    .scada-block-body {
        display               : grid;
        grid-template-columns : repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Sub-group (<défauts>, <voyants>, <vanne 1> …) */
.scada-group {
    display         : flex;
    flex-direction  : column;
    border          : 1px solid #2e2e4a;
    border-radius   : 6px;
    padding         : 5px 7px 6px;
    background-color: #1a1a2e;
    min-width       : 0;
    box-sizing      : border-box;
}

/* Sub-group title */
.scada-group-title {
    color           : #7a9fd4;
    font-size       : 0.68rem;
    font-weight     : 700;
    text-transform  : uppercase;
    letter-spacing  : 0.07em;
    margin-bottom   : 5px;
    padding-bottom  : 3px;
    border-bottom   : 1px solid #2e2e4a;
}

/*
 * Widget area inside a sub-group.
 * Elements wrap onto multiple lines so nothing is ever clipped.
 * The outer ResizeObserver scale on .scada-grid handles viewport overflow.
 */
.scada-group-body {
    display         : flex;
    flex-direction  : row;
    flex-wrap       : wrap;
    align-items     : flex-start;
    gap             : 4px;
}

/* ============================================================
   SCADA Widgets  (sWidgets.js)
   ============================================================ */

.scada-cell { display:flex; align-items:center; justify-content:center; }

/* -------------------------------------------------------
   INDICATOR — passive read-only display
   ------------------------------------------------------- */
.scada-indicator {
    display         : flex;
    align-items     : center;
    justify-content : center;
    padding         : 0 8px;
    border-radius   : 4px;
    background-color: #12121f;
    border          : 1px solid #2e2e4a;
    border-left     : 3px solid #4a5568;
    color           : #8892a4;
    font-family     : 'Courier New', monospace;
    font-size       : 0.8rem;
    font-weight     : 600;
    letter-spacing  : 0.02em;
    min-width       : 80px;
    min-height      : 38px;
    text-align      : center;
    white-space     : nowrap;
    overflow        : hidden;
    text-overflow   : ellipsis;
    box-shadow      : none;
    transition      : background-color 0.25s, border-left-color 0.25s, color 0.25s;
}

.scada-indicator.alarm {
    background-color: #2d0a0a;
    border-left-color: #dc3545;
    color           : #ff8080;
    animation       : scada-blink 1s step-start infinite;
}

@keyframes scada-blink {
    0%, 100% { opacity: 1;    }
    50%       { opacity: 0.3; }
}

/* -------------------------------------------------------
   BUTTON — clearly interactive
   ------------------------------------------------------- */
.scada-btn {
    min-width       : 72px;
    min-height      : 38px;
    padding         : 0 14px;
    font-size       : 0.75rem;
    font-weight     : 700;
    letter-spacing  : 0.05em;
    white-space     : nowrap;
    text-transform  : uppercase;
    border-radius   : 20px;
    box-shadow      : 0 2px 5px rgba(0,0,0,0.55),
                      0 1px 0 rgba(255,255,255,0.08) inset;
    transition      : transform 0.08s, box-shadow 0.08s, filter 0.08s;
}

.scada-btn:hover {
    filter          : brightness(1.18);
    box-shadow      : 0 3px 9px rgba(0,0,0,0.65),
                      0 1px 0 rgba(255,255,255,0.12) inset;
}

.scada-btn:active {
    transform       : translateY(1px);
    box-shadow      : 0 1px 2px rgba(0,0,0,0.4);
    filter          : brightness(0.93);
}

/* Compact / mobile */
.scada-compact .scada-indicator,
.scada-compact .scada-btn {
    min-height      : 32px;
    font-size       : 0.7rem;
    padding         : 0 8px;
}

/* -------------------------------------------------------
   RANGE — progress bar & slider
   ------------------------------------------------------- */
.scada-range {
    display         : flex;
    align-items     : center;
    gap             : 4px;
    width           : 100%;
    padding         : 3px 4px;
    box-sizing      : border-box;
}

.scada-min,
.scada-max {
    flex            : 0 0 4.5rem;
    font-size       : 0.63rem;
    color           : #666;
    white-space     : nowrap;
    overflow        : hidden;
    text-overflow   : ellipsis;
    line-height     : 1.2;
}
.scada-min { text-align: right;  }
.scada-max { text-align: left;   }

.scada-progress {
    flex            : 1;
    height          : 22px;
    border-radius   : 4px;
    background-color: #1a1a2e;
    border          : 1px solid #2e2e4a;
    overflow        : hidden;
    min-width       : 40px;
}

.scada-progress .progress-bar {
    transition      : width 0.35s ease;
    font-size       : 0.68rem;
    font-weight     : 600;
    display         : flex;
    align-items     : center;
    justify-content : center;
    white-space     : nowrap;
    min-width       : 2rem;
}

.scada-slider {
    flex            : 1;
    accent-color    : #0d6efd;
    cursor          : pointer;
    height          : 6px;
    min-width       : 40px;
}

.scada-badge {
    flex            : 0 0 3.5rem;
    font-size       : 0.68rem;
    text-align      : center;
    padding         : 2px 4px;
    white-space     : nowrap;
}

/* Toggle (switch) */
.scada-toggle {
    display         : flex;
    align-items     : center;
    gap             : 8px;
    padding         : 3px 6px;
    width           : 100%;
    box-sizing      : border-box;
}
.scada-toggle label {
    color           : #c8d0e0;
    font-size       : 0.78rem;
    cursor          : pointer;
    white-space     : nowrap;
    flex            : 1;
}
.scada-toggle .form-check-input { cursor:pointer; flex-shrink:0; }

/* ============================================================
   Login Modal — prevent iOS zoom
   ============================================================ */
@supports (-webkit-touch-callout: none) {
    .modal input[type="text"],
    .modal input[type="password"] { font-size: 16px !important; }
}

/* ============================================================
   Notifications — Navbar
   ============================================================ */
#ntf { position: relative; }

#ntf_btn {
    position        : relative;
    padding         : 0.5rem 0.75rem;
    background      : transparent;
    border          : none;
    color           : #fff;
    transition      : background-color 0.2s;
}
#ntf_btn:hover { background-color:rgba(255,255,255,0.1); border-radius:4px; }
#ntf_btn i     { font-size:1.25rem; }

#ntf_btn.has-alerts i { animation: bell-shake 1.8s ease infinite; }

@keyframes bell-shake {
    0%, 90%, 100% { transform: rotate(0deg);   }
    92%           { transform: rotate(-12deg);  }
    96%           { transform: rotate(12deg);   }
    98%           { transform: rotate(-8deg);   }
}

#ntf_lt_nb, #ntf_td_nb {
    min-width:20px; height:20px; padding:0 6px;
    font-size:0.7rem; line-height:20px; text-align:center;
    border-radius:10px; font-weight:bold;
}
#ntf_lt_nb { background-color:#dc3545 !important; color:white !important; }
#ntf_td_nb { background-color:#ffc107 !important; color:#000   !important; }

#ntf_lst {
    max-height:400px; overflow-y:auto; overflow-x:hidden;
    min-width:320px; max-width:400px; padding:0;
}
#ntf_lst::-webkit-scrollbar       { width:8px; }
#ntf_lst::-webkit-scrollbar-track { background:#1a1a1a; }
#ntf_lst::-webkit-scrollbar-thumb { background:#555; border-radius:4px; }
#ntf_lst::-webkit-scrollbar-thumb:hover { background:#777; }

#ntf_lst li { border-bottom:1px solid rgba(255,255,255,0.1); list-style:none; }
#ntf_lst li:last-child { border-bottom:none; }

#ntf_lst .dropdown-item { white-space:normal; padding:0.75rem 1rem; word-wrap:break-word; }
#ntf_lst .dropdown-item:hover        { background-color:rgba(255,255,255,0.1); }
#ntf_lst .dropdown-item.text-warning { color:#ffc107 !important; }
#ntf_lst .dropdown-item.text-danger  { color:#dc3545 !important; }
#ntf_lst .fw-bold  { font-weight:600 !important; margin-bottom:0.25rem; display:block; }
#ntf_lst small     { font-size:0.85rem; opacity:0.9; line-height:1.4; }

@media (max-width: 767px) {
    #ntf_btn   { padding:0.5rem; }
    #ntf_btn i { font-size:1.1rem; }
    #ntf_lt_nb, #ntf_td_nb { min-width:18px; height:18px; font-size:0.65rem; line-height:18px; padding:0 5px; }
    #ntf_lst {
        max-height:300px; min-width:280px;
        max-width:calc(100vw - 2rem); right:-10px !important;
    }
    #ntf_lst .dropdown-item { padding:0.625rem 0.875rem; font-size:0.9rem; }
    #ntf_lst small { font-size:0.8rem; }
}

@media (max-width: 375px) {
    #ntf_lst { min-width:260px; max-width:calc(100vw - 1rem); }
    #ntf_lst .dropdown-item { padding:0.5rem 0.75rem; font-size:0.85rem; }
}

#ntf[style*="display: none"] { display:none !important; }