@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&family=Fira+Code:wght@400;500&display=swap');

:root {
    --bg-os: #1e1e1e;
    --win-bg: rgba(37, 37, 38, 0.85);
    --win-border: rgba(255, 255, 255, 0.1);
    --title-bar: #333333;
    --taskbar-bg: #007acc;
    --text-primary: #cccccc;
    --glow-color: rgba(0, 122, 204, 0.4);
    --accent: #007acc;
}

[data-theme="dracula"] {
    --bg-os: #282a36;
    --win-bg: rgba(40, 42, 54, 0.9);
    --win-border: rgba(98, 114, 164, 0.5);
    --title-bar: #44475a;
    --taskbar-bg: #6272a4;
    --text-primary: #f8f8f2;
    --glow-color: rgba(189, 147, 249, 0.6);
    --accent: #ff79c6;
}

[data-theme="onedark"] {
    --bg-os: #282c34;
    --win-bg: rgba(40, 44, 52, 0.85);
    --win-border: rgba(171, 178, 191, 0.2);
    --title-bar: #21252b;
    --taskbar-bg: #2c313a;
    --text-primary: #abb2bf;
    --glow-color: rgba(97, 175, 239, 0.4);
    --accent: #61afef;
}

[data-theme="monokai"] {
    --bg-os: #272822;
    --win-bg: rgba(39, 40, 34, 0.9);
    --win-border: rgba(2fd, 151, 31, 0.3);
    --title-bar: #1e1f1c;
    --taskbar-bg: #75715e;
    --text-primary: #f8f8f2;
    --glow-color: rgba(253, 151, 31, 0.5);
    --accent: #e6db74;
}

[data-theme="nord"] {
    --bg-os: #2e3440;
    --win-bg: rgba(46, 52, 64, 0.9);
    --win-border: rgba(76, 86, 106, 0.6);
    --title-bar: #3b4252;
    --taskbar-bg: #434c5e;
    --text-primary: #d8dee9;
    --glow-color: rgba(136, 192, 208, 0.5);
    --accent: #88c0d0;
}

[data-theme="github-dark"] {
    --bg-os: #0d1117;
    --win-bg: rgba(13, 17, 23, 0.85);
    --win-border: rgba(48, 54, 61, 0.8);
    --title-bar: #161b22;
    --taskbar-bg: #21262d;
    --text-primary: #c9d1d9;
    --glow-color: rgba(88, 166, 255, 0.4);
    --accent: #58a6ff;
}

[data-theme="solarized-dark"] {
    --bg-os: #002b36;
    --win-bg: rgba(0, 43, 54, 0.9);
    --win-border: rgba(131, 148, 150, 0.2);
    --title-bar: #073642;
    --taskbar-bg: #073642;
    --text-primary: #839496;
    --glow-color: rgba(38, 139, 210, 0.5);
    --accent: #268bd2;
}

[data-theme="ayu-dark"] {
    --bg-os: #0f1419;
    --win-bg: rgba(15, 20, 25, 0.9);
    --win-border: rgba(230, 180, 80, 0.2);
    --title-bar: #151a1e;
    --taskbar-bg: #20272b;
    --text-primary: #b3b1ad;
    --glow-color: rgba(230, 180, 80, 0.5);
    --accent: #e6b450;
}

[data-theme="synthwave"] {
    --bg-os: #2b213a;
    --win-bg: rgba(38, 35, 53, 0.85);
    --win-border: rgba(255, 126, 219, 0.4);
    --title-bar: #241b2f;
    --taskbar-bg: #f92aad;
    --text-primary: #f92aad;
    --glow-color: rgba(255, 126, 219, 0.8);
    --accent: #36f9f6;
    text-shadow: 0 0 2px var(--glow-color);
}

[data-theme="night-owl"] {
    --bg-os: #011627;
    --win-bg: rgba(1, 22, 39, 0.9);
    --win-border: rgba(130, 170, 255, 0.2);
    --title-bar: #01111d;
    --taskbar-bg: #0b2942;
    --text-primary: #d6deeb;
    --glow-color: rgba(130, 170, 255, 0.6);
    --accent: #82aaff;
}

[data-theme="cobalt2"] {
    --bg-os: #193549;
    --win-bg: rgba(25, 53, 73, 0.9);
    --win-border: rgba(255, 198, 0, 0.3);
    --title-bar: #15232d;
    --taskbar-bg: #1f4662;
    --text-primary: #ffffff;
    --glow-color: rgba(255, 198, 0, 0.6);
    --accent: #ffc600;
}

[data-theme="material-dark"] {
    --bg-os: #212121;
    --win-bg: rgba(33, 33, 33, 0.9);
    --win-border: rgba(255, 255, 255, 0.1);
    --title-bar: #1a1a1a;
    --taskbar-bg: #2c2c2c;
    --text-primary: #eeffff;
    --glow-color: rgba(130, 170, 255, 0.3);
    --accent: #82aaff;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-os);
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
}

#os-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#taskbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--taskbar-bg);
    height: 45px;
    padding: 0 10px;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.taskbar-left, .taskbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#start-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}
#start-btn:hover {
    background: rgba(255,255,255,0.2);
}
#taskbar-windows button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    margin-right: 5px;
    cursor: pointer;
}
#theme-selector {
    background: rgba(0,0,0,0.3);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 4px;
    border-radius: 4px;
}
#clock { font-size: 14px; font-weight: 600; color: #fff; }

#start-menu {
    position: absolute;
    top: 45px;
    left: 10px;
    width: 280px;
    background: var(--win-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--win-border);
    border-radius: 0 0 8px 8px;
    padding: 10px;
    z-index: 10000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 5px;
}
#start-menu.hidden { display: none; }

.start-menu-item {
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    transition: background 0.2s;
}
.start-menu-item:hover { background: rgba(255,255,255,0.1); color: var(--accent); }

#desktop-area {
    flex: 1;
    position: relative;
    background-image: 
        linear-gradient(45deg, rgba(255,255,255,0.02) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.02) 25%, transparent 25%);
    background-size: 40px 40px;
    background-position: 0 0, 0 20px;
}

/* OKNA GLASSMORPHISM IDE */
.glass-window {
    position: absolute;
    min-width: 320px;
    min-height: 200px;
    background: var(--win-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--win-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.window-header {
    background: var(--title-bar);
    padding: 12px 18px;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--win-border);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.window-header:active { cursor: grabbing; }

.window-title {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-shadow: none;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.9;
}

.window-controls button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
    border-radius: 50%;
    width: 24px; height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s, color 0.2s;
}
.window-controls button:hover { background: rgba(255,255,255,0.1); color: #fff; }

.window-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.window-content::-webkit-scrollbar { width: 8px; }
.window-content::-webkit-scrollbar-thumb { background: var(--win-border); border-radius: 4px; }

/* IDE FORMS COMPONENTS */
.ide-panel {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--win-border);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
}
.ide-input {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--win-border);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    margin-top: 5px;
    box-sizing: border-box;
}
.ide-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 5px var(--glow-color);
}
.ide-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}
.ide-btn:hover { opacity: 0.8; }
.ide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; align-items: start; }

/* DATA CARD dla urządzeń */
.data-card {
    background: rgba(15, 15, 15, 0.6);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    border-left: 4px solid var(--accent);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}
.data-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}
.data-card .icon { color: var(--accent); font-size: 1.5rem; float: right; opacity: 0.8; }
.data-card .title { font-size: 12px; opacity: 0.8; font-family: 'Poppins', sans-serif; font-weight: 500; margin-right: 30px; }
.data-card .value { font-size: 22px; font-weight: 600; color: var(--text-primary); margin-top: 15px; font-family: 'Fira Code', monospace; }

.data-card.danger { border-color: #ff5252; border-left-color: #ff5252; background: rgba(255, 82, 82, 0.15); color: #ff5252; }
.data-card.danger .value, .data-card.danger .icon { color: #ff5252; }
.ide-list-item:hover { border-color: var(--accent); background: rgba(0, 0, 0, 0.4); }

/* GAUGE DASHBOARD */
.gauge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; padding: 20px; background: var(--bg-os); overflow-y: auto; height: calc(100% - 10px); box-sizing: border-box; }
.gauge-card { background: rgba(20, 20, 22, 0.7); border: 1px solid rgba(255,255,255,0.05); border-radius: 16px; padding: 20px 10px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 8px 25px rgba(0,0,0,0.5); position: relative; transition: transform 0.2s; }
.gauge-card:hover { transform: translateY(-3px); }
.gauge-svg-container { position: relative; width: 100%; max-width: 140px; aspect-ratio: 1/1; }
.gauge-svg { width: 100%; height: 100%; transform: rotate(0deg); }
.gauge-center { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 15px; }
.gauge-value { font-size: 24px; font-weight: 700; font-family: 'Fira Code', monospace; color: var(--text-primary); line-height: 1; text-shadow: 0 0 10px rgba(255,255,255,0.1); }
.gauge-unit { font-size: 11px; opacity: 0.6; margin-top: 4px; font-family: 'Poppins', sans-serif; }
.gauge-label { margin-top: 0px; font-size: 14px; font-weight: 600; color: var(--text-primary); opacity: 0.9; font-family: 'Poppins', sans-serif; }

/* DESKTOP UI COMPONENTS */
.desktop-icons-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    max-height: calc(100% - 40px);
    gap: 20px;
    z-index: 10;
}
.desktop-icon {
    width: 85px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
    padding: 10px 5px;
    border-radius: 8px;
    transition: background 0.2s;
    font-family: 'Poppins', sans-serif;
}
.desktop-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}
.desktop-icon i {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--accent);
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.6));
}
.desktop-icon span {
    font-size: 12px;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    word-break: break-word;
    font-weight: 500;
}

.desktop-widgets-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
    width: 180px;
}
.desktop-widget {
    background: rgba(30, 30, 32, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}
.desktop-widget:hover {
    transform: translateY(-2px);
}
.desktop-widget .gauge-card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 15px 5px;
}
.desktop-widget .gauge-card:hover {
    transform: none;
}
/* --- NEW METRICS & KIOSK EXTENSIONS --- */

/* Grouping Categories */
.dashboard-category-wrapper {
    background: rgba(20, 20, 22, 0.4);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    margin-bottom: 25px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.dashboard-category-title {
    font-size: 18px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: #64ffda;
    margin-bottom: 15px;
    padding-left: 10px;
    border-left: 4px solid #64ffda;
    opacity: 0.9;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Pulsing Alerts for Gauges */
@keyframes pulse-danger {
    0% { box-shadow: 0 8px 25px rgba(0,0,0,0.5), inset 0 0 0px rgba(255, 23, 68, 0); border-color: rgba(255,255,255,0.05); }
    50% { box-shadow: 0 8px 25px rgba(255, 23, 68, 0.4), inset 0 0 15px rgba(255, 23, 68, 0.2); border-color: rgba(255, 23, 68, 0.5); transform: scale(1.02); }
    100% { box-shadow: 0 8px 25px rgba(0,0,0,0.5), inset 0 0 0px rgba(255, 23, 68, 0); border-color: rgba(255,255,255,0.05); }
}
.gauge-pulse-danger {
    animation: pulse-danger 2s infinite ease-in-out !important;
}

/* Pure Kiosk Mode Hiding */
body.kiosk-mode #taskbar {
    display: none !important;
}
body.kiosk-mode .desktop-icons-container {
    display: none !important;
}
body.kiosk-mode #os-container {
    height: 100vh !important;
    width: 100vw !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
}
body.kiosk-mode .window {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    border-radius: 0 !important;
    transform: none !important;
    box-shadow: none !important;
}
body.kiosk-mode .window-header {
    display: none !important; /* Hide the app title bar in pure kiosk mode */
}
body.kiosk-mode .window-content {
    height: 100vh !important;
    max-height: 100vh !important;
}
/* --- MODERN SCADA DASHBOARD --- */
:root {
    --bg-main: #0a0a0c;
    --sidebar-bg: #111116;
    --accent: #64ffda;
    --text-primary: #e6f1ff;
    --text-mutted: #8892b0;
    --card-bg: rgba(255, 255, 255, 0.03);
}

body.dashboard-mode {
    background: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
    overflow: hidden;
}

#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
#sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu li {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    color: var(--text-mutted);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu li:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.sidebar-menu li.active {
    background: rgba(100, 255, 218, 0.05);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.sidebar-menu i {
    width: 20px;
    text-align: center;
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    text-align: center;
    font-family: 'Fira Code', monospace;
    color: var(--accent);
    font-size: 18px;
}

/* Main Area */
#main-content {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    position: relative;
    background: radial-gradient(circle at top right, rgba(100,255,218,0.03), transparent 40%),
                radial-gradient(circle at bottom left, rgba(100,255,218,0.02), transparent 40%);
}

.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Fixes for Dash Grid */
#dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; align-items: start; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--sidebar-bg);
    border: 1px solid rgba(100, 255, 218, 0.2);
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-mutted);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #ff5252;
}

.modal-body {
    padding: 20px;
}

/* Responsiveness */
@media (max-width: 768px) {
    #sidebar {
        width: 60px;
    }
    .nav-text {
        display: none;
    }
    .tab-content {
        padding: 15px;
    }
}
.ide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; align-items: start; }
