/* styles.css — EasyBMS Dashboard Design */

body {
    font-family: sans-serif;
    margin: 0;
    padding: 1em;
    background: #f5f5f5;
    color: #333;
}

    /* Force the page content background to be light/white so only the header is green */
    body {
        background: #ffffff !important;
    }

.topbar {
    margin-bottom: 1em;
}

.topbar a {
    color: #2e7d32;
    text-decoration: none;
    margin-left: 1em;
}

h1 {
    color: #2e7d32;
    margin-bottom: 1em;
}

/* Top layout */
.top-section {
    display: flex;
    align-items: flex-start;
    gap: 1em;
    margin-bottom: 1em;
}

.pack-chart-box {
    flex: 0 0 auto;
    width: 20cm;
    height: 4cm;
    background: #fff;
    padding: 0.5em;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}


.gauge-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.gauge-box .gauge-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    font-size: 1.5em;
    font-weight: bold;
    color: #2e7d32;
}

.gauge-box .gauge-sub {
    position: absolute;
    top: calc(50% + 1.4em);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
}

.info-panels {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5em;
}

.info-panel {
    background: #e0e0e0;
    color: #333;
    padding: 0.8em;
    border-radius: 6px;
    text-align: center;
}

.info-panel .title {
    font-size: 0.85em;
    text-transform: uppercase;
    color: #555;
}

.info-panel .value {
    margin-top: 0.3em;
    font-size: 1.2em;
    font-weight: bold;
}

/* Grid layout below top */
.container {
    display: grid;
    grid-template-areas:
        "switch alarm"
        "basic  cell"
        "device device";
    grid-gap: 1em;
}

.switch-status { grid-area: switch; background:#fff; padding:1em; border-radius:6px; }
.alarm-protect { grid-area: alarm;  background:#fff; padding:1em; border-radius:6px; }
.basic-info    { grid-area: basic;  background:#fff; padding:1em; border-radius:6px; }
.cell-voltage  { grid-area: cell;   background:#fff; padding:1em; border-radius:6px; }
.device-info   { grid-area: device; background:#fff; padding:1em; border-radius:6px; }

.status-list div {
    background: #c8e6c9;
    padding: 6px;
    margin: 4px 0;
    border-radius: 4px;
    color: #333;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5em;
}

th, td {
    border: 1px solid #ddd;
    padding: 6px;
    text-align: left;
}

th {
    background: #f0f0f0;
}

/* Styles moved from backup.php */
.message {
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.card {
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group select, .form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
    .btn {
        display: inline-block;
        padding: 14px 22px; /* increased padding for larger buttons */
        background-color: #4CAF50;
        color: white;
        text-decoration: none;
        border-radius: 8px; /* more rounded */
        border: none;
        cursor: pointer;
        margin-right: 8px;
        margin-bottom: 8px;
        font-size: 1rem; /* larger font-size */
    }
}

.btn-primary { background-color: #4CAF50; }
.btn-secondary { background-color: #6c757d; }
.btn-sm { padding: 5px 10px; font-size: 0.9em; }
.btn-warning { background-color: #ffc107; color: #212529; }
.btn-danger { background-color: #dc3545; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px; text-align: left; border-bottom: 1px solid #ddd; }
.table th { background-color: #f2f2f2; }

/* File selection specific styles (from backup.php) */
.selection-container { display: flex; flex-direction: column; gap: 20px; }
.selection-column { width: 100%; }
.file-list-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #f9f9f9;
    /* Use a responsive approach: limit width to 15cm but allow shrinking */
    max-width: 15cm;
    width: 100%;
    box-sizing: border-box;
    writing-mode: horizontal-tb !important; /* ensure horizontal text flow */
    direction: ltr !important;
}

/* Two-column grid per file row */
.file-item {
    padding: 3px 0;
    display: grid;
    grid-template-columns: 28px 1fr;
    column-gap: 8px;
    align-items: start;
    text-align: left;
}

.file-item input[type="checkbox"] {
    margin: 6px 0 0 0;
    justify-self: center;
    align-self: start;
}

.file-item label { display: block; font-weight: normal; cursor: pointer; padding-right: 6px; }

.file-name { display: block; width: 100%; white-space: normal; word-break: break-word; writing-mode: horizontal-tb !important; direction: ltr !important; }

.button-group { margin-top: 10px; }

.btn-sm { padding: 5px 10px; font-size: 0.9em; }

/* Header styles moved from header.php */


header {
    background: transparent;
    padding: 12px 16px 8px 16px;
}

.header-top {
    display: grid;
    grid-template-columns: min-content 1fr min-content;
    align-items: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 0;
}

.logo {
    width: 10cm; /* requested 10cm width */
    height: auto;
    display: block;
    margin: 0 16px 0 20px;
}

.header-text { flex: 1; text-align: center; color: #fff; }
.header-text h1 { margin: 0; color: #ffffff; font-size: 2.4em; font-weight: 700; }
.header-text .subtitle { margin: 0; color: rgba(255,255,255,0.9); font-size: 0.95em; }

.user-info { color: #fff; position: static; text-align: right; }
.user-info a { color: #fff; margin-left: 8px; }

/* Center the fullwidth nav under the header */
.fullwidth-nav .nav-links { justify-content: center; }
.fullwidth-nav { justify-content: center; }

.user-role { display: inline-block; padding: 2px 6px; background-color: rgba(0,0,0,0.15); color: white; border-radius: 4px; font-size: 0.8em; margin-left: 5px; }
.super-admin-role { background-color: #ff9800; }

nav { clear: both; margin-top: 10px; }
nav ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; text-align: center; }
nav ul li { display: inline-block; }
nav ul li a { display: inline-block; color: #ffffff; text-align: center; padding: 10px 14px; text-decoration: none; background-color: rgba(0,0,0,0.15); margin: 0 4px; border-radius: 4px; }
nav ul li a:hover { background-color: rgba(0,0,0,0.2); }
nav ul li a.active { background-color: rgba(0,0,0,0.25); }

/* Apply EasyBms branding color to the header only */
header {
    background-color: #34a853 !important;
    color: #fff !important;
}

header, header * {
    color: #fff !important;
}

/* Make nav buttons visible on the green header */
nav ul li a { background-color: rgba(255,255,255,0.12) !important; color: #fff !important; }
nav ul li a.active { background-color: rgba(255,255,255,0.18) !important; }

/* Compact header nav (matches screenshot) */
.compact-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Footer styling: match header full-bleed green and center the copyright line */
.site-footer {
    background-color: #34a853; /* same as header */
    color: #ffffff !important;
    text-align: center;
    padding: 12px 16px;
    box-sizing: border-box;
    margin-top: 1em;
    /* compensate for body padding so footer visually spans the viewport */
    position: relative;
    left: calc(-1 * (var(--body-padding, 1em)));
    width: calc(100% + (var(--body-padding, 1em) * 2));
}
.site-footer p { margin: 0; color: #ffffff; font-size: 0.95em; }

@media (max-width: 560px) {
    .site-footer { padding: 10px 8px; font-size: 0.9em; left: calc(-1 * (var(--body-padding, 8px))); width: calc(100% + (var(--body-padding, 8px) * 2)); }
}
.header-with-logo-padding {
    padding-left: calc(10cm + 40px); /* push content right of logo (logo width + some margin) */
    /* gap between green header area and page content */
    margin-bottom: 0.5cm; /* preferred spacing */
    margin-bottom: 8px;   /* fallback for environments that don't render cm units nicely */
}
.compact-nav .nav-links {
    display: inline-flex;
    gap: 12px;
    align-items: center;
}
.compact-nav .nav-links .btn {
    color: #ffffff !important; /* nav buttons should be white */
    background-color: #1b7a2a !important; /* match Backup CTA dark green */
    border-radius: 6px;
    padding: 10px 14px;
    text-decoration: none;
    font-size: 0.95em;
    margin-right: 6px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.06);
    border: none;
    min-width: 11rem; /* fixed width so buttons match visually */
    text-align: center;
}
.compact-nav .nav-links .btn + .btn {
    margin-left: 6px;
}
.compact-nav .nav-cta {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .header-with-logo-padding { padding-left: calc(8cm + 24px); }
    .compact-nav .nav-links .btn { min-width: 9.5rem; padding: 8px 12px; }
}

@media (max-width: 900px) {
    .header-with-logo-padding { padding-left: calc(6cm + 16px); }
    .logo { width: 6cm; }
    .compact-nav { flex-wrap: wrap; gap: 10px; }
    .compact-nav .nav-links { width: 100%; display: flex; justify-content: center; flex-wrap: wrap; }
    .compact-nav .nav-links .btn { min-width: 8rem; margin: 6px; }
    .compact-nav .nav-cta { width: 100%; justify-content: center; margin-top: 6px; }
}

@media (max-width: 560px) {
    /* For very small screens allow horizontal scrolling for nav */
    .compact-nav { overflow-x: auto; white-space: nowrap; }
    .compact-nav .nav-links { display: inline-flex; }
    .compact-nav .nav-links .btn { min-width: 7rem; }
    .header-with-logo-padding { padding-left: 3.5cm; }
    .logo { width: 3.5cm; }
}
.compact-nav .nav-cta .btn {
    background-color: #1b7a2a !important; /* darker green for the button */
    color: #fff !important;
    border-radius: 6px;
    padding: 8px 14px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.06);
    border: none;
}

/* hover state for nav buttons */
.compact-nav .nav-links .btn:hover,
.compact-nav .nav-cta .btn:hover {
    background-color: #155d1b !important;
}

/* ===== Header & Full-width nav: definitive layout rules ===== */
/* Make header-top span the full width of the viewport so logo can sit at the left edge */
.header-top {
    display: grid;
    grid-template-columns: auto 1fr auto; /* logo | center title | user-info */
    align-items: center; /* vertically center logo/title/user-info */
    gap: 16px;
    width: 100%;
    max-width: none; /* allow full width */
    padding: 12px 0 12px 0; /* ensure no left/right padding */
    box-sizing: border-box;
}

/* Logo stays at the left edge (in-flow) */
.logo {
    width: 10cm; /* restore requested visual size */
    height: auto;
    margin: 0; /* remove extra offsets so it sits flush on the left */
    justify-self: start;
    align-self: center; /* vertically center within header-top */
}

/* If the logo image includes built-in whitespace, nudge it left so the visible mark
   sits flush with the viewport edge. Adjust value if your logo file has different
   internal padding. */
.logo {
    margin-left: -18px;
}

/* Title centered in the middle column */
.header-text { text-align: center; align-self: start; }
.header-text h1 { margin: 0; }

/* User-info aligned to the top-right */
.user-info { justify-self: end; align-self: start; text-align: right; }

/* Make the nav a full-width row beneath the header-top. The .nav-links container
   is centered and may grow to a max-width; buttons are intrinsic width (no forced flex-grow)
   so the group visually centers across the page while occupying the full horizontal row. */
.fullwidth-nav {
    display: block;
    width: 100%;
    background: transparent;
    margin-top: 0;
    padding: 8px 12px 16px 12px;
    box-sizing: border-box;
}

.fullwidth-nav .nav-links {
    display: flex;
    gap: 12px;
    justify-content: flex-start; /* align menu to the left (start) */
    flex-wrap: wrap;
    width: 100%;
    max-width: 1400px; /* keep a comfortable maximum line length */
    margin: 0; /* align to left edge */
    padding-left: 0; /* no gutter - start at left edge */
}

/* Make the header container span to the viewport edges so it appears flush with the page left */
.header-with-logo-padding {
    width: calc(100% + 2em); /* compensate for body padding:1em on each side */
    margin-left: -1em; /* negate body left padding so header touches viewport left */
    margin-right: -1em; /* negate right padding to keep full-bleed */
    padding-left: 0; /* ensure no extra inset */
    padding-right: 0;
    box-sizing: border-box;
}

/* Buttons should keep their natural size and not stretch to fill columns */
.fullwidth-nav .nav-links .btn {
    flex: 0 0 auto; /* do not grow */
    margin: 6px 8px;
    min-width: 8rem; /* keep readable size */
}

/* Ensure header spacing */
.header-top { padding-bottom: 6px; }

/* Responsive behavior: reduce logo and allow nav to wrap on smaller screens */
@media (max-width: 1200px) {
    .logo { max-width: 180px; }
}

@media (max-width: 900px) {
    .logo { width: 6cm; max-width: 140px; }
    .header-text h1 { font-size: 1.6em; }
    .fullwidth-nav .nav-links { justify-content: center; }
}

@media (max-width: 560px) {
    .logo { width: 3.5cm; max-width: 120px; }
    .fullwidth-nav .nav-links { gap: 8px; }
    .fullwidth-nav { padding-left: 8px; padding-right: 8px; }
}

/* Final explicit header overrides to match the attached design. These
   rules are intentionally specific and placed at the end so they win
   over earlier, more generic rules. */
header.header-with-logo-padding {
    /* full-bleed header that compensates for body padding */
    margin-left: -1em !important;
    margin-right: -1em !important;
    width: calc(100% + 2em) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box;
}

/* Header top row: logo at left, title centered, user-info at top-right */
header.header-with-logo-padding .header-top {
    grid-template-columns: auto 1fr auto !important;
    /* keep grid but make items start at the top so we can place title lower */
    align-items: start !important;
    padding: 8px 12px !important; /* reduce vertical padding to compress header */
    margin: 0 !important;
}

/* Logo: slightly inset so the visible mark appears visually aligned with the edge */
header.header-with-logo-padding .logo {
    /* constrain logo height so header doesn't grow too tall; allow width to scale */
    width: auto !important;
    max-height: 90px !important;
    margin-left: 8px !important; /* small inset from the very edge */
    margin-right: 12px !important;
    justify-self: start !important;
}

/* Ensure the nav group is centered beneath the title */
header.header-with-logo-padding .fullwidth-nav {
    padding-top: 4px !important;
    padding-bottom: 8px !important;
}
header.header-with-logo-padding .fullwidth-nav .nav-links {
    justify-content: center !important;
    margin: 0 auto !important;
    padding-left: 0 !important;
    max-width: 1100px !important;
}

/* Keep welcome/user-info aligned to the top-right */
header.header-with-logo-padding .user-info {
    justify-self: end !important;
    align-self: start !important;
}

/* Make header full-bleed so the green spans the full viewport even when body has padding */
header.header-with-logo-padding {
    position: relative;
    left: calc(-1em); /* offset the body's 1em padding */
    width: calc(100% + 2em);
    box-sizing: border-box;
}

@media (max-width: 560px) {
    header.header-with-logo-padding { left: calc(-0.5em); width: calc(100% + 1em); }
}

/* Move the title visually lower in the header and reduce its size so header is compact */
header.header-with-logo-padding .header-text {
    align-self: end !important; /* place title at the bottom of the header-top row */
    padding-bottom: 6px !important;
}
header.header-with-logo-padding .header-text h1 {
    font-size: 1.9em !important; /* slightly smaller so it fits the compact header */
    margin: 0 !important;
}

/* Keep the fullwidth nav on a single centered line for wide viewports
   and prevent the .compact-nav rule from forcing large min-widths. On
   smaller screens (<900px) it will wrap/scroll as before. */
@media (min-width: 900px) {
    header.header-with-logo-padding .fullwidth-nav .nav-links {
        flex-wrap: nowrap !important; /* force single line */
        overflow-x: visible !important;
    }
    /* Override the compact-nav .btn min-width so items can fit on one line */
    header.header-with-logo-padding .fullwidth-nav .nav-links .btn {
        min-width: 8rem !important;
        margin: 6px 10px !important;
        white-space: nowrap !important;
    }
}

/* Footer: full-bleed green bar matching header styling */
.site-footer {
    background-color: #34a853 !important;
    color: #ffffff !important;
    text-align: center;
    padding: 12px 1em;
    margin-left: -1em; /* offset body padding so footer is full-bleed */
    width: calc(100% + 2em);
    box-sizing: border-box;
    position: relative;
    left: calc(-1em);
}
.site-footer p { margin: 0; font-size: 0.95em; color: rgba(255,255,255,0.95); }

@media (max-width: 560px) {
    .site-footer { padding: 10px 0.6em; left: calc(-0.5em); width: calc(100% + 1em); }
}

