/* Shared messaging UI */

.msg-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: -8px 0 -8px -8px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--app-text);
    font-size: 1.35rem;
    cursor: pointer;
    flex-shrink: 0;
}

.msg-back-btn:active {
    background: rgba(255, 255, 255, 0.08);
}

.msg-compose-page,
.msg-thread-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--app-topbar-height) - var(--app-nav-height) - 32px);
    padding-bottom: 0;
    max-width: var(--app-max-content);
}

.msg-compose-header,
.msg-thread-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-top: 4px;
}

.msg-compose-heading,
.msg-thread-heading {
    min-width: 0;
    flex: 1;
}

.msg-compose-title,
.msg-thread-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1.3;
}

.msg-compose-sub,
.msg-thread-sub {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--app-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-job-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
}

.msg-job-card-icon {
    font-size: 1.25rem;
    color: var(--ui-primary);
    flex-shrink: 0;
}

.msg-job-card-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-job-card-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
}

.msg-job-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--app-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-job-card-link {
    flex-shrink: 0;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: var(--ui-primary-muted);
    color: var(--ui-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.msg-compose-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-compose-textarea {
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    min-height: 200px;
    border-radius: var(--app-radius-lg);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    padding: 16px;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    font-family: inherit;
}

.msg-compose-textarea::placeholder {
    color: var(--app-text-muted);
}

.msg-char-count {
    align-self: flex-end;
    font-size: 0.75rem;
    color: var(--app-text-muted);
    font-variant-numeric: tabular-nums;
}

.msg-compose-footer {
    padding: 16px 0 8px;
    position: sticky;
    bottom: 0;
    background: linear-gradient(transparent, var(--app-bg) 24%);
}

.msg-job-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--ui-primary-muted);
    border-radius: var(--app-radius);
    background: var(--ui-primary-muted);
    color: var(--ui-primary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.msg-job-banner-chevron {
    margin-left: auto;
    opacity: 0.7;
}

.msg-thread-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 16px;
    -webkit-overflow-scrolling: touch;
}

.msg-thread-empty {
    text-align: center;
    color: var(--app-text-muted);
    font-size: 0.9rem;
    padding: 32px 16px;
}

.msg-bubble-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-bubble-row {
    display: flex;
}

.msg-bubble-row.mine {
    justify-content: flex-end;
}

.msg-bubble-row.theirs {
    justify-content: flex-start;
}

.msg-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-bubble-row.mine .msg-bubble {
    background: var(--ui-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-bubble-row.theirs .msg-bubble {
    background: var(--app-surface-raised);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    border-bottom-left-radius: 4px;
}

.msg-invoice-card {
    max-width: 88%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: var(--app-surface-raised);
    border: 1px solid var(--app-border);
    cursor: pointer;
}

.msg-invoice-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.msg-invoice-card-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--app-text);
}

.msg-invoice-card-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-invoice-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--app-text-secondary);
}

.msg-invoice-card-total {
    padding-top: 8px;
    border-top: 1px solid var(--app-border);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--app-text);
}

.msg-invoice-card-cta {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--app-text);
    color: var(--app-bg);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.msg-invoice-card-cta:disabled {
    opacity: 0.5;
    cursor: default;
}

.msg-invoice-card-paid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(111, 214, 127, 0.12);
    color: #6fd67f;
    font-weight: 700;
    font-size: 0.9rem;
}

.msg-schedule-card {
    max-width: 88%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: var(--app-surface-raised);
    border: 1px solid var(--app-border);
}

.msg-schedule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.msg-schedule-card-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--app-text);
}

.msg-schedule-card-date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--app-text);
}

.msg-schedule-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-schedule-card-cta-secondary {
    padding: 10px 16px;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    background: transparent;
    color: var(--app-text);
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.msg-schedule-card-cta-secondary:disabled {
    opacity: 0.5;
    cursor: default;
}

.msg-invoice-error {
    margin-top: 8px;
}

.msg-rating-card {
    max-width: 88%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: var(--app-surface-raised);
    border: 1px solid var(--app-border);
}

.msg-rating-card-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--app-text);
}

.msg-rating-picker {
    display: flex;
    gap: 4px;
}

.msg-rating-star-btn {
    background: transparent;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--ui-primary);
    font-size: 1.5rem;
    line-height: 1;
}

.msg-rating-comment {
    width: 100%;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    padding: 10px 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    font-family: inherit;
}

.msg-rating-comment::placeholder {
    color: var(--app-text-muted);
}

.msg-rating-stars-readonly {
    display: flex;
    gap: 2px;
    color: var(--ui-primary);
    font-size: 1.1rem;
}

.msg-rating-comment-text {
    margin: 0;
    font-size: 0.88rem;
    color: var(--app-text-secondary);
    line-height: 1.4;
}

.msg-thread-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 0 8px;
    border-top: 1px solid var(--app-border);
    background: var(--app-bg);
    position: sticky;
    bottom: 0;
}

.msg-reply-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 14px;
    border-radius: 22px;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    font-size: 0.95rem;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}

.msg-reply-input::placeholder {
    color: var(--app-text-muted);
}

.msg-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--ui-primary);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.msg-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.msg-send-btn:not(:disabled):active {
    background: var(--ui-primary-hover);
}

.inbox-page .page-header {
    margin-bottom: 16px;
}

.inbox-thread-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inbox-thread-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    background: var(--app-surface);
    color: inherit;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.inbox-thread-item:active {
    background: var(--app-surface-raised);
}

.inbox-thread-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--ui-primary-muted);
    color: var(--ui-primary);
    font-size: 0.95rem;
    font-weight: 700;
}

img.inbox-thread-avatar {
    object-fit: cover;
}

.msg-thread-avatar,
.msg-compose-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--ui-primary-muted);
    color: var(--ui-primary);
    font-size: 0.85rem;
    font-weight: 700;
}

img.msg-thread-avatar,
img.msg-compose-avatar {
    object-fit: cover;
}

.inbox-thread-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inbox-thread-top {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inbox-thread-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--app-text);
}

.inbox-thread-job {
    font-size: 0.78rem;
    color: var(--ui-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-thread-preview {
    font-size: 0.85rem;
    color: var(--app-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-thread-chevron {
    flex-shrink: 0;
    color: var(--app-text-muted);
    font-size: 0.9rem;
}

.job-view-page {
    padding-bottom: 24px;
}

.job-view-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.job-view-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.job-view-media {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    border-radius: var(--app-radius-lg);
    overflow: hidden;
}

.job-view-image {
    display: block;
    width: 100%;
    height: auto;
}

.job-view-video {
    display: block;
    width: 100%;
    background: #000;
}

.job-view-body {
    padding: 0 4px;
}

.job-view-name {
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 700;
}

.job-view-desc {
    margin: 0 0 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--app-text-secondary);
    white-space: pre-wrap;
}

.job-view-meta {
    margin: 0;
    font-size: 0.88rem;
    color: var(--app-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
