/*
================================================================================
Rain City Maids Design System
File: /Content/css/rcm-design-system.css
Loaded site-wide via Site.Master <head>.

NAMING:    All classes prefixed `rcm-` to avoid Bootstrap/DevExpress collisions.
LAYERING:  Wraps DevExpress controls; doesn't replace them. Existing pages keep
           working — new/touched pages adopt the wrappers and tokens.
DOCS:      /Documentation/Design-System/README.md (live catalog).

WHEN ADDING TO THIS FILE:
- Only ship classes that something actually uses today (organic growth).
- Document new classes in the README before reuse on another page.
- Light theme only. Never hardcode dark-mode colors here.
- No dependency on jQuery/JS — design system is pure CSS.
================================================================================
*/

/* ==============================================================================
   TOKENS
   CSS custom properties consumed by every component class below. Scoped to
   :root so existing pages aren't affected unless they reference these tokens.
   ============================================================================== */
:root {
    /* Brand palette */
    --rcm-color-brand: #00AEEF;
    --rcm-color-brand-dark: #0098d3;
    --rcm-color-brand-darker: #0080c0;
    --rcm-color-brand-tint: #e0f4fc;

    /* Neutrals (light theme) */
    --rcm-color-bg: #ffffff;
    --rcm-color-bg-subtle: #fafbfc;
    --rcm-color-bg-muted: #f5f7fa;
    --rcm-color-bg-hover: #f7f9fc;
    --rcm-color-border: #e8ecf1;
    --rcm-color-border-strong: #d8dde3;
    --rcm-color-divider: #ecf0f3;

    /* Text */
    --rcm-color-text: #1f2937;
    --rcm-color-text-muted: #4b5563;
    --rcm-color-text-subtle: #6b7280;
    --rcm-color-text-faint: #9ca3af;

    /* Semantic */
    --rcm-color-success: #047857;
    --rcm-color-success-bg: #ecfdf5;
    --rcm-color-info: #075985;
    --rcm-color-info-bg: #e0f2fe;
    --rcm-color-warning: #92400e;
    --rcm-color-warning-bg: #fef3c7;
    --rcm-color-danger: #b91c1c;
    --rcm-color-danger-bg: #fee2e2;
    --rcm-color-purple: #6d28d9;
    --rcm-color-purple-bg: #ede9fe;

    /* Channel colors (Communications + future channel indicators) */
    --rcm-channel-email-fg: #0288d1;
    --rcm-channel-email-bg: #e7f4fb;
    --rcm-channel-sms-fg: #2e7d32;
    --rcm-channel-sms-bg: #e8f5e9;
    --rcm-channel-call-fg: #c2410c;
    --rcm-channel-call-bg: #fff4e5;

    /* Spacing scale */
    --rcm-space-1: 4px;
    --rcm-space-2: 8px;
    --rcm-space-3: 12px;
    --rcm-space-4: 16px;
    --rcm-space-5: 24px;
    --rcm-space-6: 32px;

    /* Radius */
    --rcm-radius-sm: 4px;
    --rcm-radius-md: 6px;
    --rcm-radius-lg: 8px;
    --rcm-radius-pill: 999px;

    /* Shadows */
    --rcm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --rcm-shadow-md: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 20px rgba(0, 0, 0, 0.04);
    --rcm-shadow-focus: 0 0 0 3px rgba(0, 174, 239, 0.10);

    /* Type sizes (font-family inherited from existing body styles) */
    --rcm-font-xs: 10.5px;
    --rcm-font-sm: 12px;
    --rcm-font-md: 13px;
    --rcm-font-base: 14px;
    --rcm-font-lg: 16px;
    --rcm-font-xl: 18px;

    /* Transitions */
    --rcm-transition-fast: 0.1s ease;
    --rcm-transition-base: 0.15s ease;
}

/* ==============================================================================
   PAGE HEADER
   Generic page-header pattern with avatar + name + meta + actions.
   Use on CustomerEdit, EmployeeEdit, ContactEdit, etc.
   ============================================================================== */
.rcm-page-header {
    padding: 18px 28px;
    border-bottom: 1px solid var(--rcm-color-divider);
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--rcm-color-bg);
}
.rcm-page-header-title {
    flex: 1;
    min-width: 0;
}
.rcm-page-header-name {
    font-size: var(--rcm-font-xl);
    font-weight: 600;
    color: var(--rcm-color-text);
    line-height: 1.3;
}
.rcm-page-header-meta {
    color: var(--rcm-color-text-subtle);
    font-size: 12.5px;
    margin-top: 2px;
}
.rcm-page-header-actions {
    display: flex;
    gap: var(--rcm-space-2);
    flex-shrink: 0;
}

/* ==============================================================================
   AVATAR
   Gradient circle with initials (or icon).
   ============================================================================== */
.rcm-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--rcm-color-brand), var(--rcm-color-brand-darker));
    border-radius: 50%;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--rcm-font-lg);
    box-shadow: 0 2px 6px rgba(0, 174, 239, 0.30);
    flex-shrink: 0;
}
.rcm-avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.rcm-avatar-lg { width: 56px; height: 56px; font-size: 20px; }

/* ==============================================================================
   PILL — small status indicator (Active, Inactive, etc.)
   Modifier class controls color: .rcm-pill-success | .rcm-pill-info | etc.
   ============================================================================== */
.rcm-pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: var(--rcm-font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--rcm-color-bg-muted);
    color: var(--rcm-color-text-muted);
}
.rcm-pill-success { background: var(--rcm-color-success-bg); color: var(--rcm-color-success); }
.rcm-pill-info    { background: var(--rcm-color-info-bg);    color: var(--rcm-color-info); }
.rcm-pill-warning { background: var(--rcm-color-warning-bg); color: var(--rcm-color-warning); }
.rcm-pill-danger  { background: var(--rcm-color-danger-bg);  color: var(--rcm-color-danger); }

/* ==============================================================================
   TAB STRIP
   Generic tab navigation. Use with `<a>` or `<button>` elements.
   Active tab marked via `.active` class.
   ============================================================================== */
.rcm-tab-strip {
    display: flex;
    border-bottom: 1px solid var(--rcm-color-divider);
    padding: 0 24px;
    background: var(--rcm-color-bg-subtle);
}
.rcm-tab-strip a,
.rcm-tab-strip button {
    padding: 12px 16px;
    color: var(--rcm-color-text-subtle);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: var(--rcm-font-md);
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--rcm-transition-base);
}
.rcm-tab-strip a.active,
.rcm-tab-strip button.active {
    color: var(--rcm-color-brand);
    border-bottom-color: var(--rcm-color-brand);
    background: var(--rcm-color-bg);
}
.rcm-tab-strip a:hover:not(.active),
.rcm-tab-strip button:hover:not(.active) {
    color: var(--rcm-color-text);
}

/* ==============================================================================
   TOOLBAR — section header with controls (filter chips, search, actions)
   ============================================================================== */
.rcm-toolbar {
    padding: var(--rcm-space-3) 24px;
    border-bottom: 1px solid var(--rcm-color-divider);
    display: flex;
    align-items: center;
    gap: var(--rcm-space-3);
    background: var(--rcm-color-bg-subtle);
}
.rcm-toolbar-spacer { flex: 1; }

/* ==============================================================================
   FILTER CHIPS — segmented filter group (All / Email / SMS / Calls etc.)
   ============================================================================== */
.rcm-filter-chips {
    display: flex;
    gap: 2px;
    background: #f0f2f5;
    padding: 3px;
    border-radius: 7px;
}
.rcm-chip {
    padding: 5px 13px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--rcm-color-text-subtle);
    background: transparent;
    border: none;
    transition: all var(--rcm-transition-base);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: var(--rcm-space-2);
}
.rcm-chip.active {
    background: var(--rcm-color-bg);
    color: var(--rcm-color-brand);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.rcm-chip:hover:not(.active) { color: var(--rcm-color-text); }
.rcm-chip > i { font-size: 11px; }
.rcm-chip-count {
    background: #e5e7eb;
    color: var(--rcm-color-text-muted);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
    margin-left: 2px;
}
.rcm-chip.active .rcm-chip-count {
    background: var(--rcm-color-brand-tint);
    color: var(--rcm-color-brand);
}

/* ==============================================================================
   TOOLBAR SEARCH INPUT
   ============================================================================== */
.rcm-toolbar-search {
    background: var(--rcm-color-bg);
    border: 1px solid #e0e4e9;
    padding: 6px 12px 6px 32px;
    border-radius: var(--rcm-radius-md);
    width: 220px;
    font-size: 12.5px;
    font-family: inherit;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239ca3af' stroke-width='2'><circle cx='7' cy='7' r='5'/><line x1='11' y1='11' x2='14' y2='14'/></svg>");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 14px;
}
.rcm-toolbar-search:focus {
    outline: none;
    border-color: var(--rcm-color-brand);
    box-shadow: var(--rcm-shadow-focus);
}

/* ==============================================================================
   DAY DIVIDER — chronological separator in lists/timelines
   ============================================================================== */
.rcm-day-divider {
    text-align: center;
    margin: var(--rcm-space-4) 0 var(--rcm-space-2);
    font-size: var(--rcm-font-xs);
    color: var(--rcm-color-text-faint);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    position: relative;
}
.rcm-day-divider > span {
    background: var(--rcm-color-bg);
    padding: 0 var(--rcm-space-3);
    position: relative;
    z-index: 1;
}
.rcm-day-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #f0f2f5;
}

/* ==============================================================================
   ROW — list-item pattern (icon + body + meta + time)
   Used for communications timelines, activity logs, message lists, etc.
   ============================================================================== */
.rcm-row {
    display: flex;
    align-items: flex-start;
    gap: var(--rcm-space-3);
    padding: var(--rcm-space-3);
    border-radius: var(--rcm-radius-lg);
    cursor: pointer;
    transition: all var(--rcm-transition-fast);
    border: 1px solid transparent;
    margin-bottom: 2px;
}
.rcm-row:hover {
    background: var(--rcm-color-bg-hover);
    border-color: var(--rcm-color-border);
}

.rcm-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--rcm-font-base);
    flex-shrink: 0;
    position: relative;
    background: var(--rcm-color-bg-muted);
    color: var(--rcm-color-text-muted);
}
/* Channel-colored icon variants */
.rcm-row.rcm-channel-email .rcm-row-icon { background: var(--rcm-channel-email-bg); color: var(--rcm-channel-email-fg); }
.rcm-row.rcm-channel-sms   .rcm-row-icon { background: var(--rcm-channel-sms-bg);   color: var(--rcm-channel-sms-fg); }
.rcm-row.rcm-channel-call  .rcm-row-icon { background: var(--rcm-channel-call-bg);  color: var(--rcm-channel-call-fg); }

/* Direction arrow badge on icon (in/out/missed) */
.rcm-row-dir {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    border: 1.5px solid #ffffff;
}
.rcm-row.rcm-dir-in     .rcm-row-dir { color: var(--rcm-color-success); background: #d1fae5; }
.rcm-row.rcm-dir-out    .rcm-row-dir { color: #1d4ed8;                  background: #dbeafe; }
.rcm-row.rcm-dir-missed .rcm-row-dir { color: var(--rcm-color-danger);  background: var(--rcm-color-danger-bg); }

.rcm-row-body { flex: 1; min-width: 0; }
.rcm-row-line1 {
    display: flex;
    align-items: center;
    gap: var(--rcm-space-2);
    margin-bottom: 3px;
}
.rcm-row-from {
    font-weight: 600;
    color: var(--rcm-color-text);
    font-size: 13.5px;
}
.rcm-row-from-meta {
    color: var(--rcm-color-text-subtle);
    font-size: var(--rcm-font-sm);
    font-weight: 400;
}
.rcm-row-time {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--rcm-color-text-faint);
    flex-shrink: 0;
}
.rcm-row-line2 {
    color: var(--rcm-color-text-muted);
    font-size: var(--rcm-font-md);
    line-height: 1.45;
    /* 2-line clamp; rows past 2 lines truncate with ellipsis. Detail popup shows full content. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.rcm-row-subject {
    font-weight: 600;
    color: var(--rcm-color-text);
    margin-right: 6px;
}
.rcm-row-line3 {
    margin-top: 5px;
    display: flex;
    gap: 14px;
    font-size: 11px;
    color: var(--rcm-color-text-faint);
    align-items: center;
}
.rcm-row-line3 i { margin-right: 4px; }

/* ==============================================================================
   META PILL — inline icon+text annotation (small, in row meta lines)
   ============================================================================== */
.rcm-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ==============================================================================
   BADGE — short status tag (Bot, Unread, Opened, Failed, Draft)
   Modifier class controls color.
   ============================================================================== */
.rcm-badge {
    display: inline-block;
    font-size: 9.5px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--rcm-color-bg-muted);
    color: var(--rcm-color-text-muted);
}
.rcm-badge-bot    { background: var(--rcm-color-purple-bg);  color: var(--rcm-color-purple); }
.rcm-badge-unread { background: var(--rcm-color-brand);      color: #ffffff; }
.rcm-badge-opened { background: #f0fdf4;                     color: #166534; }
.rcm-badge-failed { background: var(--rcm-color-danger-bg);  color: var(--rcm-color-danger); }
.rcm-badge-draft  { background: var(--rcm-color-warning-bg); color: var(--rcm-color-warning); }

/* ==============================================================================
   ICON BUTTON — neutral square icon-only button
   ============================================================================== */
.rcm-icon-btn {
    background: transparent;
    border: none;
    color: var(--rcm-color-text-subtle);
    width: 30px;
    height: 30px;
    border-radius: var(--rcm-radius-sm);
    cursor: pointer;
    font-size: var(--rcm-font-base);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rcm-icon-btn:hover {
    background: #eef1f5;
    color: var(--rcm-color-text);
}

/* ==============================================================================
   BUTTONS
   .rcm-btn-primary — brand-colored CTA
   .rcm-btn-ghost   — neutral outlined button
   ============================================================================== */
.rcm-btn {
    padding: 7px 16px;
    border-radius: var(--rcm-radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 12.5px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    transition: all var(--rcm-transition-base);
    text-decoration: none;
}
.rcm-btn-primary {
    background: var(--rcm-color-brand);
    color: #ffffff;
    border-color: var(--rcm-color-brand);
}
.rcm-btn-primary:hover {
    background: var(--rcm-color-brand-dark);
    border-color: var(--rcm-color-brand-dark);
    color: #ffffff;
}
.rcm-btn-ghost {
    background: var(--rcm-color-bg);
    border-color: #d1d5db;
    color: var(--rcm-color-text-muted);
}
.rcm-btn-ghost:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: var(--rcm-color-text-muted);
    text-decoration: none;
}

/* ==============================================================================
   dxPopup global scroll-wheel fix
   Every dxPopup must be scrollable with the mouse wheel when content overflows.
   This used to require a per-popup `$('#myPopup .dx-popup-content').css(...)` call
   (see CLAUDE.md "dxPopup content MUST be scrollable"); this rule makes it global
   so new popups don't have to opt in.
   ============================================================================== */
.dx-popup-wrapper .dx-popup-content {
    overflow-y: auto !important;
}

/* ==============================================================================
   EMAIL MESSAGE — single message inside an email thread.
   Class names (.email-message, .email-message-header, etc.) match TodaySales.css
   so an email thread renders identically wherever it's shown. Originally lived in
   TodaySales.css; promoted here in 2026-05 so CustomerEdit's Communications popup
   could use the same look without duplicating styles.
   ============================================================================== */
.email-message {
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    margin-bottom: 12px;
    background: #ffffff;
}
.email-message.inbound { border-left: 3px solid #e0e0e0; }
.email-message.outbound { border-left: 3px solid var(--rcm-color-brand); }

.email-message-header {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
}
.email-message.outbound .email-message-header { background: #f0f8ff; }
.email-message-header:hover { background: #f0f0f0; }
.email-message.outbound .email-message-header:hover { background: #e8f4fd; }

.email-message.collapsed { border-bottom-width: 1px; }
.email-message.collapsed .email-message-header { border-bottom: none; border-radius: 6px; }

.email-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
    margin-right: 12px;
    flex-shrink: 0;
}
.email-message.inbound .email-message-avatar { background-color: #6c757d; }
.email-message.outbound .email-message-avatar { background-color: var(--rcm-color-brand); }

.email-message-meta { flex: 1; min-width: 0; }
.email-message-sender {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}
.email-message-preview {
    font-weight: 400;
    color: #999;
    font-size: 12px;
    margin-left: 4px;
}
.email-message-addresses {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.email-message-addresses.hidden { display: none; }
.email-message-date {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
    margin-left: 12px;
    flex-shrink: 0;
}
.email-collapse-icon {
    font-size: 11px;
    color: #bbb;
    margin-left: 8px;
    flex-shrink: 0;
    align-self: center;
}

.email-message-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    word-wrap: break-word;
}
.email-message-body p { margin: 0; }
.email-message-body img { max-width: 100%; height: auto; }
.email-message-body table { max-width: 100%; }
.email-message-body a { color: var(--rcm-color-brand); }
.email-message-body.empty {
    color: var(--rcm-color-text-faint);
    font-style: italic;
    font-size: 13px;
}
.email-message-body.empty i { margin-right: 6px; }

/* Search-match highlight — yellow halo around any matched message in a detail view.
   Works across email-message blocks AND SMS chat bubbles (both inbound and outbound). */
.rcm-search-match {
    box-shadow: 0 0 0 2px #ffb74d, 0 0 14px rgba(255, 183, 77, 0.55);
    background-color: #fff8e1 !important;
    border-color: #ffb74d !important;
}
.rcm-bubble.out.rcm-search-match {
    /* Outbound bubbles use a brand-blue gradient; preserve the gradient and just ring it. */
    background: linear-gradient(135deg, var(--rcm-color-brand), var(--rcm-color-brand-dark)) !important;
    color: #ffffff !important;
}

/* X close button — site-wide close affordance for master-detail div-swap panels.
   Matches the TodaySales detail-header pattern. Bumped to 22px in 2026-05 so it reads as
   a clearly-tappable "large X" rather than a thin icon. */
.email-conv-close-btn {
    font-size: 22px;
    color: #aaa;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
}
.email-conv-close-btn:hover { color: #d9534f; }

/* "..." toggle that hides quoted reply chains within an email body */
.email-quoted-toggle {
    display: inline-block;
    padding: 2px 8px;
    margin: 8px 0;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #888;
    user-select: none;
}
.email-quoted-toggle:hover { background: #e0e0e0; color: #555; }
.email-quoted-hidden { color: #666; font-size: 13px; }

/* ==============================================================================
   EMPTY STATE
   ============================================================================== */
.rcm-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--rcm-color-text-faint);
    font-size: var(--rcm-font-md);
}
.rcm-empty-state > i {
    font-size: 28px;
    margin-bottom: var(--rcm-space-2);
    opacity: 0.5;
    display: block;
}
