/* Enviro360 mobile — single stylesheet, mobile-first.
   Kept inline-friendly to render well inside the NativePHP webview. */

:root {
    /* Force the WebView to render the page in light mode regardless of
       the OS theme. Bonutrim's logo is a dark wordmark on a green leaf,
       which is unreadable on a near-black dark-mode background. */
    color-scheme: light only;

    --enviro-green: #4caf50;
    --enviro-green-dark: #2e7d32;
    --enviro-green-soft: #e8f5e9;
    --enviro-text: #1b1b18;
    --enviro-text-muted: #62625e;
    --enviro-border: #e1e1de;
    --enviro-bg: #fafafa;
    --enviro-card: #ffffff;
    --enviro-error: #c0392b;
    --enviro-error-bg: #fdecea;
    --radius: 0.75rem;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--enviro-text);
    background: var(--enviro-bg);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--enviro-green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* App shell — used by the dashboard.
 *
 * NativePHP runs the WebView edge-to-edge (the Android template calls
 * WindowCompat.setDecorFitsSystemWindows(window, false) and injects
 * env(safe-area-inset-*) values from the WindowInsetsCompat). The
 * .nativephp-safe-area class on the shell is the framework's hook;
 * we just have to actually consume the env() values in our padding so
 * the header stops sliding under the clock + battery icons.
 */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
    background: var(--enviro-card);
    border-bottom: 1px solid var(--enviro-border);
    padding:
        calc(0.75rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right))
        0.75rem calc(1rem + env(safe-area-inset-left));
    display: flex; align-items: center; justify-content: space-between;
}
.app-header__brand { display: flex; align-items: center; gap: 0.75rem; }
.app-header__brand img { height: 32px; width: auto; }
.app-header__tenant {
    background: var(--enviro-green-soft);
    color: var(--enviro-green-dark);
    font-size: 0.75rem; font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.app-header__logout {
    background: none; border: 1px solid var(--enviro-border);
    color: var(--enviro-text);
    padding: 0.4rem 0.75rem; border-radius: var(--radius);
    cursor: pointer;
}
.app-header__logout:hover { background: var(--enviro-bg); }

.app-nav {
    display: flex;
    background: var(--enviro-card);
    border-bottom: 1px solid var(--enviro-border);
    padding: 0 0.5rem;
    overflow-x: auto;
}
.app-nav__item {
    padding: 0.75rem 1rem;
    color: var(--enviro-text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    border-bottom: 3px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}
.app-nav__item:hover { color: var(--enviro-text); text-decoration: none; }
.app-nav__item.is-active {
    color: var(--enviro-green-dark);
    border-bottom-color: var(--enviro-green);
}

.app-main { flex: 1; padding: 1rem; max-width: 720px; width: 100%; margin: 0 auto; }

.app-footer {
    padding:
        0.6rem calc(1rem + env(safe-area-inset-right))
        calc(0.6rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    text-align: center;
    color: var(--enviro-muted);
    font-size: 0.7rem;
    border-top: 1px solid var(--enviro-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

/* Login screen */
.auth-shell {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding:
        calc(1.5rem + env(safe-area-inset-top)) calc(1.5rem + env(safe-area-inset-right))
        calc(1.5rem + env(safe-area-inset-bottom)) calc(1.5rem + env(safe-area-inset-left));
    background: linear-gradient(135deg, var(--enviro-bg) 0%, var(--enviro-green-soft) 100%);
}
.auth-card {
    background: var(--enviro-card);
    width: 100%; max-width: 420px;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.auth-card__logo { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.auth-card__logo img { height: 60px; width: auto; }
.auth-card__title { font-size: 1.25rem; font-weight: 600; text-align: center; margin: 0 0 0.25rem; }
.auth-card__subtitle { font-size: 0.875rem; color: var(--enviro-text-muted); text-align: center; margin: 0 0 1.5rem; }

/* Cards */
.card {
    background: var(--enviro-card);
    border: 1px solid var(--enviro-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card__title { font-size: 1rem; font-weight: 600; margin: 0 0 0.75rem; }
.card__muted { color: var(--enviro-text-muted); font-size: 0.875rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; font-size: 0.9rem; }
.kv dt { color: var(--enviro-text-muted); }
.kv dd { margin: 0; font-weight: 500; }

.empty {
    display: flex; flex-direction: column; align-items: center; padding: 2rem 1rem;
    color: var(--enviro-text-muted); text-align: center; gap: 0.5rem;
}
.empty__icon { font-size: 2rem; }

/* Form */
.form__field { margin-bottom: 1rem; }
.form__label {
    display: block; font-size: 0.85rem; font-weight: 600;
    margin-bottom: 0.4rem; color: var(--enviro-text);
}
.form__input, .form__select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--enviro-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--enviro-card);
    color: var(--enviro-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form__input:focus, .form__select:focus {
    outline: none;
    border-color: var(--enviro-green);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}
.form__error {
    color: var(--enviro-error);
    font-size: 0.8rem;
    margin-top: 0.3rem;
}
.form__notice {
    background: var(--enviro-error-bg);
    color: var(--enviro-error);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.btn {
    display: inline-block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--enviro-green);
    color: #fff;
    border: 0;
    border-radius: var(--radius);
    font-size: 1rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn:hover { background: var(--enviro-green-dark); }
.btn--ghost {
    background: none; color: var(--enviro-text);
    border: 1px solid var(--enviro-border);
}
.btn--ghost:hover { background: var(--enviro-bg); }

/* Misc */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem; font-weight: 600;
    background: var(--enviro-bg);
    color: var(--enviro-text-muted);
    border: 1px solid var(--enviro-border);
}
.badge--green { background: var(--enviro-green-soft); color: var(--enviro-green-dark); border-color: transparent; }

.list-reset { list-style: none; padding: 0; margin: 0; }
.flex { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Dark-mode overrides removed: the brand requires light mode for the
   pilot. Re-introduce here when we have a dark-mode logo + audited
   contrast on every screen. */

/* ==========================================================================
   Pending-request feedback layer
   --------------------------------------------------------------------------
   #app-progress is a thin top bar that shows when a form submit or a
   page navigation is in flight. .app-spinner is the inline spinner the
   submit button swaps to while the request is pending. Both are driven
   by the JS hooks in resources/views/layouts/app.blade.php.
   ========================================================================== */
#app-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    pointer-events: none;
    z-index: 99999;
    overflow: hidden;
    opacity: 0;
    transition: opacity 120ms linear;
}
#app-progress.is-active {
    opacity: 1;
}
#app-progress::after {
    content: "";
    position: absolute;
    top: 0;
    height: 3px;
    width: 30%;
    background: linear-gradient(
        90deg,
        rgba(76, 175, 80, 0) 0%,
        var(--enviro-green) 50%,
        rgba(76, 175, 80, 0) 100%
    );
    animation: app-progress-slide 1.1s linear infinite;
}
@keyframes app-progress-slide {
    0%   { left: -30%; }
    100% { left: 100%;  }
}

.app-spinner {
    display: inline-block;
    width: 0.85em;
    height: 0.85em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    margin-right: 0.35em;
    vertical-align: -2px;
    animation: app-spinner-rotate 0.7s linear infinite;
}
@keyframes app-spinner-rotate {
    to { transform: rotate(360deg); }
}

/* Disabled button keeps colour but loses the hover affordance. */
.btn:disabled,
.btn[disabled] {
    opacity: 0.7;
    cursor: progress;
}

/* Locale toggle — PT | EN pill cluster.
   Used on the login screen and in the layout footer. Each language
   is a tiny <form> POSTing to /locale (so the toggle survives a hard
   refresh / cold start), and the active button is highlighted via
   .is-active. */
.locale-toggle {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin: 0 0 1rem;
}
.locale-toggle__btn {
    background: var(--enviro-card);
    color: var(--enviro-text-muted);
    border: 1px solid var(--enviro-border);
    padding: 0.25rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.locale-toggle__btn:hover {
    color: var(--enviro-text);
}
.locale-toggle__btn.is-active {
    background: var(--enviro-green-soft);
    color: var(--enviro-green-dark);
    border-color: transparent;
}

.app-footer .locale-toggle {
    margin: 0.25rem 0 0;
}
