/* EHSIA CSS — scoped to #page-ehsia */
/* ============================================================
   EHSIA – assets/css/variables.css
   Design tokens & CSS custom properties
   ============================================================ */

:root {
    /* Brand Palette */
    --twine:         #c0a463;
    --laurel:        #6a9a75;
    --cutty-sark:    #54857a;
    --tarawera:      #0a425c;
    --matisse:       #177d90;
    --teal-blue:     #043c54;
    --flamingo:      #ec642c;
    --sea-green:     #2f7c46;

    /* Semantic Colours */
    --primary:       var(--matisse);
    --primary-dark:  var(--teal-blue);
    --secondary:     var(--cutty-sark);
    --success:       var(--sea-green);
    --warning:       var(--twine);
    --danger:        var(--flamingo);
    --info:          var(--laurel);
    --dark:          var(--tarawera);

    /* Neutrals */
    --light:         #f8fafc;
    --white:         #ffffff;
    --border:        #e2e8f0;
    --action-bg:     #e0f2fe;

    /* Shadows */
    --shadow:        0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:     0 4px 16px rgba(0,0,0,0.12);

    /* Radii */
    --radius:        6px;
    --radius-lg:     8px;

    /* Transitions */
    --transition:    all 0.2s ease;
    --portal-transition: all 0.3s ease;

    /* Gradients */
    --gradient-primary:   linear-gradient(135deg, var(--primary)  0%, var(--teal-blue)  100%);
    --gradient-secondary: linear-gradient(135deg, var(--secondary) 0%, var(--cutty-sark) 100%);
    --gradient-success:   linear-gradient(135deg, var(--success)   0%, var(--sea-green)  100%);
    --gradient-warning:   linear-gradient(135deg, var(--warning)   0%, var(--twine)      100%);
    --gradient-danger:    linear-gradient(135deg, var(--danger)    0%, var(--flamingo)   100%);
    --gradient-info:      linear-gradient(135deg, var(--info)      0%, var(--laurel)     100%);
}

/* ============================================================
   EHSIA – assets/css/base.css
   Reset, body, global typography
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

#page-ehsia {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg0);
    min-height: 100vh;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark);
}

#page-ehsia .hidden { display: none !important; }

/* Scrollbar */
#page-ehsia ::-webkit-scrollbar { height: 8px; width: 8px; }
#page-ehsia ::-webkit-scrollbar-track { background: var(--light); }
#page-ehsia ::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 4px; }
#page-ehsia ::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

/* ============================================================
   EHSIA – assets/css/layout.css
   Main container, header, menu bars, content areas
   ============================================================ */

/* ── Logo watermarks ──────────────────────────────────────── */
#page-ehsia .logo, #page-ehsia .logo2 {
    position: fixed; top: -50px; width: 300px; height: 300px;
    z-index: 9999; pointer-events: none;
    background-image: none; background-size: contain;
    background-repeat: no-repeat; background-position: center;
}
#page-ehsia .logo { left: 80px; }
#page-ehsia .logo2 { top: -99px; right: 10px; width: 400px; height: 400px; }

/* ── Main Container ───────────────────────────────────────── */
#page-ehsia .container {
    max-width: 1920px; width: 100%; margin: 0 auto;
    background: rgba(255,255,255,0.95);
    border-radius: 12px; box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    aspect-ratio: 16/9;
    min-height: 85vh; max-height: calc(100vh - 20px);
    display: flex; flex-direction: column; overflow: hidden;
    border: 2px solid rgba(255,255,255,0.2);
}

/* ── Header ───────────────────────────────────────────────── */
#page-ehsia .header {
    background: var(--gradient-primary); color: var(--white);
    padding: 8px 20px; text-align: center;
    border-radius: 12px 12px 0 0;
    position: relative; overflow: hidden;
    border-bottom: 2px solid var(--primary-dark);
}
#page-ehsia .header::before {
    content: ''; position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='m36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    opacity: 0.3;
}
#page-ehsia .header-content { display: flex; align-items: center; gap: 20px; position: relative; z-index: 2; }
#page-ehsia .header-text { flex: 1; }
#page-ehsia .header-text h1 { font-size: 1.8em; margin-bottom: 8px; text-shadow: 0 2px 4px rgba(0,0,0,0.3); font-weight: 700; }
#page-ehsia .header-text p { font-size: 1em; opacity: 0.9; font-weight: 500; }

/* ── Menu Bars ────────────────────────────────────────────── */
#page-ehsia .main-menu, #page-ehsia .sub-menu {
    background: var(--light); padding: 10px;
    display: flex; justify-content: space-between;
    align-items: center; gap: 10px; flex-wrap: wrap;
}
#page-ehsia .main-menu { border-bottom: 2px solid var(--primary); }
#page-ehsia .main-menu-buttons {
    display: flex; gap: 10px; flex-wrap: wrap;
    flex-grow: 1; justify-content: center;
}
#page-ehsia .form-group { margin-bottom: 0; }
#page-ehsia .action-dropdown {
    background: var(--action-bg) !important;
    border: 2px solid var(--info) !important;
    padding: 6px; border-radius: 4px;
}

/* ── Content Panels ───────────────────────────────────────── */
#page-ehsia .main-content {
    display: none; flex: 1; overflow-y: hidden; padding: 0;
    background-color: #f0f4f8; flex-direction: column;
}
#page-ehsia .main-content.active { display: flex; }
#page-ehsia .sub-content { display: none; flex-grow: 1; padding: 15px; overflow-y: auto; }
#page-ehsia .sub-content.active { display: block; }

/* ── EHSIA Dashboard Grid ─────────────────────────────────── */
#page-ehsia .dashboard-grid {
    display: grid;
    grid-template-columns: 3fr 1fr;
    grid-template-rows: repeat(2, 1fr);
    gap: 20px; height: 100%; padding: 20px;
}
#page-ehsia .ehsia-dashboard-card {
    background: var(--white); border-radius: var(--radius-lg);
    padding: 20px; box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex; flex-direction: column;
}
#page-ehsia .ehsia-dashboard-card h2 {
    color: var(--primary); font-size: 1.3em;
    font-weight: 700; margin-bottom: 20px; text-align: center;
}
#page-ehsia .chart-canvas-container {
    flex: 1; position: relative; min-height: 0;
}
#page-ehsia .ehsia-dashboard-card .chart-canvas-container { flex-grow: 1; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) {
#page-ehsia .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        padding: 15px; gap: 15px;
    }
#page-ehsia .ehsia-dashboard-card h2 { font-size: 1.1em; margin-bottom: 15px; }
}

/* ============================================================
   EHSIA – assets/css/table.css
   Interactive data tables
   ============================================================ */

#page-ehsia .table-container {
    overflow: auto; background: var(--white);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
    border: 1px solid var(--border); flex-grow: 1; padding: 0;
}

#page-ehsia table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
#page-ehsia th, #page-ehsia td {
    padding: 8px 10px; text-align: left;
    border: 1px solid var(--border); vertical-align: middle;
    color: var(--dark); min-width: 50px;
}
#page-ehsia th {
    background: var(--gradient-primary); color: var(--white);
    font-weight: 700; position: sticky; top: 0; z-index: 10; text-align: center;
}
#page-ehsia tbody tr:nth-child(even) { background-color: #f8fafc; }
#page-ehsia tr:hover { background-color: rgba(23,125,144,0.05); }

/* ── Sticky first columns ─────────────────────────────────── */
.interactive-table thead th:first-child,
#page-ehsia .interactive-table tbody td:first-child {
    position: sticky; left: 0; background-color: #e9ecef; z-index: 5; min-width: 280px;
}
.interactive-table thead th:nth-child(2),
#page-ehsia .interactive-table tbody td:nth-child(2) {
    position: sticky; left: 280px; background-color: #f1f5f9; z-index: 5; text-align: center;
}

/* ── Row types ────────────────────────────────────────────── */
#page-ehsia .interactive-table .section-row     td { background-color: var(--primary-dark); color: var(--white); font-weight: bold; font-size: 14px; }
#page-ehsia .interactive-table .sub-section-row td { background-color: var(--primary);      color: var(--white); font-weight: bold; }
#page-ehsia .interactive-table .indented-row td:first-child { padding-left: 30px; }
#page-ehsia .calculated-section-row td { background-color: var(--primary); color: var(--white); font-weight: bold; }
#page-ehsia .calculated-cell { text-align: right; font-weight: bold; }

/* ── Editable data cells ──────────────────────────────────── */
#page-ehsia .data-cell { position: relative; cursor: pointer; text-align: right; min-width: 120px; }
#page-ehsia .data-cell:hover { background-color: #e0f2fe; }
#page-ehsia .data-cell.empty:hover::after {
    content: 'Click to enter'; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%,-50%);
    color: #999; font-style: italic; font-size: 10px;
}
#page-ehsia .data-cell .cell-value { display: block; width: 100%; height: 100%; padding-right: 35px; }
#page-ehsia .data-cell input {
    width: 100%; border: 1px solid var(--primary); padding: 6px;
    text-align: right; font-size: 12px; font-family: inherit;
    border-radius: 3px; background-color: #fff;
    position: absolute; top: 0; left: 0; height: 100%;
}
#page-ehsia .data-cell .cell-actions {
    position: absolute; top: 50%; right: 5px; transform: translateY(-50%);
    display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s ease;
}
#page-ehsia .data-cell.has-data:hover .cell-actions { opacity: 1; }
#page-ehsia .cell-actions button {
    background: none; border: none; cursor: pointer;
    padding: 2px; font-size: 12px; line-height: 1;
}
#page-ehsia .cell-actions button:hover { transform: scale(1.2); color: var(--primary); }

/* ============================================================
   EHSIA – assets/css/components.css
   Buttons, plant selector, loading spinner
   ============================================================ */

/* ── Buttons ──────────────────────────────────────────────── */
#page-ehsia .main-menu-btn, #page-ehsia .sub-menu-btn {
    padding: 8px 20px; border: 2px solid var(--primary);
    background: var(--white); color: var(--primary);
    border-radius: var(--radius); font-weight: 600;
    cursor: pointer; transition: var(--transition);
    font-size: 14px; text-align: center; min-width: 220px;
    font-family: inherit; box-shadow: 0 2px 6px rgba(23,125,144,0.1);
}
#page-ehsia .sub-menu-btn { min-width: 180px; font-size: 13px; padding: 7px 18px; }

#page-ehsia .main-menu-btn:hover, #page-ehsia .sub-menu-btn:hover {
    background: rgba(23,125,144,0.1);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(23,125,144,0.2);
}
#page-ehsia .main-menu-btn.active, #page-ehsia .sub-menu-btn.active {
    background: var(--gradient-primary); color: var(--white);
    box-shadow: var(--shadow); border-color: var(--primary-dark);
}

#page-ehsia .btn-camera {
    background: none; border: 1px solid var(--primary); color: var(--primary);
    border-radius: 4px; cursor: pointer; padding: 0 5px; font-size: 14px;
    height: 24px; display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
#page-ehsia .btn-camera:hover { background: var(--primary); color: var(--white); }

/* ── Plant Selector Overlay ───────────────────────────────── */
#page-ehsia .plant-selector-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--gradient-primary);
    z-index: 10000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: white; text-align: center;
}
#page-ehsia .plant-selector-title h1 {
    font-size: 2.5em; margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
#page-ehsia .plant-selector-title p { font-size: 1.2em; margin-bottom: 40px; opacity: 0.9; }
#page-ehsia .plant-options-container { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; }

#page-ehsia .plant-card {
    background: rgba(255,255,255,0.95); color: var(--dark);
    border-radius: 15px; padding: 30px; width: 280px;
    text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border: 2px solid transparent; transition: all 0.3s ease;
    cursor: pointer; backdrop-filter: blur(5px);
}
#page-ehsia .plant-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3); background: white;
}
#page-ehsia .plant-card-logo { font-size: 3em; margin-bottom: 15px; font-weight: 800; }
#page-ehsia .plant-card h2 { color: var(--primary); font-size: 1.8em; margin-bottom: 5px; }
#page-ehsia .plant-card span { color: var(--secondary); font-size: 0.9em; font-weight: 600; }

#page-ehsia .back-to-portal-btn {
    margin-top: 40px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white; padding: 10px 20px;
    border-radius: 20px; cursor: pointer;
    font-size: 1rem; font-weight: 500; transition: all 0.3s ease;
}
#page-ehsia .back-to-portal-btn:hover { background: rgba(255,255,255,0.25); }

/* ── Loading Spinner ──────────────────────────────────────── */
#page-ehsia .loading-overlay {
    position: fixed; inset: 0; background: rgba(10,66,92,0.7);
    z-index: 99999; display: flex; flex-direction: column;
    align-items: center; justify-content: center; color: white;
}
#page-ehsia .loading-overlay.hidden { display: none; }
#page-ehsia .spinner {
    width: 48px; height: 48px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notification ───────────────────────────────────── */
#page-ehsia #ehsia-toast {
    position: fixed; bottom: 24px; right: 24px; z-index: 99998;
    background: var(--dark); color: white;
    padding: 12px 20px; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); font-size: 14px;
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none; max-width: 320px;
}
#page-ehsia #ehsia-toast.show { opacity: 1; transform: translateY(0); }
#page-ehsia #ehsia-toast.success { background: var(--success); }
#page-ehsia #ehsia-toast.error { background: var(--danger); }
#page-ehsia #ehsia-toast.info { background: var(--primary); }

