/**
 * CO Secure Chat — Patient-facing styles. Mobile-first.
 * @since 1.5.0
 */

/* ── Card layout ────────────────────────────────────────────────────── */

#co-chat-app {
    max-width: 480px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: #1a1a1a;
}

.co-chat-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 16px;
}

.co-chat-header {
    background: #1a5fa5;
    color: #fff;
    padding: 20px 24px 16px;
}

.co-chat-header h2 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
}

.co-chat-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.85;
}

.co-chat-body {
    padding: 20px 24px 24px;
}

/* ── Forms ───────────────────────────────────────────────────────────── */

.co-chat-body label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.co-chat-body input[type="text"],
.co-chat-body input[type="tel"],
.co-chat-body input[type="email"],
.co-chat-body input[type="date"],
.co-chat-body textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fafafa;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.co-chat-body input:focus,
.co-chat-body textarea:focus {
    outline: none;
    border-color: #1a5fa5;
    background: #fff;
}

.co-chat-toggle {
    margin-bottom: 16px;
}

.co-chat-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    cursor: pointer;
}

.co-chat-toggle input[type="radio"] {
    margin: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.co-chat-btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: #1a5fa5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.co-chat-btn:hover:not(:disabled) {
    background: #15508c;
}

.co-chat-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.co-chat-btn-secondary {
    background: transparent;
    color: #1a5fa5;
    border: 1px solid #d0d5dd;
}

.co-chat-btn-secondary:hover:not(:disabled) {
    background: #f5f8fc;
}

.co-chat-btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
    margin-top: 8px;
}

.co-chat-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #667;
    text-decoration: none;
}

.co-chat-link:hover {
    color: #1a5fa5;
}

/* ── Error ────────────────────────────────────────────────────────────── */

.co-chat-error {
    background: #fef2f2;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ── Inquiry cards ───────────────────────────────────────────────────── */

.co-chat-inquiry-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}

.co-chat-inquiry-card:hover {
    border-color: #1a5fa5;
}

.co-chat-inquiry-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1a5fa5;
    margin-bottom: 2px;
}

.co-chat-inquiry-detail {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.co-chat-inquiry-date {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.co-chat-inquiry-preview {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}

.co-chat-inquiry-general {
    border-style: dashed;
}

.co-chat-inquiry-closed {
    opacity: 0.7;
}

.co-chat-body h3 {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin: 20px 0 8px;
}

/* ── Chat window ─────────────────────────────────────────────────────── */

.co-chat-window {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 400px;
    max-height: 700px;
    overflow: hidden;
}

.co-chat-window-header {
    background: #1a5fa5;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.co-chat-back-arrow {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

.co-chat-online, .co-chat-offline {
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 10px;
}

.co-chat-online {
    background: #dcfce7;
    color: #166534;
}

.co-chat-offline {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
}

.co-chat-readonly-badge {
    margin-left: auto;
    font-size: 11px;
    background: #fef3cd;
    color: #856404;
    padding: 3px 8px;
    border-radius: 10px;
}

/* Messages area */

.co-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fb;
}

.co-chat-msg {
    max-width: 80%;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.co-chat-msg-patient {
    background: #1a5fa5;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.co-chat-msg-staff {
    background: #e8ecf1;
    color: #1a1a1a;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.co-chat-msg-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.co-chat-msg-body {
    white-space: pre-wrap;
}

.co-chat-msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.co-chat-msg-attachment {
    font-size: 12px;
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
}

.co-chat-msg-staff .co-chat-msg-attachment {
    background: rgba(0,0,0,0.05);
}

/* Compose area */

.co-chat-compose {
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    background: #fff;
    flex-shrink: 0;
}

.co-chat-compose textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    box-sizing: border-box;
    font-family: inherit;
}

.co-chat-compose textarea:focus {
    outline: none;
    border-color: #1a5fa5;
}

.co-chat-compose-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.co-chat-attach-label {
    font-size: 13px;
    color: #1a5fa5;
    cursor: pointer;
    font-weight: 500;
}

.co-chat-compose-actions .co-chat-btn {
    width: auto;
    padding: 8px 24px;
    margin-top: 0;
}

/* Read-only mode */
.co-chat-readonly .co-chat-compose {
    display: none;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 520px) {
    #co-chat-app {
        max-width: 100%;
        margin: 0;
    }

    .co-chat-card {
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .co-chat-window {
        border-radius: 0;
        height: calc(100vh - 60px);
        max-height: none;
    }
}
