:root {
    --bg-color: #1c1c1e; --container-bg: #2c2c2e; --item-bg: #3a3a3c;
    --text-color: #f2f2f7; --label-color: #8e8e93; --border-color: rgba(255, 255, 255, 0.1);
    --title-color: #00aaff; --shadow-color: rgba(0, 0, 0, 0.5); --increment-color: #34c759;
    --decrement-color: #ff3b30; --xp-color: #fca311; --edit-color: #fca311;
}
body.light-theme {
    --bg-color: #f2f2f7; --container-bg: #ffffff; --item-bg: #e5e5ea;
    --text-color: #1c1c1e; --label-color: #6c6c70; --border-color: #d1d1d6;
    --title-color: #007aff; --shadow-color: rgba(0, 0, 0, 0.1);
}
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bg-color); color: var(--text-color); display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 20px; gap: 20px; transition: background-color 0.3s, color 0.3s; }
nav { display: flex; gap: 15px; background-color: var(--container-bg); padding: 10px 20px; border-radius: 12px; border: 1px solid var(--border-color); box-shadow: 0 4px 12px var(--shadow-color); width: 100%; max-width: 1130px; box-sizing: border-box; justify-content: center; }
nav a { color: var(--text-color); text-decoration: none; font-weight: 500; padding: 8px 15px; border-radius: 8px; transition: background-color 0.2s, color 0.2s; }
nav a:hover { background-color: var(--item-bg); }
nav a.active { background-color: var(--title-color); color: #fff; text-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
.content-wrapper { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; width: 100%; gap: 30px; }
.container { width: 100%; padding: 30px; background-color: var(--container-bg); border-radius: 12px; box-shadow: 0 8px 24px var(--shadow-color); border: 1px solid var(--border-color); transition: background-color 0.3s, border-color 0.3s; }
#main-container, #habits-container { max-width: 700px; text-align: center; }
#history-container { max-width: 400px; align-self: flex-start; }
.header-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
h1, h2 { color: var(--title-color); text-shadow: 0 0 10px var(--title-color); }
h1 { margin: 0; font-size: 1.8em; }
h2 { margin-top: 0; text-align: center; }
.header-buttons { display: flex; gap: 10px; }
#theme-toggle-btn, #toggle-edit-btn { background: none; border: 1px solid var(--border-color); border-radius: 50%; width: 40px; height: 40px; font-size: 18px; cursor: pointer; display: flex; justify-content: center; align-items: center; padding: 0; transition: background-color 0.2s; }
#theme-toggle-btn:hover, #toggle-edit-btn:hover { background-color: var(--item-bg); }
#theme-toggle-btn svg, #toggle-edit-btn svg { width: 20px; height: 20px; fill: var(--text-color); transition: fill 0.3s; }
.icon-sun, body.light-theme .icon-moon, .icon-unlock, body.edit-mode-enabled .icon-lock { display: none; }
body.light-theme .icon-sun, .icon-moon, body.edit-mode-enabled .icon-unlock, .icon-lock { display: block; }
#chart-wrapper { height: 350px; margin: 20px 0 30px 0; }
.rank-container { background-color: var(--item-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; margin-bottom: 20px; text-align: left; }
.rank-display { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rank-display span { font-size: 1.5em; font-weight: bold; }
.rank-tag { padding: 5px 15px; border-radius: 15px; font-size: 1.2em; font-weight: bold; color: white; }
#rank-up-test { font-size: 0.9em; color: var(--label-color); }
#rank-up-test h4 { margin: 0 0 8px 0; color: var(--text-color); }
#rank-up-test ul { margin: 0; padding-left: 20px; }
.attribute-item { display: flex; align-items: center; gap: 10px; padding: 12px 15px; background-color: var(--item-bg); border-radius: 8px; border: 1px solid var(--border-color); }
.attribute-name-wrapper { display: flex; align-items: center; flex-grow: 1; text-align: left; }
.attribute-name { font-size: 16px; font-weight: 500; }
.attribute-details { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.value-control-group { display: flex; align-items: center; gap: 8px; }
.value-display { display: flex; flex-direction: column; align-items: center; }
.value-label { font-size: 10px; color: var(--label-color); font-weight: bold; text-transform: uppercase; margin-bottom: 4px; }
.attribute-value { background-color: var(--bg-color); padding: 5px 10px; border-radius: 5px; font-weight: bold; font-size: 14px; min-width: 25px; text-align: center; border: 1px solid var(--border-color); }
.control-btn { color: white; border: none; width: 30px; height: 30px; font-size: 18px; font-weight: bold; line-height: 30px; border-radius: 6px; cursor: pointer; transition: background-color 0.3s; }
.control-btn:disabled { background-color: #555; cursor: not-allowed; }
.incrementar-btn { background-color: var(--increment-color); }
.decrementar-btn { background-color: var(--decrement-color); }
.value-control-group .control-btn { display: none; }
body.edit-mode-enabled .value-control-group .control-btn { display: flex; }
.attribute-xp-bar { width: 120px; flex-shrink: 0; }
.xp-bar-container { width: 100%; height: 8px; background-color: var(--bg-color); border-radius: 4px; overflow: hidden; border: 1px solid var(--border-color); }
.xp-bar-progress { height: 100%; width: 0%; background-color: var(--xp-color); border-radius: 4px; transition: width 0.5s ease-in-out; }
.xp-info-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.level-display { font-size: 10px; font-weight: bold; color: var(--label-color); }
.xp-text { font-size: 10px; color: var(--label-color); }
#history-list, #habits-list { list-style-type: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
#history-list { max-height: 500px; overflow-y: auto; }
.history-item { background-color: var(--item-bg); padding: 8px 12px; border-radius: 6px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.history-item-text { flex-grow: 1; text-align: left; margin-right: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .timestamp { font-size: 12px; color: var(--label-color); flex-shrink: 0; }
.history-item .change-pos { color: var(--increment-color); font-weight: bold; }
.history-item .change-neg { color: var(--decrement-color); font-weight: bold; }
.history-item .origin { color: var(--label-color); font-size: 0.9em; }
#system-alert { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(200%); background-color: rgba(0, 50, 150, 0.9); color: #fff; padding: 15px 25px; border-radius: 12px; border: 2px solid var(--title-color); box-shadow: 0 0 20px var(--title-color); font-size: 1.1em; font-weight: bold; z-index: 1000; transition: transform 0.5s ease-in-out; text-align: center; }
#system-alert.show { transform: translateX(-50%) translateY(0); }
.attribute-title { font-size: 10px; font-weight: bold; color: var(--xp-color); margin-left: 8px; font-style: italic; }
.rank-e { background-color: #6c757d; } .rank-d { background-color: #34c759; } .rank-c { background-color: #007aff; } .rank-b { background-color: #bf5af2; } .rank-a { background-color: #ff9500; } .rank-s { background-color: #ff3b30; }
#habit-form { display: flex; flex-direction: column; gap: 15px; margin-bottom: 30px; }
.form-row { display: flex; gap: 15px; }
.form-group { display: flex; flex-direction: column; text-align: left; flex-grow: 1; }
.form-group label { margin-bottom: 8px; font-size: 14px; color: var(--label-color); font-weight: 500; }
.form-group input, .form-group select { background-color: var(--bg-color); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; font-size: 16px; width: 100%; box-sizing: border-box; }
.segmented-control { display: flex; background-color: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 4px; }
.sg-btn { flex: 1; padding: 8px; border: none; background-color: transparent; color: var(--label-color); font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 6px; transition: background-color 0.2s, color 0.2s; }
.sg-btn.active { background-color: var(--item-bg); color: var(--text-color); font-weight: bold; }
.checkbox-group { display: flex; align-items: center; gap: 10px; background-color: var(--bg-color); padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); }
#attributes-checkboxes { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px; background-color: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; }
.checkbox-label { display: flex; align-items: center; cursor: pointer; font-size: 14px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border-color); transition: all 0.2s ease-in-out; }
.checkbox-label:hover { border-color: var(--title-color); color: var(--title-color); }
.checkbox-label input { display: none; }
.checkbox-label:has(input:checked) { background-color: var(--title-color); border-color: var(--title-color); color: #ffffff; }
.submit-btn { background-color: var(--title-color); color: white; border: none; border-radius: 8px; padding: 12px; font-size: 16px; font-weight: bold; cursor: pointer; transition: opacity 0.2s; }
.submit-btn:disabled { background-color: #555; cursor: not-allowed; }
.habit-item { display: flex; justify-content: space-between; align-items: center; background-color: var(--item-bg); padding: 12px 15px; border-radius: 8px; border-left: 4px solid transparent; transition: border-color 0.3s; }
.habit-item.mandatory { border-left-color: var(--xp-color); }
.habit-info { flex-grow: 1; text-align: left; }
.habit-name-wrapper { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.habit-name { font-weight: bold; font-size: 1.1em; }
.attributes-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.habit-stats-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--label-color); font-weight: 500; background-color: var(--bg-color); padding: 3px 8px; border-radius: 10px; }
.habit-attribute-tag { font-size: 11px; color: var(--label-color); background-color: var(--bg-color); padding: 3px 8px; border-radius: 10px; }
.habit-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.complete-btn, .delete-btn, .edit-btn { border: none; cursor: pointer; font-weight: bold; display: flex; align-items: center; justify-content: center; color: white; }
.complete-btn { background-color: var(--increment-color); width: auto; padding: 0 10px; height: 35px; border-radius: 8px; font-size: 14px; }
.complete-btn:disabled { background-color: #555; cursor: not-allowed; opacity: 0.7; }
.edit-btn { background-color: var(--edit-color); width: 35px; height: 35px; border-radius: 50%; }
.delete-btn { background-color: var(--decrement-color); width: 35px; height: 35px; border-radius: 50%; }
.difficulty-tag { font-size: 10px; font-weight: bold; padding: 2px 8px; border-radius: 8px; text-transform: uppercase; color: white; }
.difficulty-rank-e { background-color: #6c757d; } .rank-d { background-color: #34c759; } .rank-c { background-color: #007aff; } .rank-b { background-color: #bf5af2; } .rank-a { background-color: #ff9500; } .rank-s { background-color: #ff3b30; }
#habit-form { display: flex; flex-direction: column; gap: 15px; margin-bottom: 30px; }
.form-row { display: flex; gap: 15px; }
.form-group { display: flex; flex-direction: column; text-align: left; flex-grow: 1; }
.form-group label { margin-bottom: 8px; font-size: 14px; color: var(--label-color); font-weight: 500; }
.form-group input, .form-group select { background-color: var(--bg-color); color: var(--text-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; font-size: 16px; width: 100%; box-sizing: border-box; }
.segmented-control { display: flex; background-color: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; padding: 4px; }
.sg-btn { flex: 1; padding: 8px; border: none; background-color: transparent; color: var(--label-color); font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 6px; transition: background-color 0.2s, color 0.2s; }
.sg-btn.active { background-color: var(--item-bg); color: var(--text-color); font-weight: bold; }
.checkbox-group { display: flex; align-items: center; gap: 10px; background-color: var(--bg-color); padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); }
#attributes-checkboxes { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px; background-color: var(--bg-color); border: 1px solid var(--border-color); border-radius: 8px; }
.checkbox-label { display: flex; align-items: center; cursor: pointer; font-size: 14px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border-color); transition: all 0.2s ease-in-out; }
.checkbox-label:hover { border-color: var(--title-color); color: var(--title-color); }
.checkbox-label input { display: none; }
.checkbox-label:has(input:checked) { background-color: var(--title-color); border-color: var(--title-color); color: #ffffff; }
.submit-btn { background-color: var(--title-color); color: white; border: none; border-radius: 8px; padding: 12px; font-size: 16px; font-weight: bold; cursor: pointer; transition: opacity 0.2s; }
.submit-btn:disabled { background-color: #555; cursor: not-allowed; }
.habit-item { display: flex; justify-content: space-between; align-items: center; background-color: var(--item-bg); padding: 12px 15px; border-radius: 8px; border-left: 4px solid transparent; transition: border-color 0.3s; }
.habit-item.mandatory { border-left-color: var(--xp-color); }
.habit-info { flex-grow: 1; text-align: left; }
.habit-name-wrapper { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.habit-name { font-weight: bold; font-size: 1.1em; }
.attributes-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.habit-stats-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--label-color); font-weight: 500; background-color: var(--bg-color); padding: 3px 8px; border-radius: 10px; }
.habit-attribute-tag { font-size: 11px; color: var(--label-color); background-color: var(--bg-color); padding: 3px 8px; border-radius: 10px; }
.habit-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.complete-btn, .delete-btn, .edit-btn { border: none; cursor: pointer; font-weight: bold; display: flex; align-items: center; justify-content: center; color: white; }
.complete-btn { background-color: var(--increment-color); width: auto; padding: 0 10px; height: 35px; border-radius: 8px; font-size: 14px; }
.complete-btn:disabled { background-color: #555; cursor: not-allowed; opacity: 0.7; }
.edit-btn { background-color: var(--edit-color); width: 35px; height: 35px; border-radius: 50%; }
.delete-btn { background-color: var(--decrement-color); width: 35px; height: 35px; border-radius: 50%; }
.difficulty-tag { font-size: 10px; font-weight: bold; padding: 2px 8px; border-radius: 8px; text-transform: uppercase; color: white; }
.difficulty-rank-e { background-color: #6c757d; } .rank-d { background-color: #34c759; } .rank-c { background-color: #007aff; } .rank-b { background-color: #bf5af2; } .rank-a { background-color: #ff9500; } .rank-s { background-color: #ff3b30; }
@media (max-width: 768px) {
    body { padding: 10px; gap: 15px; }
    .content-wrapper { gap: 15px; }
    .container { padding: 15px; }
    h1 { font-size: 1.5em; }
    h2 { font-size: 1.2em; }
    .attribute-item { flex-direction: column; align-items: stretch; gap: 12px; }
    .attribute-name-wrapper { justify-content: center; }
    .attribute-name { font-size: 18px; flex-grow: 0; }
    .attribute-xp-bar { width: 100%; }
    .attribute-details { justify-content: space-around; flex-wrap: wrap; }
    #chart-wrapper { height: 280px; }
    .form-row { flex-direction: column; }
    .habit-item { flex-direction: column; align-items: stretch; gap: 15px; text-align: center; }
    .habit-info { text-align: center; }
    .habit-name-wrapper, .attributes-tags { justify-content: center; }
    .habit-actions { justify-content: center; }
}

.modal-hidden {
    display: none;
}

.modal-visible {
    display: flex; /* Use flex for centering */
    position: fixed;
    z-index: 1001; /* Higher than system-alert */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
}

.modal-content {
    background-color: var(--container-bg);
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: auto;
    max-width: 80%;
    max-height: 80%;
    position: relative;
}

.modal-images-container {
    display: flex;
    gap: 10px;
}

#modal-image-1, #modal-image-2 {
    max-width: 45%;
    max-height: 70vh;
}

.modal-close {
    color: var(--label-color);
    position: absolute;
    top: 10px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--text-color);
    text-decoration: none;
}

body.hidden-until-auth .content-wrapper {
    display: none;
}
