body, html {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    font-family: '__Inter_dbf9c5', '__Inter_Fallback_dbf9c5';
    background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('Mangrove.jpg');
    width: 100%;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    color: #f0f4f1;
    line-height: 1.6;
}

.header {
    background: linear-gradient(135deg, #325947, #325947);
    color: #f0f4f1;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    font-family: 'Inter', sans-serif;
}

.header-text {
    flex-grow: 1;
    text-align: center;
}

.header h1 {
    margin: 0;
    font-size: 1.5rem;
    text-shadow: 1px 1px 2px #2f4f2f;
}

.header p {
    margin: 0.5rem 0 0;
    font-size: 1rem;
}

.container {
    flex: 1;
    padding: 2rem 2rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
}

.card {
    background-color: rgba(50, 89, 71, 0.8);
    border-radius: 16px;
    box-shadow: 0 0px 0px #325947;
    font-family: 'Inter';
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 5px solid #000000;
    min-width: 180px;
    max-width: 220px;
    flex: 1 1 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 16px rgba(46, 61, 26, 0.4);
}

.gauge-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
}

.gauge-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: stretch;
}

.gauge {
    width: 180px;
    height: 140px;
    margin: 10px auto;
}

.chart-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 2rem;
}

.chart-container .card {
    flex: 1 1 30%;
    min-width: 200px;
}

canvas {
    width: 100%;
    max-height: 300px;
    background-color: #f4e6e6;
    border-radius: 8px;
    box-shadow: inset 0 0 10px #c4d3a4;
}

.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

.history-section {
    margin-top: 3rem;
    padding: 1rem;
    background-color: rgba(50, 89, 71, 0.8);
    border-radius: 16px;
    font-family: 'Inter';
    border: 5px solid #000000;
    box-shadow: 0 0px 0px #325947;
    color: #ffffff;
}


.history-section-soil h2, .history-section-water h2 {
    text-align: center;
    margin-bottom: 1.2rem;
    font-size: 1.6rem;
    font-weight: 700;
    color: #eafbe6;
    text-shadow: 1px 1px 8px #2f4f2f;
}

.history-cards-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.history-cards-wrapper .card {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    margin-bottom: 0;
    background-color: rgba(50, 89, 71, 0.8);
    color: #eafbe6;
    border: 5px solid #000000;
    box-shadow: 0 6px 24px #2f4f2f55;
    border-radius: 16px;
    padding: 1.5rem 1rem;
}

.history-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

.history-table-wrapper table.data-table thead th {
    position: sticky;
    top: 0;
    background-color: #8fbc8f;
    z-index: 10;
}

.history-section .table-container {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
}

.history-section table.data-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

.history-section table.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #8fbc8f;
}


.history-section table.data-table thead th,
.history-section table.data-table tbody td {
    box-sizing: border-box;
    padding: 10px;
    word-wrap: break-word;
}

.history-section table.data-table thead th {
    position: sticky;
    top: 0;
    background-color: #8fbc8f;
    z-index: 11;
}

.history-section h2 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    font-weight: 700;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    box-shadow: 0 2px 6px rgba(46, 61, 26, 0.2);
    border-radius: 8px;
    background-color: #2f4f2f;
    overflow: hidden;
    color: #eafbe6;
}

.data-table th, .data-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #325947;
}

.data-table th {
    background-color: #325947;
    color: #eafbe6;
}

.data-table tr:nth-child(even) {
    background-color: #3d5c47;
    color: #eafbe6;
}

.data-table tr:nth-child(odd) {
    background-color: #264034;
    color: #eafbe6;
}

.data-table tr:hover {
    background-color: #4e7c5b;
    color: #fff;
}


footer {
    background: linear-gradient(135deg, #325947, #325947);
    color: #f0f4f1;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -2px 6px rgba(46, 61, 26, 0.15);
    font-family: 'Inter', sans-serif;
    font-style: italic;
}

.footer-text {
    flex-grow: 1;
    text-align: center;
}

footer p {
    margin: 0;
    font-size: 1rem;
}

.logo-header {
    height: 80px;
    width: fit-content;
}
.logo-footer {
    height: 40px;
    width: auto;
}

.hamburger-menu {
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-left: 1rem;
    z-index: 1001;
    background: rgba(50, 89, 71, 0.92);
    border-radius: 12px;
    box-shadow: 0 2px 8px #2f4f2f33;
    transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
    border: 2px solid #264034;
    position: relative;
}
.hamburger-menu:hover, .hamburger-menu.active {
    background: linear-gradient(135deg, #406d5a 80%, #325947 100%);
    box-shadow: 0 4px 16px #2f4f2f55;
    transform: scale(1.06) rotate(-2deg);
}
.hamburger-menu span {
    display: block;
    width: 26px;
    height: 4px;
    margin: 4px 0;
    background: #eafbe6;
    border-radius: 3px;
    box-shadow: 0 1px 4px #2f4f2f33;
    transition: all 0.3s cubic-bezier(.4,2,.6,1), background 0.2s;
}
.hamburger-menu.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}
.hamburger-menu.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.nav-drawer {
    position: fixed;
    top: 0;
    right: -220px;
    width: 200px;
    height: 100vh;
    background: #325947;
    color: #f0f4f1;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: right 0.3s;
    padding-top: 80px;
}
.nav-drawer.open {
    right: 0;
}
.nav-drawer ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.nav-drawer li {
    margin: 1.5rem 0;
    text-align: center;
}
.nav-drawer a {
    color: #f0f4f1;
    text-decoration: none;
    font-size: 1.2rem;
    font-family: 'Inter', sans-serif;
    transition: color 0.2s;
}
.nav-drawer a:hover {
    color: #8fbc8f;
}

.page-section {
    display: block;
}

.card.chart-fullwidth {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    box-sizing: border-box;
}
.card.chart-fullwidth canvas {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 320px;
}

.export-buttons {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
    margin-top: 1rem;
}

.optimal-species-card {
    width: 100%;
    max-width: 900px;
    margin: 2rem auto 0 auto;
    background-color: rgba(50, 89, 71, 0.8); /* Match main card theme */
    color: #eafbe6;
    border-radius: 14px;
    box-shadow: 0 2px 8px #2f4f2f33;
    border: 5px solid #000000;
    padding: 1.2rem 1rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Inter', sans-serif;
    transition: box-shadow 0.3s, border 0.3s;
    justify-content: center;
}

.optimal-species-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.7rem;
    font-weight: 700;
    color: #eafbe6;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 4px #2f4f2f55;
}

.optimal-species-card label {
    font-size: 1rem;
    font-weight: 600;
    color: #eafbe6;
    margin-bottom: 0.3rem;
}

.optimal-species-card select {
    width: 100%;
    max-width: 300px;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #325947;
    font-size: 1rem;
    background: #264034;
    color: #eafbe6;
    margin-bottom: 1rem;
    margin-top: 0.3rem;
    box-shadow: 0 1px 4px #2f4f2f33;
    transition: border 0.2s;
}

.optimal-species-card select:focus {
    border: 2px solid #0097a7;
    outline: none;
}

#speciesMetricsDisplay {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    margin-top: 0.7rem;
    background: transparent;
    border-radius: 10px;
    box-shadow: none;
    padding: 0.2rem 0.2rem;
    color: #eafbe6;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: center;
    align-items: stretch;
}

.species-metric-row {
    width: 150%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: justify;
    background: rgba(44, 70, 56, 0.7);
    border-radius: 8px;
    padding: .4rem 1.2rem;
    margin: 0.1rem 0;
    margin-left: -60px;
    font-size: 1rem;
    font-weight: 600;
    color: #eafbe6;
}

.species-metric-label {
    color: #8fbc8f;
    font-weight: 700;
    font-size: 1rem;
    margin-right: 1rem;
}

.species-metric-value {
    color: #eafbe6;
    font-weight: 600;
    font-size: 1rem;
    text-align: right;
}

.species-metrics-list {
    width: 100%;
    max-width: 300px; /* Match dropdown */
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.species-metrics-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
    font-size: 1rem;
    display: grid;
    grid-template-columns: 1fr; /* Single column, split by row */
    gap: 0.5rem 0;
    margin-top: 0.2rem;
    justify-items: center;
    align-items: center;
    box-sizing: border-box;
}

.species-metrics-table tr {
    display: contents;
}

.species-metrics-table th,
.species-metrics-table td {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    text-align: center;
    font-weight: 600;
    color: #eafbe6;
    font-size: 1rem;
    padding-left: 0.2rem; /* Reduce horizontal space */
    padding-right: 0.2rem; /* Reduce horizontal space */
    box-sizing: border-box;
}

.species-metrics-table th {
    font-weight: 700;
    color: #8fbc8f;
    font-size: 1rem;
    padding-right: 0.5rem;
}

.species-metrics-table td {
    font-weight: 600;
    color: #eafbe6;
    font-size: 1rem;
    padding-left: 0.5rem;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

/* Live Feed Page Styles */
.live-feed-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    height: calc(100vh - 180px);
}

.video-container {
    flex: 1;
    background: #264034;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.pump-controls {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 20px;
    background: #264034;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.pump-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 110px;
    margin: 0 10px;
}

.pump-status-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #eafbe6;
    margin-bottom: 6px;
    letter-spacing: 1px;
    text-shadow: 0 1px 4px #2f4f2f55;
    transition: color 0.2s;
}

/* Square Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 54px;
    height: 54px;
    margin-bottom: 0.2rem;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #888;
    transition: background 0.3s, box-shadow 0.3s;
    border-radius: 10px;
    box-shadow: 0 2px 8px #2f4f2f33;
    border: 2px solid #222;
}
input:checked + .slider {
    background-color: #4caf50;
    box-shadow: 0 0 8px #4caf50cc;
}
.slider:before {
    position: absolute;
    content: "";
    left: 8px;
    top: 8px;
    width: 36px;
    height: 36px;
    background-color: #fff;
    border-radius: 6px;
    transition: background 0.3s;
    box-shadow: 0 1px 4px #2f4f2f33;
}
input:checked + .slider:before {
    background-color: #eafbe6;
}

.pump-label {
    font-family: 'Inter', Arial, sans-serif;
    color: #8fbc8f;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.2rem;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 4px #2f4f2f55;
    transition: color 0.2s;
    display: block;
    text-align: center;
}

.pump-controls {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 20px;
    background: #264034;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.logout-btn {
    background: linear-gradient(135deg, #325947 80%, #406d5a 100%);
    color: #eafbe6;
    border: none;
    border-radius: 10px;
    padding: 0.55rem 1.3rem;
    font-size: 1.05rem;
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 600;
    margin-left: 1.2rem;
    box-shadow: 0 2px 8px #2f4f2f33;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    outline: none;
    letter-spacing: 0.5px;
    position: relative;
    top: 0;
    right: 0;
}
.logout-btn:hover, .logout-btn:focus {
    background: linear-gradient(135deg, #406d5a 80%, #325947 100%);
    color: #fff;
    box-shadow: 0 4px 16px #2f4f2f55;
}

/* Custom Scrollbar Styling */
body, html, .container, .gauge-container, .gauge-group, .history-section, .history-cards-wrapper, .history-table-wrapper, .table-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) rgba(255,255,255,0.05);
}

/* Chrome, Edge, Safari */
body::-webkit-scrollbar, .container::-webkit-scrollbar, .gauge-container::-webkit-scrollbar, .gauge-group::-webkit-scrollbar, .history-section::-webkit-scrollbar, .history-cards-wrapper::-webkit-scrollbar, .history-table-wrapper::-webkit-scrollbar, .table-container::-webkit-scrollbar {
    width: 6px;
    background: rgba(255,255,255,0.05);
}
body::-webkit-scrollbar-thumb, .container::-webkit-scrollbar-thumb, .gauge-container::-webkit-scrollbar-thumb, .gauge-group::-webkit-scrollbar-thumb, .history-section::-webkit-scrollbar-thumb, .history-cards-wrapper::-webkit-scrollbar-thumb, .history-table-wrapper::-webkit-scrollbar-thumb, .table-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
}
body::-webkit-scrollbar-thumb:hover, .container::-webkit-scrollbar-thumb:hover, .gauge-container::-webkit-scrollbar-thumb:hover, .gauge-group::-webkit-scrollbar-thumb:hover, .history-section::-webkit-scrollbar-thumb:hover, .history-cards-wrapper::-webkit-scrollbar-thumb:hover, .history-table-wrapper::-webkit-scrollbar-thumb:hover, .table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.35);
}

@media (max-width: 900px) { 
    .gauge-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    .gauge-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }
    .chart-container {
        flex-direction: column;
        gap: 1rem;
    }
    .history-section-soil, .history-section-water {
        padding: 1rem 0.2rem;
    }
    .history-cards-wrapper .card {
        padding: 1rem 0.5rem;
    }
    .optimal-species-card {
        max-width: 98vw;
        padding: 1.2rem 0.5rem 1.5rem 0.5rem;
    }
    #speciesMetricsDisplay {
        max-width: 98vw;
        padding: 1rem 0.5rem;
    }
}
@media (max-width: 600px) {
    .gauge-group {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    .card {
        min-width: 140px;
        max-width: 95vw;
    }
    .container {
        padding: 1rem 0.5rem 2rem;
    }
    .nav-drawer {
        width: 100vw;
        right: -100vw;
    }
    .nav-drawer.open {
        right: 0;
    }
    .optimal-species-card {
        max-width: 100vw;
        padding: 1rem 0.2rem 1.2rem 0.2rem;
    }
    #speciesMetricsDisplay {
        max-width: 100vw;
        padding: 0.7rem 0.2rem;
    }
    .species-metrics-table {
        grid-template-columns: 1fr;
    }
}
