﻿/* SpherePMS base theme.
 *
 * All brand-specific values are driven by CSS custom properties (--ep-*) that are
 * injected per organization in base.html. This file only *consumes* those tokens, so
 * white-labeling never requires recompiling or overriding Bootstrap globally
 * (decision: white-label; doc 16 §7).
 *
 * Default palette (platform) — sampled from the SpherePMS logo, see
 * settings.SPHEREPMS_DEFAULT_BRANDING for the derivation and the measured contrast ratios:
 *   ink #08192B · primary #0F3E6B · surface #F1F5F8 · secondary #8FD4DA · accent #0B6C7A
 */

/* Google Sans Flex — self-hosted. Drop the font files into core/static/core/fonts/
 * and this face activates automatically; until then the fallback stack is used. */
@font-face {
    font-family: "Google Sans Flex";
    src: url("../fonts/GoogleSansFlex.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

/* Static design tokens (the brand color/font tokens are injected per-org in base.html).
 * The neutrals are tinted with the ink hue rather than pure black, so borders and
 * placeholders sit in the same cool family as the logo instead of reading grey. */
:root {
    --ep-border: rgba(8, 25, 43, 0.14);
    --ep-border-soft: rgba(8, 25, 43, 0.09);
    --ep-muted-bg: #e6edf2;
    --ep-muted-text: #5b6b7c;
    --ep-radius: 1rem;
    --ep-radius-sm: 0.5rem;
    --ep-shadow: 0 2px 12px rgba(8, 25, 43, 0.08);
    /* The logo's own teal->blue sweep, for hero surfaces and the landing page. */
    --ep-brand-gradient: linear-gradient(135deg, #0B6C7A 0%, #12547F 48%, #0F3E6B 100%);
}

body.ep-body {
    font-family: var(--ep-font);
    color: var(--ep-ink);
    background-color: var(--ep-surface);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Keyboard focus visibility across interactive elements. */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--ep-accent);
    outline-offset: 2px;
}

/* Dashboard KPI cards lift slightly on hover. */
.ep-kpi {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ep-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--ep-shadow);
}

/* Unified status badge tinted from a catalog option color (set inline via style). */
.ep-badge-status {
    color: #fff;
    font-weight: 500;
}

main {
    flex: 1 0 auto;
}

.ep-navbar {
    background-color: var(--ep-primary);
}

.ep-navbar .navbar-brand,
.ep-navbar .ep-navbar-user {
    color: var(--ep-surface);
    font-weight: 600;
}

/* Active module link on the navbar. Uses --ep-secondary, not --ep-accent: the brand teal
 * on the navy navbar is only 1.8:1, so an accent underline would be invisible. */
.ep-navbar .ep-navbar-user.active {
    border-bottom: 2px solid var(--ep-secondary);
    padding-bottom: 2px;
}

/* Platform/organization logo in the navbar brand. */
.ep-navbar-logo {
    height: 30px;
    width: auto;
    display: block;
}

.ep-navbar-search-input {
    min-width: 11rem;
}

/* Hamburger toggler tinted for the dark branded navbar. */
.ep-navbar .navbar-toggler {
    border-color: var(--ep-surface);
    color: var(--ep-surface);
}

.ep-navbar .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* From `lg` (992px) the navbar drops the hamburger and lays every module link,
 * the search box, the org switcher and the profile email out in a single flex
 * row with no wrap — on laptop-width screens (roughly 992-1400px) a fully
 * authenticated org user has enough links that the row overflows and gets
 * clipped by the viewport. Shrink the text, let the row wrap onto a second
 * line instead of overflowing, and cap the two unbounded text fields
 * (org name, email) so one long value can't push everything else out. */
@media (min-width: 992px) {
    .ep-navbar #ep-nav .ms-auto {
        flex-wrap: wrap;
        row-gap: 0.5rem;
        justify-content: flex-end;
    }

    .ep-navbar .ep-navbar-user,
    .ep-navbar .btn-sm,
    .ep-navbar .dropdown-toggle {
        font-size: 0.85rem;
    }

    .ep-navbar-org-name,
    .ep-navbar-email {
        display: inline-block;
        max-width: 10rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }
}

@media (min-width: 992px) and (max-width: 1399.98px) {
    .ep-navbar-search-input {
        min-width: 7rem;
    }

    .ep-navbar-org-name,
    .ep-navbar-email {
        max-width: 7rem;
    }
}

.ep-btn-primary {
    background-color: var(--ep-accent);
    border: 1px solid var(--ep-accent);
    color: #fff;
}

.ep-btn-primary:hover {
    filter: brightness(0.92);
    color: #fff;
}

/* Outline button for light content pages (primary-colored so it is visible on white). */
.ep-btn-outline {
    border: 1px solid var(--ep-primary);
    color: var(--ep-primary);
    background: transparent;
}

.ep-btn-outline:hover {
    background: var(--ep-primary);
    color: #fff;
}

/* On the dark navbar the same class must read light. */
.ep-navbar .ep-btn-outline {
    border-color: var(--ep-surface);
    color: var(--ep-surface);
}

.ep-navbar .ep-btn-outline:hover {
    background: var(--ep-surface);
    color: var(--ep-primary);
}

/* Round avatars (person profile picture), shown everywhere the person appears. */
.ep-avatar {
    display: inline-block;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--ep-muted-bg);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    border: 1px solid var(--ep-border);
    aspect-ratio: 1 / 1;
}

.ep-avatar-sm { width: 28px; height: 28px; }
.ep-avatar-md { width: 48px; height: 48px; }
.ep-avatar-lg { width: 96px; height: 96px; }

/* Placeholder circle when a person has no photo yet. */
.ep-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ep-secondary);
    color: var(--ep-primary);
}

.ep-hero {
    background-color: var(--ep-primary);
    color: var(--ep-surface);
}

.ep-lead {
    color: var(--ep-secondary);
}

.ep-card {
    background: #fff;
    border: 1px solid var(--ep-border-soft);
    border-radius: 1rem;
}

/* Chart.js needs a parent with a fixed height + position:relative — without one, its
   ResizeObserver keeps re-measuring a height that the canvas itself just grew. */
.ep-chart-box {
    position: relative;
    width: 100%;
    height: 260px;
}

.ep-swatch {
    width: 100%;
    height: 72px;
    border-radius: 0.75rem;
    border: 1px solid var(--ep-border);
}

.ep-footer {
    flex-shrink: 0;
    background-color: var(--ep-ink);
    color: var(--ep-secondary);
}

/* Enlaces a la documentación en el pie. Heredan el cian del pie en vez del azul de enlace, que
   sobre la tinta oscura casi no se lee; el subrayado sólo aparece al pasar por encima para que la
   fila se lea como una línea de pie y no como tres enlaces sueltos. */
.ep-footer-links a {
    color: var(--ep-secondary);
    text-decoration: none;
    opacity: .85;
}
.ep-footer-links a:hover,
.ep-footer-links a:focus-visible {
    color: #fff;
    text-decoration: underline;
    opacity: 1;
}
.ep-footer-links span {
    opacity: .45;
    margin: 0 .45rem;
}

/* Badges styled with the brand primary. */
.ep-badge {
    background-color: var(--ep-primary);
    color: #fff;
    font-weight: 500;
}

/* --- Image thumbnails (always shown 4:3) + crop stage --- */
.ep-thumb {
    position: relative;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--ep-border);
    background: var(--ep-muted-bg);
}

.ep-thumb > img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* Cropped image shown via background (one stored image + a display-only crop rectangle). */
.ep-thumb-media {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    background-color: var(--ep-muted-bg);
    background-repeat: no-repeat;
}

.ep-thumb-primary {
    outline: 3px solid var(--ep-accent);
    outline-offset: -3px;
}

.ep-thumb-badge {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    background: var(--ep-accent);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
}

.ep-thumb-actions {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
    padding: 0.35rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.ep-thumb:hover .ep-thumb-actions {
    opacity: 1;
}

.ep-thumb-actions form {
    margin: 0;
}

.ep-crop-stage {
    max-height: 60vh;
}

.ep-crop-stage > img {
    max-width: 100%;
    display: block;
}

/* Card cover image (property list / space cards). */
.ep-cover {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 0.75rem 0.75rem 0 0;
    background-color: var(--ep-muted-bg);
    background-repeat: no-repeat;
}

/* Hero variant used by the public availability pages: same crop, squarer corners, taller. */
.ep-cover-lg {
    aspect-ratio: 3 / 2;
    border-radius: 0.75rem;
}

/* Inline preview for plain image uploads (ep_file_preview.js). */
.ep-file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ep-file-preview:empty {
    display: none;
}

.ep-file-thumb {
    margin: 0;
    width: 88px;
    text-align: center;
}

.ep-file-thumb img {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 0.4rem;
    border: 1px solid var(--ep-border);
    background: var(--ep-muted-bg);
}

.ep-file-thumb figcaption {
    font-size: 0.7rem;
    color: var(--ep-muted-text);
    margin-top: 0.15rem;
}

/* Contract document: on-screen frame vs. clean PDF content. */
.ep-doc-frame {
    background: #fff;
    border: 1px solid var(--ep-border-soft);
    border-radius: 0.5rem;
    padding: 2rem;
}

/* Template variable chip (rich editor + live previews outside TinyMCE). Hardcoded because
 * it also renders inside TinyMCE's iframe and in generated PDFs, where --ep-* never reach. */
.ep-varfield {
    display: inline-block;
    background: #0F3E6B;
    color: #fff;
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 0.85em;
}

/* ---------------------------------------------------------------------------
 * Public landing page (core/landing.html)
 * ------------------------------------------------------------------------ */

/* The landing is the only surface that fills the viewport with brand color, so it is the
 * one place the logo's actual gradient appears rather than the flat primary token. */
/* The hero is deliberately the LIGHT surface and the module cards carry the brand gradient.
 * The logo is a dark navy mark with teal facets: on the gradient it sank into its own colours and
 * stopped reading as a logo. On the pale surface it keeps its edges, and the weight of the page
 * moves down to the module grid, which is what a visitor is actually there to scan. */
.ep-landing-hero {
    background: var(--ep-muted-bg);
    color: var(--ep-ink);
    position: relative;
    overflow: hidden;
}

/* A faint echo of the logo's sphere, bled off the right edge. Decorative only:
 * it is a background image, so screen readers never see it. */
.ep-landing-hero::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -6rem;
    width: 34rem;
    height: 34rem;
    transform: translateY(-50%);
    background: radial-gradient(circle, rgba(11, 108, 122, 0.14) 0%, transparent 68%);
    pointer-events: none;
}

.ep-landing-hero > .container {
    position: relative;
    z-index: 1;
}

.ep-landing-logo {
    height: 104px;
    width: auto;
    filter: drop-shadow(0 6px 18px rgba(8, 25, 43, 0.18));
}

.ep-landing-lead {
    color: var(--ep-muted-text);
    font-size: 1.15rem;
    max-width: 46rem;
}

/* CTA row on the pale hero: the primary action is filled brand blue, the secondary an outline of
 * the same. Both clear WCAG AA against the surface. */
.ep-btn-hero {
    background: var(--ep-primary);
    border: 1px solid var(--ep-primary);
    color: #fff;
    font-weight: 600;
}

.ep-btn-hero:hover {
    background: var(--ep-accent);
    border-color: var(--ep-accent);
    color: #fff;
}

.ep-btn-hero-outline {
    background: transparent;
    border: 1px solid var(--ep-primary);
    color: var(--ep-primary);
    font-weight: 600;
}

.ep-btn-hero-outline:hover {
    background: var(--ep-primary);
    border-color: var(--ep-primary);
    color: #fff;
}

/* Pill navigation (platform layer tabs): Bootstrap's default active pill is its own blue, which
 * reads as a foreign colour next to the brand. */
.nav-pills .nav-link {
    color: var(--ep-primary);
}

.nav-pills .nav-link.active {
    background-color: var(--ep-primary);
    color: #fff;
}

.nav-pills .nav-link:hover:not(.active) {
    background-color: var(--ep-muted-bg);
}

/* Feature grid — the brand gradient lives here now (see the hero note above). */
.ep-feature {
    background: var(--ep-brand-gradient);
    border: 1px solid transparent;
    border-radius: var(--ep-radius);
    padding: 1.5rem;
    height: 100%;
    color: #fff;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ep-feature:hover {
    transform: translateY(-3px);
    box-shadow: var(--ep-shadow);
}

/* Body copy inside a module card: dimmed enough to rank below the title, bright enough to read
 * on the gradient (white at 82% clears AA on the lightest end of the sweep). */
.ep-feature-text {
    color: rgba(255, 255, 255, 0.82);
}

.ep-feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 1.35rem;
    margin-bottom: 0.9rem;
}

.ep-section-title {
    font-weight: 600;
}

.ep-section-sub {
    color: var(--ep-muted-text);
    max-width: 42rem;
}

/* Closing call-to-action band. */
.ep-landing-cta {
    background: var(--ep-ink);
    color: #fff;
    border-radius: var(--ep-radius);
}

@media (max-width: 575.98px) {
    .ep-landing-logo { height: 76px; }
    .ep-landing-hero::after { display: none; }
}

/* --- Mostrar/ocultar contraseña -------------------------------------------------------------
 * El ojito lo inyecta ep_ui.js en CADA campo de contraseña de la aplicación (entrar, registrarse,
 * cambiar y restablecer), en vez de escribirse plantilla por plantilla: así ninguna pantalla futura
 * se queda sin él. El envoltorio es la referencia de posición y el input gana espacio a la derecha
 * para que el texto nunca pase por debajo del botón. */
.ep-password-wrap {
    position: relative;
    display: block;
}

.ep-password-wrap input {
    padding-right: 2.75rem !important;
}

.ep-password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ep-muted-text, #6c757d);
    cursor: pointer;
    border-radius: 0 0.55rem 0.55rem 0;
    font-size: 1.05rem;
    line-height: 1;
}

.ep-password-toggle:hover,
.ep-password-toggle:focus-visible {
    color: var(--ep-ink, #212529);
}

.ep-password-toggle:focus-visible {
    outline: 2px solid var(--ep-accent, #0d6efd);
    outline-offset: -2px;
}

/* El ojito se dibuja encima del input, así que no debe comerse su clic de foco cuando el campo
 * ocupa toda la fila de un formulario apretado. */
.ep-password-wrap input:disabled + .ep-password-toggle {
    display: none;
}

/* --- Calendario de citas del CRM -------------------------------------------------------------
 * Rejilla de agenda: una fila por hora y las citas colocadas en su minuto exacto. La altura de la
 * hora la decide Python (crm/calendars.py) porque con ella se calcula el «top» de cada bloque; aquí
 * sólo se dibuja. Las líneas de hora son un degradado repetido, no 24 elementos por columna. */
.ep-cal-head,
.ep-cal-body {
    display: grid;
    grid-template-columns: 3.5rem repeat(7, minmax(0, 1fr));
}

.ep-cal-head {
    border-bottom: 1px solid var(--ep-border-soft);
    background: var(--ep-surface);
    position: sticky;
    top: 0;
    z-index: 2;
}

.ep-cal-headcell {
    text-align: center;
    padding: 0.4rem 0.25rem;
    border-left: 1px solid var(--ep-border-soft);
}

.ep-cal-scroll {
    max-height: 34rem;
    overflow-y: auto;
}

.ep-cal-gutter {
    border-right: 1px solid var(--ep-border-soft);
}

.ep-cal-hourlabel {
    font-size: 0.7rem;
    color: var(--ep-muted-text);
    text-align: right;
    padding-right: 0.35rem;
    transform: translateY(-0.4rem);
}

.ep-cal-day {
    position: relative;
    border-left: 1px solid var(--ep-border-soft);
    background-image: linear-gradient(to bottom, var(--ep-border-soft) 0 1px, transparent 1px 100%);
    background-repeat: repeat-y;
}

.ep-cal-today {
    background-color: rgba(143, 212, 218, 0.12);
}

/* El hueco donde se agenda. Invisible hasta que el cursor pasa por encima: la rejilla no debe
 * parecer un tablero de botones, pero cada hora sí es un sitio donde se puede hacer clic. */
.ep-cal-slot {
    display: block;
    position: relative;
    z-index: 0;
}

.ep-cal-slot:hover {
    background: rgba(11, 108, 122, 0.09);
    box-shadow: inset 0 0 0 1px rgba(11, 108, 122, 0.35);
}

.ep-cal-event {
    position: absolute;
    z-index: 1;
    overflow: hidden;
    padding: 0.15rem 0.3rem;
    border-radius: 0.3rem;
    color: #fff;
    font-size: 0.72rem;
    line-height: 1.15;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(2, 0, 13, 0.25);
}

.ep-cal-event:hover {
    color: #fff;
    filter: brightness(1.08);
}

.ep-cal-event-time { font-weight: 600; margin-right: 0.2rem; }
.ep-cal-event-name { display: inline; }
.ep-cal-event-meta { display: block; opacity: 0.85; }

.ep-cal-dot {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
}

/* Vista de mes: la cuadrícula clásica, con las citas como fichas de color. */
.ep-cal-monthgrid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.ep-cal-monthhead {
    background: var(--ep-surface);
    border-bottom: 1px solid var(--ep-border-soft);
}

.ep-cal-monthcell {
    min-height: 6.5rem;
    border-left: 1px solid var(--ep-border-soft);
    border-bottom: 1px solid var(--ep-border-soft);
    padding: 0.35rem;
}

.ep-cal-outside { background: rgba(2, 0, 13, 0.025); color: var(--ep-muted-text); }

.ep-cal-add {
    color: var(--ep-muted-text);
    text-decoration: none;
    line-height: 1;
    opacity: 0;
}

.ep-cal-monthcell:hover .ep-cal-add { opacity: 1; }

.ep-cal-chip {
    display: block;
    margin-top: 0.2rem;
    padding: 0.1rem 0.3rem;
    font-size: 0.72rem;
    border-left: 3px solid #6c757d;
    border-radius: 0.2rem;
    background: rgba(2, 0, 13, 0.04);
    color: var(--ep-ink);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ep-cal-chip:hover { background: rgba(2, 0, 13, 0.09); color: var(--ep-ink); }

@media (max-width: 767.98px) {
    .ep-cal-head, .ep-cal-body { grid-template-columns: 2.6rem repeat(7, minmax(0, 1fr)); }
    .ep-cal-event { font-size: 0.62rem; }
    .ep-cal-monthcell { min-height: 4.5rem; }
}
