/* 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);
}

/* Add light theme overrides */
html[data-theme="light"] .notification.success {
    background: #00c853;
    color: white;
    border: none;
}

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

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

/* --- 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 {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
}

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

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: var(--table-header-bg);
    color: var(--primary-color);
    font-weight: 500;
    padding: 1rem;
    text-align: center;
    white-space: nowrap;
}

td {
    padding: 1rem;
    vertical-align: middle;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

/* Hover effect for desktop */
@media (min-width: 769px) {
    tbody tr:hover {
        background: rgba(0, 229, 255, 0.05);
    }
    #students-table thead th:nth-child(3),
    #students-table tbody td:nth-child(3) {
        text-align: right;
        /* optional padding for visual breathing room */
        padding-right: 1rem;
    }
}

@media (max-width: 768px) {
    table thead,
    table thead tr,
    table thead th {
        display: none;
    }

    .table-container {
        border: none;
        background: none;
        box-shadow: none;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    tr {
        background: var(--card-bg);
        border: var(--card-border);
        border-radius: 10px;
        margin-bottom: 1rem;
        box-shadow: var(--glow-shadow);
        padding: 0.5rem;
    }

    td {
        border: none !important;
        position: relative;
        padding-left: calc(40% + 15px) !important;
        text-align: right !important;
        min-height: 40px;
        /* display: flex !important
; */
        align-items: center;
        justify-content: flex-end;
        border-bottom: 1px solid var(--border-color) !important;
        margin-bottom: 0.3rem;
    }

    td:last-child {
        border-bottom: none !important;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 40%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 500;
        text-align: left;
        color: var(--primary-color);
    }

    /* Special handling for demonstration and action columns */
    td[data-label="Demonstração"],
    td[data-label="Ações"] {
        padding: 1rem !important;
        justify-content: center;
        text-align: center !important;
    }

    td[data-label="Demonstração"]::before,
    td[data-label="Ações"]::before {
        position: static;
        width: auto;
        margin-bottom: 0.5rem;
        display: block;
        text-align: center;
    }

    td[data-label="Demonstração"],
    td[data-label="Ações"] {
        flex-direction: column;
    }

    /* Exercise demo image adjustments */
    .exercise-demo {
        margin: 0.5rem auto;
        max-width: 120px;
        height: auto;
    }

    /* Action buttons container */
    .action-buttons {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    /* Enhance button styling */
    .btn-danger,
    .btn-success {
        min-width: 120px;
        justify-content: center;
    }

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

    html[data-theme="light"] td::before {
        color: #0070cc;
    }

    /* Cell value alignment */
    td > *:not(.action-buttons):not(.exercise-demo):not(.status-badge) {
        max-width: 60%;
        text-align: right;
    }

    /* Status badge positioning */
    td .status-badge {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    td[data-label="Ações"] {
        padding: 0.8rem !important;
        justify-content: center !important;
        text-align: center !important;
    }

    td[data-label="Ações"]::before {
        display: block !important;
    }

    .action-buttons {
        display: flex;
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .btn-success, 
    .btn-danger {
        padding: 0.6rem 1rem;
        min-width: 100px;
        justify-content: center;
        font-size: 0.9rem;
    }

    .btn-success span, 
    .btn-danger span {
        display: inline-block;
    }

    td[data-label="Status"] {
        justify-content: flex-end;
    }

    .status-badge {
        margin: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 80px;
    }
}

@media (max-width: 768px) {
    /* Ensure the cell itself is a flex container in row direction */
    td[data-label="Ações"] {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: left !important;
        /* re-apply padding for consistency */
        padding: 0.8rem 1rem !important;
    }
    /* Render the pseudo-label inline, not block */
    td[data-label="Ações"]::before {
        content: attr(data-label);
        position: static !important;
        display: inline-block !important;
        width: auto !important;
        margin: 0 !important;
        margin-right: 0.5rem !important;
        transform: none !important;
        flex: none !important;
    }
    /* Remove extra bottom margin on the action button itself */
    td[data-label="Ações"] button,
    td[data-label="Ações"] .action-buttons {
        margin: 0 !important;
    }
}

/* Align "Demonstração" cell label and image on mobile similar to "Ações" */
@media (max-width: 768px) {
    td[data-label="Demonstração"] {
        /* make it a row flex container */
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: left !important;
        padding: 0.8rem 1rem !important;
    }
    td[data-label="Demonstração"]::before {
        /* inline‐flow the label on the left */
        position: static !important;
        display: inline-block !important;
        width: auto !important;
        margin: 0 !important;
        margin-right: 0.5rem !important;
        transform: none !important;
        content: attr(data-label);
    }
    td[data-label="Demonstração"] img,
    td[data-label="Demonstração"] .exercise-demo {
        /* ensure the demo image sits on the right without extra margin */
        margin: 0 !important;
        flex-shrink: 0;
    }
}

.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-panel,
.stat-item,
.stat-label,
.stat-value,
.stat-unit,
.stat-change {
    display: none;
}

/* 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;
    overflow-y: scroll;
    padding: 1rem;
}

.modal.active {
    display: block;
}

.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;
    margin: 2rem auto;
}

.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);
}

.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
    margin: 0 auto; 
}

.status-badge-active {
    background: rgba(0, 200, 83, 0.2);
    color: var(--success-color);
}

.status-badge-pending {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
}

.status-badge-inactive {
    background: rgba(158, 158, 158, 0.2);
    color: #9e9e9e;
}

.btn-success, .btn-danger {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.3s ease;
    border: none;
    font-size: 0.9rem;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-success:hover, .btn-danger:hover {
    transform: translateY(-2px);
}

.btn-success:hover {
    background: #00a650;
}

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

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center; 
}

.action-buttons svg {
    width: 16px;
    height: 16px;
}

.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;
}

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;
}

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);
    outline: none;
}

.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;
}

/* Enhanced Table Styles */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 1rem;
}

/* Modal Form Styles */
.modal select,
.modal input[type="number"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.modal select:focus,
.modal input[type="number"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1);
    outline: none;
}

/* Light theme adjustments */
html[data-theme="light"] .modal select,
html[data-theme="light"] .modal input[type="number"] {
    background: #ffffff;
    border: 1px solid #e6e6e6;
    color: #1a1a1a;
}

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

/* Select dropdown arrow styling */
.modal select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

/* Optgroup styling */
.modal select optgroup {
    font-weight: bold;
    color: var(--primary-color);
}

.modal select option {
    font-weight: normal;
    color: var(--text-color);
    padding: 0.5rem;
}

html[data-theme="light"] .modal select optgroup {
    color: #0070cc;
}

html[data-theme="light"] .modal select option {
    color: #1a1a1a;
}

/* Form group spacing */
.modal .form-group {
    margin-bottom: 1.2rem;
}

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

/* Notes textarea specific styling */
.modal textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: all 0.3s ease;
}

.modal textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1);
    outline: none;
}

html[data-theme="light"] .modal textarea {
    background: #ffffff;
    border: 1px solid #e6e6e6;
    color: #1a1a1a;
}

html[data-theme="light"] .modal textarea:focus {
    border-color: #0070cc;
    box-shadow: 0 0 0 2px rgba(0, 112, 204, 0.1);
}

/* Input type number specific styling */
.modal input[type="number"] {
    -moz-appearance: textfield;
}

.modal input[type="number"]::-webkit-outer-spin-button,
.modal input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Dropdown specific styles */
.form-group select {
    cursor: pointer;
}

.form-group select option {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 0.8rem;
}

html[data-theme="light"] .form-group select option {
    background: #ffffff;
    color: #1a1a1a;
}

/* Modal scrollbar styles */
.modal::-webkit-scrollbar {
    width: 8px;
}

.modal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.modal::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

html[data-theme="light"] .modal::-webkit-scrollbar-thumb {
    background: #0070cc;
}

/* Responsive modal styles */
@media (min-width: 769px) {
    .modal-content {
        margin: 2rem auto;
    }
}

@media (max-width: 768px) {
    .modal-content {
        margin: 1rem auto;
        padding: 1.5rem;
    }
}

.exercise-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.5rem;
    background: var(--background-color);
    border-radius: 8px;
}

.exercise-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.exercise-preview-info {
    flex: 1;
}

.exercise-preview-info strong {
    display: block;
    margin-bottom: 0.25rem;
}

.exercise-preview-info span {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.custom-exercise-input {
    margin-top: 1rem;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    border-radius: 8px;
    width: 100%;
    transition: all 0.3s ease;
}

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

html[data-theme="light"] .custom-exercise-input {
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid #e6e6e6;
}

html[data-theme="light"] .custom-exercise-input:focus {
    border-color: #0070cc;
    box-shadow: 0 0 0 2px rgba(0, 112, 204, 0.1);
}

/* Enhanced Workout Display Styles */
.workout-day-card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.workout-day-card h4 {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.workout-day-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.workout-day-card li {
    margin-bottom: 1rem;
}

.workout-day-card li:last-child {
    margin-bottom: 0;
}

.exercise-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.exercise-info:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-shadow);
}

.exercise-media {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.exercise-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.exercise-details {
    flex: 1;
}

.exercise-details strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}

.exercise-details span {
    display: block;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.exercise-details small {
    display: block;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* Workouts Table Enhancements */
.compact-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.compact-table th {
    background: var(--table-header-bg);
    color: var(--primary-color);
    font-weight: 500;
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.compact-table td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.compact-table tr:last-child td {
    border-bottom: none;
}

.compact-table tr:hover td {
    background: rgba(0, 229, 255, 0.05);
}

.compact-table .exercise-demo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: var(--glow-shadow);
}

/* Workout Schedule Layout */
.workout-schedule {
    margin-top: 2rem;
}

.workout-schedule h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.workout-days {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Welcome Banner Enhancement */
.welcome-banner {
    background: linear-gradient(to right, var(--primary-color), var(--hover-color));
    color: white;
    padding: 2rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    text-align: center;
}

.welcome-banner h2 {
    color: white;
    border: none;
    margin: 0;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.welcome-banner p {
    opacity: 0.9;
    margin: 0;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .workout-days {
        grid-template-columns: 1fr;
    }

    .exercise-info {
        flex-direction: column;
        text-align: center;
    }

    .exercise-media {
        width: 100px;
        height: 100px;
        margin: 0 auto;
    }

    .compact-table {
        font-size: 0.9rem;
    }

    .compact-table th,
    .compact-table td {
        padding: 0.6rem;
    }

    .welcome-banner {
        padding: 1.5rem;
    }
}

/* Animation for exercise cards */
.animated {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Light theme adjustments */
html[data-theme="light"] .workout-day-card {
    background: white;
    border: 1px solid #e6e6e6;
}

html[data-theme="light"] .exercise-info {
    background: #f8f8f8;
}

html[data-theme="light"] .welcome-banner {
    background: linear-gradient(to right, #0070cc, #0051a2);
}

html[data-theme="light"] .compact-table th {
    background: #f2f2f2;
    color: #0070cc;
}

html[data-theme="light"] .exercise-details span {
    color: #0070cc;
}

/* Fix: Ensure "Ações" label appears above action cells on mobile */
@media (max-width: 768px) {
    td[data-label="Ações"]::before {
        display: block !important;
    }
}

/* Mobile “Ações” column layout fix */
@media (max-width: 768px) {
    /* Make the TD flex-row so label sits left and icon sits right */
    td[data-label="Ações"] {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: left !important;
    }
    /* Reset the pseudo‐label styling so it flows inline at the start */
    td[data-label="Ações"]::before {
        position: static !important;
        width: auto !important;
        margin: 0 !important;
        display: block !important;
        transform: none !important;
    }
    /* Remove extra bottom margin on the action button itself */
    td[data-label="Ações"] button,
    td[data-label="Ações"] .action-buttons {
        margin: 0 !important;
    }
}