/* VARIABLES DE TEMA */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-input: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-heading: #2c3e50;
    --border-color: #e0e0e0;
    --header-bg: #2c3e50;
    --accent: #667eea;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #f8f9fa;
    --card-border: #667eea;
    --danger: #e74c3c;
    --btn-secondary-bg: #f0f0f0;
    --btn-secondary-text: #333333;
    --modal-bg: #ffffff;
    --alert-warning-bg: #fff3cd;
    --alert-warning-text: #856404;
    --alert-warning-border: #ffc107;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-input: #1a1a2e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-heading: #e0e0e0;
    --border-color: #2a2a4a;
    --header-bg: #0f0f23;
    --accent: #667eea;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #16213e;
    --card-border: #667eea;
    --danger: #e74c3c;
    --btn-secondary-bg: #16213e;
    --btn-secondary-text: #e0e0e0;
    --modal-bg: #1a1a2e;
    --alert-warning-bg: #3d3200;
    --alert-warning-text: #ffc107;
    --alert-warning-border: #ffc107;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    color: var(--text-primary);
}

.container {
    width: 100%;
    min-height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.header {
    background: var(--header-bg);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.3s;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* SELECTOR DE TEMA */
.theme-selector {
    display: flex;
    gap: 8px;
}

.theme-option {
    flex: 1;
    padding: 10px 8px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s;
    font-weight: 600;
}

.theme-option:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-option.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}


/* INDICADOR OFFLINE */
.offline-banner {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--text-secondary);
    color: white;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.offline-banner.visible {
    display: flex;
}

.offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff6b6b;
    display: inline-block;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

/* PANTALLA PRINCIPAL */
.main-screen {
    display: none;
}

.main-screen.active {
    display: block;
}

.form-group {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

label {
    margin: 0;
    font-weight: 600;
    color: var(--text-heading);
    font-size: 13px;
    min-width: 110px;
    white-space: nowrap;
}

input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
}

input[type="date"] {
    padding: 10px;
}

input:focus {
    outline: none;
    border-color: #667eea;
}

.consumption-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 14px;
    text-align: center;
}

.consumption-display.empty {
    background: var(--border-color);
    color: var(--text-secondary);
}

.consumption-value {
    font-size: 32px;
    font-weight: bold;
}

.consumption-unit {
    font-size: 12px;
    margin-top: 2px;
    opacity: 0.9;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
    margin-top: 10px;
}

.btn-danger:hover {
    background: #c0392b;
}

/* HISTÓRICO */
.history-section {
    margin-top: 30px;
}

.history-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 12px;
}

.history-list {
    list-style: none;
}

.history-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 4px solid #667eea;
    font-size: 14px;
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.history-item-wrapper {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg-secondary);
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.history-item.swiped .history-item-wrapper {
    transform: translateX(-60px);
}

.history-item-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.history-info {
    flex: 1;
}

.history-item-delete-bg {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    background: var(--danger);
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
}

.history-info {
    flex: 1;
}

.history-date {
    font-weight: 600;
    color: var(--text-heading);
}

.history-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.history-consumption {
    font-weight: 600;
    color: #667eea;
    text-align: right;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 14px;
}

/* ESTADÍSTICAS EN PANTALLA PRINCIPAL */
.stats-section {
    margin-top: 20px;
}

.stats-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-heading);
}

/* PANTALLA CONFIGURACIÓN */
.settings-screen {
    display: none;
}

.settings-screen.active {
    display: block;
}

/* PANTALLA AYUDA */
.help-screen {
    display: none;
    padding: 16px;
}

.help-screen.active {
    display: block;
}

.back-to-settings-btn {
    background: none;
    border: none;
    color: #667eea;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 20px;
    font-weight: 600;
}

.help-content {
    background: var(--bg-primary);
}

.help-content h2 {
    color: var(--text-heading);
    font-size: 24px;
    margin-bottom: 20px;
    margin-top: 0;
}

.help-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.help-section:last-child {
    border-bottom: none;
}

.help-section h3 {
    color: var(--text-heading);
    font-size: 18px;
    margin-top: 0;
    margin-bottom: 12px;
}

.help-section p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.help-section ul {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
    padding-left: 20px;
    line-height: 1.8;
}

.help-section li {
    margin-bottom: 8px;
}

.help-section strong {
    color: var(--text-heading);
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* GRÁFICA */
.chart-container {
    position: relative;
    margin-bottom: 20px;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-heading);
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.filter-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.filter-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.alert-box {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    border-left: 4px solid;
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.alert-box.warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.alert-box.danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-box.info {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-group .btn {
    flex: 1;
    margin-bottom: 0;
}

/* RESPONSIVE */
@media (max-height: 700px) {
    .container {
        min-height: auto;
    }

    .content {
        max-height: 70vh;
    }

    .chart-container {
        height: 200px;
    }
}

/* PWA */
@supports (display: standalone) {
    body {
        padding-top: 20px;
    }
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    width: 100%;
}

.no-data-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-size: 14px;
}
/* MODAL DE EDICIÓN */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.modal {
    background: var(--modal-bg);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 16px;
    color: var(--text-heading);
    font-size: 18px;
}

.modal .form-group {
    margin-bottom: 12px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel {
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
}

.btn-save {
    background: #667eea;
    color: white;
}
