/* Theme Variables */
html[data-theme="light"] {
    --primary-color: #0070cc;
    --secondary-color: #2d2d2d;
    --background-color: #f8f8f8;
    --text-color: #1a1a1a;
    --card-bg: #ffffff;
    --border-color: #e6e6e6;
    --hover-color: #0051a2;
    --high-consumption-color: #cc0000;
    --danger-color: #cc0000;
    --danger-hover-color: #990000;
    --success-color: #00853e;
    --info-color: #0070cc;
    --table-header-bg: #f2f2f2;
    --notification-bg: #ffffff;
    --glow-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --card-border: 1px solid var(--border-color);
}

html[data-theme="dark"] {
    --primary-color: #00e5ff;
    --secondary-color: #6c757d;
    --background-color: #080b14;
    --text-color: #e0e0e0;
    --card-bg: rgba(13, 17, 23, 0.95);
    --border-color: rgba(0, 229, 255, 0.2);
    --hover-color: #00b8d4;
    --high-consumption-color: #ff1744;
    --danger-color: #ff1744;
    --danger-hover-color: #d50000;
    --success-color: #00e676;
    --info-color: #00e5ff;
    --table-header-bg: rgba(0, 229, 255, 0.1);
    --notification-bg: rgba(13, 17, 23, 0.95);
    --glow-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
    --card-border: 1px solid var(--border-color);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: var(--glow-shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

html[data-theme="light"] .theme-toggle .sun-icon {
    display: block;
}

html[data-theme="light"] .theme-toggle .moon-icon {
    display: none;
}

:root {
    --primary-color: #00e5ff;
    --secondary-color: #6c757d;
    --background-color: #080b14;
    --text-color: #e0e0e0;
    --card-bg: rgba(13, 17, 23, 0.8);
    --border-color: rgba(0, 229, 255, 0.2);
    --hover-color: #00b8d4;
    --high-consumption-color: #ff1744;
    --danger-color: #ff1744;
    --danger-hover-color: #d50000;
    --success-color: #00e676;
    --info-color: #00e5ff;
    --table-header-bg: rgba(0, 229, 255, 0.1);
    --notification-bg: rgba(13, 17, 23, 0.9);
    --glow-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
    --card-border: 1px solid var(--border-color);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    color: var(--text-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: var(--glow-shadow);
    border-bottom: var(--card-border);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#username {
    color: var(--text-color);
    font-weight: 500;
}

#btn-logout {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

nav button {
    background: rgba(0, 229, 255, 0.1);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    margin-left: 0.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

nav button:hover {
    background: rgba(0, 229, 255, 0.2);
    box-shadow: var(--glow-shadow);
}

nav button.active {
    background: var(--primary-color);
    color: var(--background-color);
    font-weight: bold;
    box-shadow: var(--glow-shadow);
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;  
    margin: 0 auto;
    width: 100%;
    padding-bottom: 80px; 
}

section {
    background: var(--card-bg);
    border: var(--card-border);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--glow-shadow);
}

h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 400;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

#entrada-dados form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.form-group {
    flex: 1 1 150px; 
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

input[type="date"],
input[type="text"] {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 10px;
    padding: 0.8rem;
    transition: all 0.3s ease;
}

input[type="date"]:focus,
input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: var(--glow-shadow);
    outline: none;
}

#leitura-form button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    width: 100%;
    margin-top: 1rem;
}

#leitura-form button[type="submit"]:hover {
    background-color: var(--hover-color);
}

/* --- Notification Area --- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 350px;
    min-width: 300px;
    z-index: 1100;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--notification-bg);
    backdrop-filter: blur(10px);
    border: var(--card-border);
    box-shadow: var(--glow-shadow);
}

.notification.show {
    transform: translateX(0);
}

.notification .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.notification .message {
    flex-grow: 1;
    margin-right: 0.5rem;
}

.notification .close-notification {
    background: none;
    border: none;
    color: currentColor;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.notification .close-notification:hover {
    opacity: 1;
}

.notification.success {
    background: rgba(0, 200, 83, 0.95);
    color: white;
    border: 1px solid rgba(0, 200, 83, 0.2);
}

.notification.error {
    background: rgba(255, 23, 68, 0.95);
    color: white;
    border: 1px solid rgba(255, 23, 68, 0.2);
}

.notification.info {
    background: rgba(0, 229, 255, 0.95);
    color: var(--background-color);
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.notification.update {
    background: rgba(0, 50, 100, 0.95);
    color: white;
    cursor: pointer;
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
    animation: pulse 2s infinite;
}

html[data-theme="light"] .notification.update {
    background: #0051a2;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.notification.update .message {
    font-weight: 500;
}

.notification.update:hover {
    transform: translateX(0) translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.7);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.5);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(0, 229, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 229, 255, 0);
    }
}

/* Mobile-specific notification styles */
@media (max-width: 768px) {
    .notification {
        top: auto;
        right: 0;
        bottom: 70px; /* Position above bottom navigation */
        left: 0;
        width: 92%;
        max-width: none;
        min-width: auto;
        margin: 0 auto;
        border-radius: 10px;
        transform: translateY(120%); /* Come from bottom on mobile */
        font-size: 0.85rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    }
    
    .notification.show {
        transform: translateY(0);
    }
    
    .notification.update {
        bottom: 70px; /* Keep above bottom nav */
        /* Use a more prominent animation on mobile */
        animation: mobilePulse 2s infinite;
    }
    
    /* Notifications marked as persistent won't disappear automatically */
    .notification.persistent {
        /* No auto-hide for persistent notifications */
        box-shadow: 0 -2px 15px rgba(0, 229, 255, 0.7);
    }
    
    @keyframes mobilePulse {
        0% {
            box-shadow: 0 -2px 10px rgba(0, 229, 255, 0.5);
            transform: translateY(0) scale(1);
        }
        50% {
            box-shadow: 0 -2px 15px rgba(0, 229, 255, 0.7);
            transform: translateY(0) scale(1.02);
        }
        100% {
            box-shadow: 0 -2px 10px rgba(0, 229, 255, 0.5);
            transform: translateY(0) scale(1);
        }
    }
}

/* --- End Notification Area --- */

/* --- History View Enhancements --- */
.consumo-medio {
    font-size: 0.95rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    background-color: var(--background-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.consumo-medio span {
    font-weight: bold;
    color: var(--primary-color);
}

.table-container {
    margin-top: 2rem;  
    overflow-x: auto; 
}

#historico-tabela {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
}

#historico-tabela th,
#historico-tabela td {
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    text-align: center;
    vertical-align: middle; 
}

#historico-tabela th {
    background: var(--table-header-bg);
    color: var(--primary-color);
    font-weight: 500;
    padding: 1rem;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

html[data-theme="light"] #historico-tabela th {
    background: #f2f2f2;
    color: #1a1a1a;
}

#historico-tabela td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

#historico-tabela tr:hover td {
    background: rgba(0, 229, 255, 0.05);
}

html[data-theme="light"] #historico-tabela tr:hover td {
    background: rgba(0, 0, 0, 0.05);
}

#historico-tabela td:nth-child(2), 
#historico-tabela td:nth-child(3) { 
    text-align: center;
    font-family: monospace; 
}

#historico-tabela td:nth-child(4) { 
    text-align: center;
}

.btn-remover {
    background-color: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.3rem;
    font-size: 1.1rem; 
    line-height: 1; 
    transition: color 0.2s ease;
}

.btn-remover:hover {
    color: var(--danger-hover-color);
}

.btn-remover svg {
    width: 1em; 
    height: 1em;
    vertical-align: middle; 
    fill: currentColor; 
}

.consumo-elevado {
    color: var(--high-consumption-color);
    font-weight: bold;
}

.view {
    display: none; 
}

.view.active {
    display: block; 
}

.chart-container {
    position: relative;
    height: 40vh; 
    width: 100%;
    max-width: 1000px; 
    margin: 2rem auto;
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1rem;
    border: var(--card-border);
}

.mensagem-info {
    text-align: center;
    color: var(--secondary-color);
    margin-top: 1rem;
    font-style: italic;
}

/* New Dashboard Styles */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.dashboard-header h2 {
    margin-bottom: 0;
    border-bottom: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;  
}

.dashboard-content {
    display: block;
    margin-top: 2rem;
}

.stats-card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--glow-shadow);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-item {
    flex: 1;
    min-width: 200px;
    padding: 1rem;
    background: rgba(0, 229, 255, 0.05);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-item h3 {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: normal;
    margin-bottom: 0.5rem;
}

.stat-value-container {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

#consumo-medio-valor {
    font-family: 'Roboto Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.stat-unit {
    font-size: 1rem;
    color: var(--secondary-color);
    margin-left: 0.25rem;
}

.stat-description {
    font-size: 0.85rem;
    color: var(--secondary-color);
    margin: 0;
}

html[data-theme="light"] .stat-item {
    background: rgba(0, 112, 204, 0.05);
}

html[data-theme="light"] #consumo-medio-valor {
    color: #0070cc;
}

@media (max-width: 768px) {
    .stats-card {
        flex-direction: column;
    }
    
    .stat-item {
        width: 100%;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: var(--card-border);
    border-radius: 15px;
    box-shadow: var(--glow-shadow);
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
}

.btn-primary {
    background: var(--primary-color);
    border: none;
    color: var(--background-color);
    padding: 0.7rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: var(--glow-shadow);
}

.btn-primary:hover {
    background: var(--hover-color);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}

html[data-theme="light"] .btn-primary {
    background: #0070cc;
    color: #FFFFFF;
    box-shadow: none;
}

html[data-theme="light"] .btn-primary:hover {
    background: #0051a2;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

html[data-theme="light"] .btn-secondary {
    background: #2d2d2d;
    color: #FFFFFF;
}

html[data-theme="light"] .btn-secondary:hover {
    background: #1a1a1a;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-secondary svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

#refresh-table:hover svg {
    transform: rotate(180deg);
}

/* Water Meter Reading Input Styles */
.leitura-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.metros-input,
.litros-input {
    position: relative;
    display: flex;
    align-items: center;
}

.metros-input input,
.litros-input input {
    font-family: monospace;
    font-size: 1.2rem;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    width: auto;
}

.metros-input input {
    width: 120px; 
}

.litros-input input {
    width: 60px; 
    color: #dc3545; 
}

.separator {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0 0.2rem;
}

.input-label {
    position: absolute;
    bottom: -1.4rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--secondary-color);
    white-space: nowrap;
}

.leitura-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary-color);
    font-size: 0.85rem;
    margin-top: 1.5rem;
    padding: 0.5rem;
    background-color: var(--background-color);
    border-radius: 4px;
}

.leitura-info svg {
    flex-shrink: 0;
}

/* Invalid input highlighting */
.metros-input input:invalid,
.litros-input input:invalid {
    border-color: var(--danger-color);
    background-color: rgba(220, 53, 69, 0.1);
}

.meter-reading {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.meter-reading .decimals {
    color: var(--danger-color);
}

.button-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Enhanced PlayStation-inspired styles */
html[data-theme="light"] header {
    background: #FED238;
    border-bottom: none;
}

html[data-theme="light"] header h1 {
    color: #0070cc;
    font-weight: 800;
    letter-spacing: -0.5px;
}

html[data-theme="light"] nav button {
    background: rgba(0, 112, 204, 0.1);
    color: #0070cc;
    font-weight: 500;
    border: none;
    transition: all 0.2s ease;
}

html[data-theme="light"] nav button:hover {
    background: rgba(0, 112, 204, 0.2);
    transform: translateY(-1px);
}

html[data-theme="light"] nav button.active {
    background: #0070cc;
    color: #ffffff;
}

html[data-theme="light"] .btn-primary {
    background: #0070cc;
    color: #ffffff;
    font-weight: 500;
    border: none;
    transition: all 0.2s ease;
}

html[data-theme="light"] .btn-primary:hover {
    background: #0051a2;
    transform: translateY(-2px);
}

html[data-theme="light"] .chart-container {
    background: #ffffff;
    border: 1px solid #e6e6e6;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] #historico-tabela th {
    background: #f8f8f8;
    color: #0070cc;
    font-weight: 600;
}

html[data-theme="light"] .meter-reading {
    color: #0070cc;
    font-weight: 500;
}

html[data-theme="light"] .meter-reading .decimals {
    color: #cc0000;
}

html[data-theme="light"] .modal-content {
    background: #ffffff;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .notification.success,
html[data-theme="light"] .notification.info {
    background: #0070cc;
    color: #ffffff;
    border: none;
}

html[data-theme="light"] .notification.error {
    background: #cc0000;
    color: #ffffff;
    border: none;
}

/* Enhance input styles */
html[data-theme="light"] input[type="date"],
html[data-theme="light"] input[type="text"] {
    background: #ffffff;
    border: 2px solid #e6e6e6;
    transition: all 0.2s ease;
}

html[data-theme="light"] input[type="date"]:focus,
html[data-theme="light"] input[type="text"]:focus {
    border-color: #0070cc;
    box-shadow: 0 0 0 3px rgba(0, 112, 204, 0.1);
}

/* New dashboard controls styles */
.dashboard-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.month-select,
.sector-select {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.7rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 200px;
}

html[data-theme="light"] .month-select,
html[data-theme="light"] .sector-select {
    background: #ffffff;
    color: #0070cc;
    border: 2px solid #e6e6e6;
}

.month-select:focus,
.sector-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--glow-shadow);
}

@media (max-width: 768px) {
    .dashboard-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .month-select,
    .sector-select {
        width: 100%;
        min-width: unset;
    }
}

/* Add styles for the new consumo-info section */
.consumo-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-color);
    text-align: center;
}

html[data-theme="light"] .consumo-info {
    background: #f8f8f8;
    border: 1px solid #e6e6e6;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-box {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 15px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--glow-shadow);
    backdrop-filter: blur(10px);
}

.auth-box h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    color: var(--text-color);
    text-align: center;
    margin-bottom: 1.5rem;
    border: none;
    font-size: 1.2rem;
}

.form-description {
    text-align: center;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1);
}

.password-input {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

.auth-form .btn-primary {
    width: 100%;
    margin-bottom: 1rem;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.auth-links a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.auth-links a:hover {
    color: var(--hover-color);
}

/* Updated Install Button Styles */
.install-button {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--glow-shadow);
    z-index: 1000;
    animation: slideUp 0.5s ease;
}

.install-button:hover {
    background: var(--hover-color);
    transform: translateX(-50%) translateY(-2px);
}

.install-icon {
    width: 24px;
    height: 24px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

html[data-theme="light"] .install-button {
    background: #0070cc;
    color: #ffffff;
}

html[data-theme="light"] .install-button:hover {
    background: #0051a2;
}

/* Responsive design for install button */
@media (max-width: 768px) {
    .install-button {
        bottom: 15px;
        padding: 0.7rem 1.2rem;
        font-size: 0.85rem;
    }
}

/* Bottom Navigation Bar Styles */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px; 
    background: var(--card-bg);
    border-top: var(--card-border);
    display: none; 
    align-items: stretch; 
    z-index: 899;
    backdrop-filter: blur(10px);
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    justify-content: space-between;
}

html[data-theme="light"] #bottom-nav {
    background: #ffffff;
    border-top: 1px solid #e6e6e6;
}

#bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--secondary-color);
    font-size: 0.75rem; 
    padding: 6px 0; 
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease;
    text-align: center;
}

html[data-theme="light"] #bottom-nav .nav-item {
    color: #6c757d;
}

#bottom-nav .nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px; 
    fill: currentColor;
}

#bottom-nav .nav-item:hover {
    color: var(--primary-color);
    background-color: rgba(0, 229, 255, 0.05); 
}

html[data-theme="light"] #bottom-nav .nav-item:hover {
    color: #0070cc;
    background-color: rgba(0, 112, 204, 0.05);
}

#bottom-nav .nav-item.active {
    color: var(--primary-color);
    font-weight: bold;
}

html[data-theme="light"] #bottom-nav .nav-item.active {
    color: #0070cc;
}

#bottom-btn-add {
    display: none !important;
}

@media (max-width: 480px) {
    #bottom-nav .nav-item {
        font-size: 0.65rem; 
    }

    #bottom-nav .nav-item svg {
        width: 20px; 
        height: 20px;
    }
}

/* Hide logout button in header on mobile */
@media (max-width: 768px) {
    .user-menu {
        display: none;
    }
}

/* New Mobile Header Styles */
.mobile-header {
    display: none;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 1rem;
    text-align: center;
    border-bottom: var(--card-border);
    position: sticky;
    top: 0;
    z-index: 900;
}

.mobile-header h1 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--primary-color);
    font-weight: 700;
}

html[data-theme="light"] .mobile-header {
    background: #FED238;
    border-bottom: none;
}

html[data-theme="light"] .mobile-header h1 {
    color: #0070cc;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Show mobile header */
    .mobile-header {
        display: block;
    }

    /* Adjust main padding to account for mobile header */
    main {
        padding-top: 0.5rem;
    }

    /* Hide original header and nav on small screens */
    header {
        display: none;
    }

    /* Show bottom nav on small screens */
    #bottom-nav {
        display: flex;
    }

    main {
        padding: 1rem;
        padding-bottom: 80px; 
    }
    nav {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }

    nav button {
        flex-grow: 1; 
        margin-left: 0;
        margin-right: 0.5rem; 
    }
    nav button:last-child {
        margin-right: 0;
    }

    main {
        padding: 1rem;
    }

    section {
        padding: 1rem;
    }

    #entrada-dados form {
       flex-direction: column;
       align-items: stretch; 
    }

    .form-group {
        flex-basis: auto; 
    }

    #entrada-dados button[type="submit"] {
        max-width: none; 
        width: 100%;
        margin-top: 1rem;
    }

    #historico-tabela th,
    #historico-tabela td {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .chart-container {
        height: 50vh; 
    }

    .consumo-medio {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    .dashboard-header,
    .section-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        margin-bottom: 1.5rem;  
    }

    .dashboard-header .btn-primary,
    .section-header .btn-primary {
        margin-left: 0;
        width: 100%;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
        gap: 0.8rem;  
    }

    .btn-secondary,
    .btn-primary {
        width: 100%;
        justify-content: center;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        right: 15px;
        bottom: 80px;
        padding: 8px;
    }

    .dashboard-content {
        grid-template-columns: 1fr;
    }

    .dashboard-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .month-select {
        width: 100%;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .user-menu {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }

    nav button {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }

    #historico-tabela th,
    #historico-tabela td {
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    .btn-remover {
        font-size: 1rem; 
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        right: 10px;
        bottom: 80px;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .auth-box {
        padding: 1.5rem;
    }

    .auth-box h1 {
        font-size: 1.3rem;
    }

    .auth-form h2 {
        font-size: 1.1rem;
    }
}

/* Ensure header is shown and bottom nav hidden on larger screens */
@media (min-width: 769px) {
    header {
        display: flex; 
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        padding: 1rem 2rem;
    }
    #bottom-nav {
        display: none;
    }
    main {
         padding-bottom: 2rem;
    }
}

@media (max-width: 480px) {
    #bottom-nav .nav-item {
        font-size: 0.7rem; 
    }

    #bottom-nav .nav-item svg {
        width: 22px;
        height: 22px;
    }
}

/* Loading Spinner Styles */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Button Loading State */
.btn-primary.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary.loading .button-text {
    margin-left: 8px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay .spinner-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    border: var(--card-border);
}

.loading-overlay .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
    margin-bottom: 1rem;
    border-color: var(--primary-color);
    border-top-color: transparent;
}

.loading-overlay .loading-text {
    color: var(--text-color);
    font-size: 0.9rem;
}

/* Responsive Table Styles */
@media (max-width: 768px) {
    /* Make table rows behave like cards */
    #historico-tabela {
        border: none;
        background: none;
    }

    #historico-tabela thead {
        display: none;
    }

    #historico-tabela tbody tr {
        display: block;
        background: var(--card-bg);
        border: var(--card-border);
        border-radius: 10px;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: var(--glow-shadow);
    }

    #historico-tabela tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--border-color);
        font-size: 0.9rem;
    }

    #historico-tabela tbody td:last-child {
        border-bottom: none;
    }

    /* Add labels for each cell */
    #historico-tabela tbody td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--secondary-color);
        padding-right: 1rem;
    }

    /* Single column message styling */
    #historico-tabela tbody tr td[colspan] {
        text-align: center;
        justify-content: center;
    }

    #historico-tabela tbody tr td[colspan]::before {
        display: none;
    }

    /* Meter reading specific styles */
    #historico-tabela td .meter-reading {
        font-size: 1rem;
    }

    /* Light theme specific adjustments */
    html[data-theme="light"] #historico-tabela tbody tr {
        background: #ffffff;
        border: 1px solid #e6e6e6;
    }

    html[data-theme="light"] #historico-tabela tbody td {
        border-bottom-color: #e6e6e6;
    }

    /* Add specific styles for the reading cell */
    #historico-tabela tbody td[data-label="Leitura"] {
        justify-content: space-between;
    }

    /* Style the meter reading display in mobile view */
    .meter-reading {
        text-align: right;
        white-space: nowrap;
        flex: 1;
        padding-left: 1rem; /* Add some spacing between label and value */
    }

    /* Ensure the reading and unit stay together */
    #historico-tabela td .meter-reading {
        display: inline-flex;
        align-items: center;
        gap: 2px; /* Reduce gap between number and unit */
        justify-content: flex-end;
        font-size: 0.9rem;
    }
}

/* Adjustments for form fields on mobile */
@media (max-width: 768px) {
    /* Form Field Adjustments */
    #leitura-form .form-group {
        width: 100%;
    }

    #leitura-form input[type="date"],
    #leitura-form select {
        width: 100%;
        min-width: unset;
    }

    /* Add consistent styling for the sector select within the form */
    #leitura-form .sector-select {
        width: 100%;
        min-width: unset;
        padding: 0.8rem;
        border-radius: 8px;
        margin: 0;
    }

    /* Ensure date input matches other inputs */
    #leitura-form input[type="date"] {
        padding: 0.8rem;
        border-radius: 8px;
        height: 42px; /* Match the height of select elements */
    }
}