/* Shared shell: the frame every tile page renders inside.
 *
 * Top bar, page container, auth overlay, toast, popup chrome and the base
 * form/button styling. A tile's own stylesheet loads after this one and only
 * has to describe what is unique to that tile.
 */

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100%;
    background-color: #f5f5f5;
    /* Prevent the whole page from scrolling; only .content scrolls internally.
       This keeps the fixed/absolute top bar from being scrolled off screen. */
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height accounts for mobile browser chrome */
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    position: relative;
    box-sizing: border-box; /* so padding-bottom (mobile) stays within the viewport */
    overflow: hidden;
}

.content {
    flex: 1;
    padding: 80px 20px 20px 20px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* A tile that draws its own chrome edge to edge (the daily menu) */
.content.bleed {
    padding: 60px 0 0 0;
}

.date-navigator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 0 0 5px 5px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    box-sizing: border-box;
    min-height: 60px; /* Ensure consistent height even when buttons are hidden */
}

.left-nav, .center-nav, .right-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #333;
    padding: 0;
    box-sizing: border-box;
}

.nav-btn svg {
    width: 30px;
    height: 30px;
}

.nav-btn.mantra-btn svg {
    width: 34px;
    height: 34px;
}

.nav-btn:hover {
    background-color: #bbb;
}

.nav-btn.confirm {
    background-color: #42f5b6 !important;
    color: #333 !important;
}

.nav-btn.confirm:hover {
    background-color: #4ffecc !important;
}

.nav-btn.cancel {
    background-color: #f44336;
    color: white;
}

.nav-btn.cancel:hover {
    background-color: #d32f2f;
}

#selected-date {
    font-weight: bold;
    font-size: 16px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 20px;
}

form {
    margin-bottom: 20px;
}

input[type="checkbox"] {
    margin-right: 10px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

input[type="text"] {
    width: calc(100% - 22px); /* Account for borders and padding */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

button {
    background-color: #42f5b6;
    color: #333;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 10px;
}

button:hover {
    background-color: #4ffecc;
}

ul {
    list-style-type: none;
    padding: 0;
}

li {
    background-color: #f9f9f9;
    margin-bottom: 5px;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-mode {
    height: 100vh;
    background-color: #f5f5f5;
}

.settings-nav {
    display: flex;
    background-color: #fff;
    border-top: 1px solid #ddd;
    justify-content: center;
    padding: 15px;
}

/* Mantra popup */
.mantra-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow: auto;
}

/* Keep the goal editor above the archive popups so editing a finished goal
   layers on top of the Finished Goals list rather than behind it. */
#edit-goal-popup {
    z-index: 1100;
}

.mantra-popup-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    position: relative;
}

.mantra-popup-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.mantra-popup-close:hover {
    color: #000;
}

.read-mantra-btn {
    width: 100%;
    height: 64px;
    margin-top: 16px;
    border-radius: 10px;
    background-color: #ff9800;
    color: #333;
    padding: 15px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.read-mantra-btn:hover {
    background-color: #e68900;
}

.read-mantra-btn.read,
.read-mantra-btn.completed {
    background-color: #42f5b6;
    color: #333;
}

.read-mantra-btn.read:hover,
.read-mantra-btn.completed:hover {
    background-color: #4ffecc;
}

.tab-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 10px 5px;
    background-color: #eee;
    border: none;
    border-radius: 10px;
    margin: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tab-button.active {
    background-color: #42f5b6;
    color: #333;
    box-shadow: 0 4px 12px rgba(66, 245, 182, 0.3);
}

.tab-button:hover:not(.active) {
    background-color: #f5f5f5;
}

.tab-button svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

/* Mobile specific styles */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
        box-shadow: none;
    }

    .content {
        padding: 70px 15px 15px 15px;
    }
}

@media (min-width: 769px) {
    .container {
        height: 80vh;
        margin-top: 20px;
    }
}

/* Auth overlay */
.auth-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.auth-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    min-width: 300px;
    text-align: center;
}

.auth-modal h2 {
    margin-top: 0;
}

.auth-modal form {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.auth-modal input {
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.auth-modal button {
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#auth-submit {
    background-color: #42f5b6;
    color: #333;
    margin-bottom: 10px;
}

#auth-submit:hover {
    background-color: #4ffecc;
}

#auth-toggle {
    background: none;
    border: none;
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
}

.auth-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
}

.auth-close:hover {
    color: #000;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 16px;
    border-radius: 25px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}

/* Invalid input highlighting */
.invalid {
    border: 2px solid red !important;
    background-color: #ffe6e6;
}
