/* =========================================================================
   صلة (Sila) — design system
   Color/typography/spacing tokens + component styles shared by every page.
   Logical (inset-inline-*, margin-inline-*) properties throughout so the
   whole app mirrors correctly between Arabic (RTL) and English (LTR).
   ========================================================================= */

:root {
    /* Deep navy (#00004c) — the project's core brand color, chosen deliberately
       (not a generic SaaS purple): conveys trust/security/premium, fitting an
       encrypted messaging platform. Muted gold pairs with it as the secondary
       brand accent (classic navy+gold premium pairing) — kept distinct from
       the semantic status colors below (success/warning/danger), which stay
       conventional (green/amber/red) regardless of brand hue. */
    --sila-primary: #00004c;
    --sila-primary-dark: #1c1c6e;
    --sila-primary-light: #e6e6f2;
    /* The primary colour where it is text or a line rather than a fill —
       navy on white here, a light lavender on the dark background, where
       navy text would vanish. */
    --sila-primary-ink: #00004c;
    --sila-accent: #c9a227;
    --sila-accent-dark: #a3801a;
    --sila-accent-light: #f7efd8;
    --sila-success: #1f9d6b;
    --sila-success-light: #e3f7ef;
    --sila-warning: #d99a1f;
    --sila-warning-light: #fbf1dc;
    --sila-danger: #e0475a;
    --sila-danger-light: #fbe7ea;

    --sila-bg: #f5f5fa;
    --sila-surface: #ffffff;
    --sila-border: #dfe0ea;
    --sila-text: #14142e;
    --sila-text-muted: #6b6d85;

    --sila-radius-sm: 0.5rem;
    --sila-radius-md: 0.875rem;
    --sila-radius-lg: 1.25rem;
    --sila-shadow-sm: 0 1px 2px rgba(0, 0, 30, 0.07);
    --sila-shadow-md: 0 8px 24px rgba(0, 0, 30, 0.1);
    --sila-font: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
}


/* Dark: by the system's setting unless a choice was made here (the button in
   the header writes data-theme on <html>), the same colours as the phone
   app's dark mode. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --sila-primary: #2b2b85;
        --sila-primary-dark: #3a3aa0;
        --sila-primary-light: #24224a;
        --sila-primary-ink: #c4c1f5;
        --sila-accent-light: #3a3215;
        --sila-success-light: #12352a;
        --sila-warning-light: #3a2e12;
        --sila-danger-light: #3d1820;
        --sila-bg: #0a0a1f;
        --sila-surface: #15143a;
        --sila-border: #2c2a55;
        --sila-text: #eeeef6;
        --sila-text-muted: #a6a6c8;
        --sila-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --sila-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --sila-primary: #2b2b85;
    --sila-primary-dark: #3a3aa0;
    --sila-primary-light: #24224a;
    --sila-primary-ink: #c4c1f5;
    --sila-accent-light: #3a3215;
    --sila-success-light: #12352a;
    --sila-warning-light: #3a2e12;
    --sila-danger-light: #3d1820;
    --sila-bg: #0a0a1f;
    --sila-surface: #15143a;
    --sila-border: #2c2a55;
    --sila-text: #eeeef6;
    --sila-text-muted: #a6a6c8;
    --sila-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sila-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--sila-font);
    margin: 0;
    background: var(--sila-bg);
    color: var(--sila-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 700;
    color: var(--sila-text);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--sila-border);
    border-radius: 999px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

a {
    color: var(--sila-primary-ink);
}

/* ---------- generic form controls (any bare <input>/<button> inside these
   containers, plus the specifically-classed ones used across pages) ------- */

.login-card input,
.login-card select,
.chat-page input,
.chat-page select {
    padding: 0.65rem 0.9rem;
    font-family: var(--sila-font);
    font-size: 0.95rem;
    border-radius: var(--sila-radius-sm);
    border: 1.5px solid var(--sila-border);
    background: var(--sila-surface);
    color: var(--sila-text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .login-card input:focus,
    .login-card select:focus,
    .chat-page input:focus,
    .chat-page select:focus {
        border-color: var(--sila-primary-ink);
        box-shadow: 0 0 0 3px var(--sila-primary-light);
    }

    .login-card input::placeholder,
    .chat-page input::placeholder {
        color: var(--sila-text-muted);
    }

.login-card button,
.chat-page button {
    padding: 0.65rem 1.1rem;
    font-family: var(--sila-font);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--sila-radius-sm);
    border: 1.5px solid transparent;
    background: var(--sila-primary);
    color: white;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
    white-space: nowrap;
}

    .login-card button:hover:not(:disabled),
    .chat-page button:hover:not(:disabled) {
        background: var(--sila-primary-dark);
    }

    .login-card button:active:not(:disabled),
    .chat-page button:active:not(:disabled) {
        transform: scale(0.98);
    }

    .login-card button:disabled,
    .chat-page button:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

/* Secondary ("quiet") action buttons — anything explicitly marked, plus the
   most common secondary actions across pages that shouldn't scream primary. */
.btn-secondary,
.lang-switch-button,
.theme-switch-button,
.chat-header button,
.canned-delete,
.msg-delete-everyone,
.msg-delete-me,
.invite-decline,
.support-close {
    background: var(--sila-surface);
    color: var(--sila-primary-ink);
    border-color: var(--sila-border);
}

    .btn-secondary:hover:not(:disabled),
    .chat-header button:hover:not(:disabled) {
        background: var(--sila-primary-light);
        border-color: var(--sila-primary-ink);
    }

.msg-delete-everyone,
.msg-delete-me,
.invite-decline {
    color: var(--sila-danger);
}

    .msg-delete-everyone:hover:not(:disabled),
    .msg-delete-me:hover:not(:disabled),
    .invite-decline:hover:not(:disabled) {
        background: var(--sila-danger-light);
        border-color: var(--sila-danger);
    }

/* ---------- shared page shell (header bar rendered by MainLayout) ------- */

.app-shell {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: var(--sila-surface);
    border-bottom: 1px solid var(--sila-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--sila-primary-ink);
    text-decoration: none;
}

    .app-header-brand img {
        height: 1.85rem;
        width: auto;
    }

.lang-switch-button,
.theme-switch-button {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 999px;
}

.app-body {
    flex: 1;
    padding: 1.5rem 1rem 3rem;
}

/* ---------- login ---------- */

.login-card {
    max-width: 24rem;
    margin: 4rem auto;
    padding: 2rem 1.75rem;
    background: var(--sila-surface);
    border-radius: var(--sila-radius-lg);
    box-shadow: var(--sila-shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    text-align: center;
}

.login-card-logo {
    height: 3.5rem;
    width: auto;
    align-self: center;
}

.login-qr-code {
    width: 14rem;
    height: 14rem;
    align-self: center;
    border: 1px solid var(--sila-border);
    border-radius: var(--sila-radius-md);
    padding: 0.5rem;
    background: var(--sila-surface);
}

    .login-card h1 {
        font-size: 1.75rem;
        margin-bottom: 0.25rem;
    }

    .login-card button {
        width: 100%;
    }

.login-error {
    color: var(--sila-danger);
    font-size: 0.85rem;
    margin: 0;
}

/* ---------- chat (and every other page — Status/Catalog/Invites/Agent/
   SupportChat all reuse the same .chat-page wrapper) ---------- */

.chat-page {
    max-width: 40rem;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--sila-border);
}

    .chat-header h1 {
        font-size: 1.35rem;
    }

.start-chat-row, .send-row, .search-row, .browse-product-row {
    display: flex;
    gap: 0.5rem;
}

.start-chat-row input, .send-row input, .search-row input {
    flex: 1;
    min-width: 0;
}

.send-row {
    background: var(--sila-surface);
    border: 1px solid var(--sila-border);
    border-radius: var(--sila-radius-md);
    padding: 0.5rem;
    box-shadow: var(--sila-shadow-sm);
}

    .send-row input {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

/* ---------- chat split layout (sidebar + main) — a real messaging-app
   shell instead of everything stacked in one column ---------- */

.chat-page--split {
    max-width: 78rem;
}

.chat-shell {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    height: calc(100vh - 13rem);
    min-height: 26rem;
}

.chat-sidebar {
    flex: 0 0 19rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: var(--sila-surface);
    border: 1px solid var(--sila-border);
    border-radius: var(--sila-radius-lg);
    box-shadow: var(--sila-shadow-sm);
    padding: 1rem;
    overflow-y: auto;
}

.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: var(--sila-surface);
    border: 1px solid var(--sila-border);
    border-radius: var(--sila-radius-lg);
    box-shadow: var(--sila-shadow-sm);
    padding: 1rem;
    overflow: hidden;
}

    .chat-main .messages {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

@media (max-width: 860px) {
    .chat-shell {
        flex-direction: column;
        height: auto;
    }

    .chat-sidebar {
        flex: 0 0 auto;
        max-height: 16rem;
    }

    .chat-main .messages {
        max-height: 24rem;
    }
}

.conversation-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.conversation-list-empty, .messages-empty {
    color: var(--sila-text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 1.5rem 0.5rem;
}

.conversation-item, .status-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-align: start;
    background: var(--sila-surface);
    color: var(--sila-text);
    border: 1px solid var(--sila-border);
    padding: 0.55rem 0.7rem;
    border-radius: var(--sila-radius-md);
    cursor: pointer;
    font-weight: 600;
    box-shadow: var(--sila-shadow-sm);
    transition: border-color 0.15s ease, transform 0.05s ease, background-color 0.15s ease;
}

    .conversation-item:hover, .status-item:hover {
        border-color: var(--sila-primary-ink);
    }

    .conversation-item:active, .status-item:active {
        transform: scale(0.99);
    }

    .conversation-item.active {
        background: var(--sila-primary-light);
        border-color: var(--sila-primary-ink);
    }

.conversation-item-avatar {
    flex: 0 0 auto;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sila-primary), var(--sila-accent));
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.conversation-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-info {
    font-size: 0.82rem;
    color: var(--sila-text-muted);
    font-weight: 500;
}

/* message list */

.messages {
    list-style: none;
    padding: 0.25rem 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 12rem;
}

.messages li {
    padding: 0.6rem 0.9rem;
    border-radius: var(--sila-radius-md);
    max-width: 75%;
    box-shadow: var(--sila-shadow-sm);
    line-height: 1.45;
}

.messages li.mine {
    align-self: flex-end;
    background: var(--sila-primary);
    color: white;
    border-end-end-radius: 0.3rem;
}

    .messages li.mine .status-info,
    .messages li.mine .status {
        color: rgba(255, 255, 255, 0.75);
    }

.messages li.theirs {
    align-self: flex-start;
    background: var(--sila-surface);
    border: 1px solid var(--sila-border);
    border-end-start-radius: 0.3rem;
}

/* A picture fills its bubble but for the rounding, the way it does on the
   phone. Capped in height as well as width: a portrait photograph at full
   size is a screenful of one message. */
.msg-image,
.msg-video {
    display: block;
    max-width: 100%;
    max-height: 22rem;
    border-radius: var(--sila-radius-sm);
    margin: -0.15rem 0 0.35rem;
}

.msg-audio {
    display: block;
    width: 100%;
    min-width: 14rem;
    margin: 0.1rem 0 0.35rem;
}

/* Anything without a shape of its own is a line you can press to save it. */
.msg-file {
    display: inline-block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    text-decoration: none;
    word-break: break-word;
}

.messages li.mine .msg-file {
    color: white;
}

.send-status {
    padding: 0.25rem 0.2rem 0;
    font-size: 0.85rem;
    color: var(--sila-text-muted);
}

.send-row input[type="file"] {
    flex: 0 0 auto;
    max-width: 9rem;
}

.messages .status {
    display: block;
    font-size: 0.7rem;
    opacity: 0.75;
    margin-top: 0.2rem;
}

.msg-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.msg-actions button {
    font-size: 0.68rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
}

/* calls */

.call-video-row {
    display: flex;
    gap: 0.5rem;
    position: relative;
}

.call-video {
    background: #111225;
    border-radius: var(--sila-radius-md);
}

.call-video-remote {
    width: 320px;
    height: 240px;
    object-fit: cover;
}

.call-video-local {
    width: 100px;
    height: 75px;
    object-fit: cover;
    position: absolute;
    bottom: 8px;
    inset-inline-end: 8px;
    border: 2px solid white;
    border-radius: var(--sila-radius-sm);
}

.browse-product-row .conversation-item {
    width: auto;
    flex: 1;
}

/* ---------- misc shared bits (canned responses, rating, invites) -------- */

.canned-response-list, .directory-start, .support-open-chat, .invite-accept {
    border-radius: var(--sila-radius-md);
}

.rating-row {
    display: flex;
    gap: 0.2rem;
}

.rate-star {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    color: #d8d5ef;
}

    .rate-star:hover {
        color: var(--sila-accent);
    }

/* =========================================================================
   Framework/template chrome (Blazor boilerplate) — kept, lightly themed.
   ========================================================================= */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--sila-success);
}

.invalid {
    outline: 1px solid var(--sila-danger);
}

.validation-message {
    color: var(--sila-danger);
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: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zIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--sila-border);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: var(--sila-primary-ink);
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}


/* The header's two switches side by side, at the end opposite the name. */
.header-switches {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* The logo's lettering is navy; on the dark background it is the light copy. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) img.sila-logo { content: url("../img/logo-dark.png"); }
}
:root[data-theme="dark"] img.sila-logo { content: url("../img/logo-dark.png"); }
