/* ═══════════════════════════════════════════════════════
   DIEG Control Panel — Industrial / Command Center
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-base: #070b09;
    --bg-surface: #0d1410;
    --bg-card: #111a15;
    --bg-card-hover: #162019;
    --bg-input: #0a110e;
    --border: #1e2e25;
    --border-light: #2a3d32;

    --green-primary: #00e676;
    --green-dim: #00c853;
    --green-muted: #1b5e20;
    --green-glow: rgba(0, 230, 118, 0.15);
    --green-subtle: rgba(0, 230, 118, 0.06);

    --amber: #ffab00;
    --red: #ff5252;
    --blue: #40c4ff;

    --text: #d5e0d9;
    --text-dim: #7a8f82;
    --text-muted: #4a5e52;
    --white: #eaf2ec;

    --font-mono: 'IBM Plex Mono', 'Cascadia Code', monospace;
    --font-sans: 'IBM Plex Sans', -apple-system, sans-serif;

    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-w: 240px;
    --navbar-h: 56px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Scanline overlay — subtle CRT feel */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

/* ─── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-muted); }

/* ─── Navbar ────────────────────────────────────────── */
.dg-navbar {
    height: var(--navbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.dg-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--green-primary);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

.dg-brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green-primary);
    box-shadow: 0 0 8px var(--green-primary), 0 0 20px rgba(0, 230, 118, 0.3);
    animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green-primary), 0 0 20px rgba(0, 230, 118, 0.3); }
    50% { opacity: 0.5; box-shadow: 0 0 4px var(--green-primary), 0 0 10px rgba(0, 230, 118, 0.1); }
}

.dg-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dg-user {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.dg-btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: var(--transition);
}
.dg-btn-logout:hover {
    border-color: var(--red);
    color: var(--red);
}

.dg-hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
}

/* ─── Layout ────────────────────────────────────────── */
.dg-wrapper {
    display: flex;
    min-height: calc(100vh - var(--navbar-h));
}

/* ─── Sidebar ───────────────────────────────────────── */
.dg-sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    position: sticky;
    top: var(--navbar-h);
    height: calc(100vh - var(--navbar-h));
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.dg-nav-section {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 0 12px;
    margin: 20px 0 8px;
}

.dg-nav-section:first-child { margin-top: 0; }

.dg-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.dg-nav-link:hover {
    background: var(--green-subtle);
    color: var(--text);
}

.dg-nav-link.active {
    background: var(--green-glow);
    color: var(--green-primary);
}

.dg-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--green-primary);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.5);
}

.dg-nav-link i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
}

/* ─── Sidebar Footer ────────────────────────────────── */
.dg-sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.dg-sidebar-footer-dept {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.5;
    margin-bottom: 6px;
}

.dg-sidebar-footer-author {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 600;
}

.dg-sidebar-footer-email {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Main Content ──────────────────────────────────── */
.dg-main {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

/* ─── Page Header ───────────────────────────────────── */
.dg-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.dg-page-title {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    margin: 0;
    letter-spacing: 0.5px;
}

.dg-page-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Status Pill ───────────────────────────────────── */
.dg-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.dg-status-pill.online {
    background: rgba(0, 230, 118, 0.1);
    color: var(--green-primary);
    border: 1px solid rgba(0, 230, 118, 0.2);
}

.dg-status-pill.offline {
    background: rgba(255, 82, 82, 0.1);
    color: var(--red);
    border: 1px solid rgba(255, 82, 82, 0.2);
}

.dg-status-pill.starting {
    background: rgba(255, 171, 0, 0.1);
    color: var(--amber);
    border: 1px solid rgba(255, 171, 0, 0.2);
}

.dg-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.online .dg-status-dot {
    box-shadow: 0 0 6px currentColor;
    animation: breathe 2s ease-in-out infinite;
}

/* ─── KPI Cards ─────────────────────────────────────── */
.dg-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.dg-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: var(--transition);
}

.dg-kpi:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.dg-kpi-label {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.dg-kpi-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
}

.dg-kpi-value.green { color: var(--green-primary); }
.dg-kpi-value.amber { color: var(--amber); }
.dg-kpi-value.red { color: var(--red); }
.dg-kpi-value.blue { color: var(--blue); }

/* ─── Cards ─────────────────────────────────────────── */
.dg-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.dg-card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
}

.dg-card-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.dg-card-body {
    padding: 16px;
}

/* ─── Buttons ───────────────────────────────────────── */
.dg-btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.dg-btn-sm {
    padding: 5px 10px;
    font-size: 0.72rem;
}

.dg-btn-primary {
    background: var(--green-primary);
    color: var(--bg-base);
    border-color: var(--green-primary);
}
.dg-btn-primary:hover {
    background: var(--green-dim);
    box-shadow: 0 0 16px rgba(0, 230, 118, 0.3);
}

.dg-btn-danger {
    background: transparent;
    color: var(--red);
    border-color: rgba(255, 82, 82, 0.3);
}
.dg-btn-danger:hover {
    background: rgba(255, 82, 82, 0.1);
    border-color: var(--red);
}

.dg-btn-warning {
    background: transparent;
    color: var(--amber);
    border-color: rgba(255, 171, 0, 0.3);
}
.dg-btn-warning:hover {
    background: rgba(255, 171, 0, 0.1);
    border-color: var(--amber);
}

.dg-btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border);
}
.dg-btn-ghost:hover {
    background: var(--green-subtle);
    color: var(--text);
    border-color: var(--border-light);
}

.dg-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.dg-btn-block { width: 100%; justify-content: center; }

/* ─── Log Terminal ──────────────────────────────────── */
.dg-terminal {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--green-primary);
    padding: 12px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.dg-terminal-sm { max-height: 200px; }
.dg-terminal-full { height: calc(100vh - 200px); }

/* ─── Tables ────────────────────────────────────────── */
.dg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.dg-table th {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.dg-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.dg-table tr:hover td {
    background: var(--green-subtle);
}

/* ─── Form Inputs ───────────────────────────────────── */
.dg-input,
.dg-textarea,
.dg-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 8px 12px;
    width: 100%;
    transition: var(--transition);
}

.dg-input:focus,
.dg-textarea:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.1);
}

.dg-input-sm { padding: 5px 8px; font-size: 0.8rem; }

.dg-textarea { resize: vertical; min-height: 60px; }

.dg-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.dg-checkbox {
    accent-color: var(--green-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ─── Badges ────────────────────────────────────────── */
.dg-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.dg-badge-green {
    background: rgba(0, 230, 118, 0.15);
    color: var(--green-primary);
}

.dg-badge-red {
    background: rgba(255, 82, 82, 0.15);
    color: var(--red);
}

.dg-badge-gray {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

/* ─── Alert ─────────────────────────────────────────── */
.dg-alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    margin-bottom: 16px;
    border: 1px solid;
}

.dg-alert-success {
    background: rgba(0, 230, 118, 0.08);
    border-color: rgba(0, 230, 118, 0.2);
    color: var(--green-primary);
}

.dg-alert-danger {
    background: rgba(255, 82, 82, 0.08);
    border-color: rgba(255, 82, 82, 0.2);
    color: var(--red);
}

/* ─── Grid helpers ──────────────────────────────────── */
.dg-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.dg-grid-sidebar {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
}

/* ─── File list (relatórios) ────────────────────────── */
.dg-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dg-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-dim);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.dg-file-item:hover {
    background: var(--green-subtle);
    color: var(--green-primary);
}

.dg-file-item.active {
    background: var(--green-glow);
    color: var(--green-primary);
}

.dg-file-icon { font-size: 1rem; flex-shrink: 0; }
.dg-file-icon.pdf { color: var(--red); }
.dg-file-icon.csv { color: var(--green-primary); }
.dg-file-icon.txt { color: var(--blue); }
.dg-file-icon.html { color: var(--amber); }

/* ─── Section dividers ──────────────────────────────── */
.dg-section {
    margin-bottom: 16px;
}

.dg-section-title {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ─── Grupo list (dashboard) ────────────────────────── */
.dg-grupo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

.dg-grupo-item:last-child { border-bottom: none; }

/* ─── Login ─────────────────────────────────────────── */
.dg-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(0, 230, 118, 0.04) 0%, transparent 60%),
        var(--bg-base);
}

.dg-login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
}

.dg-login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.dg-login-brand h1 {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--green-primary);
    letter-spacing: 4px;
    margin: 0 0 4px;
}

.dg-login-brand p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

.dg-login-field {
    margin-bottom: 16px;
}

.dg-login-error {
    background: rgba(255, 82, 82, 0.1);
    border: 1px solid rgba(255, 82, 82, 0.2);
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--red);
    font-size: 0.8rem;
    margin-bottom: 16px;
    text-align: center;
}

/* ─── Frases category colors ────────────────────────── */
.dg-frase-label.excelente { color: var(--green-primary); }
.dg-frase-label.boa { color: var(--blue); }
.dg-frase-label.atencao { color: var(--amber); }
.dg-frase-label.critico { color: var(--red); }

/* ─── Responsive overlay ────────────────────────────── */
.dg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 49;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .dg-hamburger { display: block; }

    .dg-sidebar {
        position: fixed;
        top: var(--navbar-h);
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
    }

    .dg-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .dg-overlay.open { display: block; }

    .dg-main { padding: 16px; }

    .dg-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dg-grid-2 { grid-template-columns: 1fr; }
    .dg-grid-sidebar { grid-template-columns: 1fr; }

    .dg-page-header {
        flex-direction: column;
    }

    .dg-table { font-size: 0.75rem; }
    .dg-table th, .dg-table td { padding: 6px 8px; }

    .dg-terminal-full { height: calc(100vh - 240px); }
}

@media (max-width: 480px) {
    .dg-kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .dg-kpi { padding: 12px; }
    .dg-kpi-value { font-size: 1.2rem; }

    .dg-login-card { padding: 28px 20px; }
    .dg-user { display: none; }
}
