/* Patient Page Specific Styles */

.patient-view {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    padding: 24px 32px;
}

/* Patient Header */
.patient-header {
    margin-bottom: 24px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

.patient-profile {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.patient-avatar {
    position: relative;
    flex-shrink: 0;
}

.patient-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: cover;
}

.twin-active-indicator {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    border: 3px solid var(--bg-card);
}

.patient-info {
    flex: 1;
}

.patient-name-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.patient-name-row h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.patient-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.patient-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.patient-meta i {
    color: var(--text-muted);
}

.patient-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.tag.condition {
    background: var(--info-light);
    color: var(--info);
}

.tag.insurance {
    background: var(--neutral-light);
    color: var(--neutral);
}

.patient-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-card);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Patient Grid */
.patient-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

/* Chat Panels Section */
.chat-panels-section {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Chat Tabs */
.chat-tabs {
    display: flex;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.chat-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.chat-tab:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.02);
}

.chat-tab.active {
    color: var(--primary);
    background: var(--bg-card);
}

.chat-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--primary));
}

.chat-tab i {
    font-size: 16px;
}

.tab-badge {
    background: var(--critical);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Chat Panels */
.chat-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-panel.active {
    display: flex;
}

/* Digital Twin Section (existing styles now nested) */
#digital-twin-panel {
    /* inherits from chat-panel */
}

.twin-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
}

.twin-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.twin-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.twin-header-left h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.twin-header-left p {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
}

.twin-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
}

.status-dot.active {
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Container */
.twin-chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Chat Messages */
.chat-message {
    display: flex;
    gap: 12px;
}

.chat-message.system {
    justify-content: center;
}

.chat-message.system .message-content {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-message.system i {
    color: var(--accent);
}

.chat-message.doctor {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    font-size: 16px;
}

.message-avatar.doctor {
    background: none;
}

.message-avatar.doctor img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
}

.message-body {
    flex: 1;
    max-width: 85%;
}

.chat-message.doctor .message-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.chat-message.doctor .message-header {
    flex-direction: row-reverse;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
}

.message-body .message-content {
    background: var(--bg-primary);
    padding: 16px 20px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.chat-message.doctor .message-body .message-content {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 16px;
    border-top-right-radius: 4px;
}

.message-content p {
    margin: 0 0 12px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 0 0 12px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 8px;
}

.message-content .highlight {
    background: rgba(239, 68, 68, 0.15);
    color: var(--critical);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.message-content .highlight.alert {
    background: rgba(239, 68, 68, 0.15);
    color: var(--critical);
}

.message-content .recommendation {
    background: rgba(0, 195, 209, 0.1);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    margin-top: 12px;
}

.message-content .recommendation i {
    color: var(--accent);
}

.message-sources {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.source {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Data Cards in Chat */
.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
}

.data-card h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.data-card h4 i {
    color: var(--primary);
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.data-item {
    text-align: center;
}

.data-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.data-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Chart Placeholder */
.chart-placeholder {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
}

.ecg-wave {
    position: relative;
}

.ecg-wave svg {
    width: 100%;
    height: 60px;
}

.chart-label {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    color: var(--critical);
    background: var(--critical-light);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Episode History */
.episode-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.episode {
    display: flex;
    align-items: center;
    gap: 12px;
}

.episode-date {
    font-size: 12px;
    color: var(--text-muted);
    width: 50px;
}

.episode-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    border-radius: 4px;
}

.episode-duration {
    font-size: 12px;
    color: var(--text-secondary);
    width: 60px;
}

.insight {
    background: var(--info-light);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 3px solid var(--info);
    font-size: 13px;
}

.insight i {
    color: var(--info);
}

/* Adherence Grid */
.adherence-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
}

.adherence-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.med-name {
    font-size: 13px;
    color: var(--text-secondary);
    width: 140px;
}

.adherence-bar-container {
    flex: 1;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.adherence-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    border-radius: 4px;
}

.adherence-bar.warning {
    background: var(--warning);
}

.adherence-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    width: 45px;
    text-align: right;
}

.adherence-value.warning {
    color: var(--warning);
}

.note {
    background: var(--warning-light);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 3px solid var(--warning);
    font-size: 13px;
    color: var(--text-secondary);
}

.note i {
    color: var(--warning);
}

/* Patient Chat Excerpts */
.patient-chat-excerpt {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 12px 0;
    overflow: hidden;
}

.excerpt-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-primary);
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.excerpt-header i {
    color: var(--primary);
}

.excerpt-content {
    padding: 16px;
}

.excerpt-message {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.excerpt-message:last-child {
    margin-bottom: 0;
}

.excerpt-message.patient {
    background: var(--bg-primary);
    margin-right: 40px;
}

.excerpt-message.ai {
    background: linear-gradient(135deg, rgba(0, 195, 209, 0.1), rgba(20, 83, 213, 0.1));
    margin-left: 40px;
}

.excerpt-message strong {
    color: var(--text-primary);
}

.summary {
    background: var(--success-light);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 3px solid var(--success);
    font-size: 13px;
    margin-top: 16px;
}

.summary i {
    color: var(--success);
}

/* Chat Input */
.chat-input-container {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.chat-suggestions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.suggestion-chip {
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.chat-input {
    display: flex;
    gap: 12px;
}

.chat-input input {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input input:focus {
    border-color: var(--accent);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

/* Patient Sidebar */
.patient-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
}

.sidebar-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sidebar-card-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sidebar-card-header i {
    color: var(--primary);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--success);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

.btn-text-small {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
}

.btn-text-small:hover {
    text-decoration: underline;
}

/* Wearable Grid */
.wearable-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.wearable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
}

.wearable-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.wearable-icon.heart {
    background: var(--critical-light);
    color: var(--critical);
}

.wearable-icon.glucose {
    background: var(--info-light);
    color: var(--info);
}

.wearable-icon.bp {
    background: #fce7f3;
    color: #db2777;
}

.wearable-icon.steps {
    background: var(--success-light);
    color: var(--success);
}

.wearable-icon.sleep {
    background: #ede9fe;
    color: #7c3aed;
}

.wearable-icon.weight {
    background: var(--warning-light);
    color: var(--warning);
}

.wearable-data {
    flex: 1;
}

.wearable-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.wearable-value small {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.wearable-label {
    font-size: 11px;
    color: var(--text-muted);
}

.wearable-trend {
    display: block;
    font-size: 10px;
    font-weight: 500;
}

.wearable-trend.up {
    color: var(--warning);
}

.wearable-time {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
}

.connected-devices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.device {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 6px 10px;
    border-radius: 6px;
}

/* History Section */
.history-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.history-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.history-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
}

.condition-list, .med-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.condition-list li, .med-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    padding: 6px 0;
}

.condition-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neutral);
}

.condition-dot.critical {
    background: var(--critical);
}

.condition-dot.warning {
    background: var(--warning);
}

.labs-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lab-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.lab-name {
    color: var(--text-secondary);
    width: 50px;
}

.lab-value {
    font-weight: 600;
    color: var(--text-primary);
}

.lab-value.warning {
    color: var(--warning);
}

.lab-date {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
}

/* Quick Actions */
.actions-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-card);
}

.action-btn i {
    font-size: 14px;
}

/* Patient Direct Chat Panel */
.patient-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.patient-chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.patient-chat-avatar {
    position: relative;
}

.patient-chat-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.online-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--neutral);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.online-status.online {
    background: var(--success);
}

.patient-chat-header-left h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
}

.patient-chat-header-left p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.patient-chat-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.header-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.patient-chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Conversation History */
.conversation-history {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-date-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 8px 0;
}

.history-date-divider::before,
.history-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.history-date-divider span {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.history-date-divider.current span {
    color: var(--primary);
    font-weight: 600;
}

.conversation-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.conversation-preview:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.conversation-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    min-width: 140px;
}

.conversation-date i {
    color: var(--primary);
}

.conversation-summary {
    flex: 1;
}

.conversation-summary p {
    margin: 0;
    font-size: 13px;
    color: var(--text-primary);
}

.conversation-summary .preview-text {
    color: var(--text-secondary);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.expand-icon {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.2s;
}

.conversation-preview.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Direct Chat Messages */
.direct-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.direct-message {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.direct-message.patient {
    align-self: flex-start;
}

.direct-message.doctor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.direct-message-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.direct-message-content {
    display: flex;
    flex-direction: column;
}

.direct-message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.sender-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-timestamp {
    font-size: 11px;
    color: var(--text-muted);
}

.direct-message-bubble {
    background: var(--bg-primary);
    padding: 12px 16px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

.direct-message.doctor .direct-message-bubble {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 16px;
    border-top-right-radius: 4px;
}

.direct-message-bubble p {
    margin: 0;
}

.direct-message-bubble.attachment {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 10px;
}

.attachment-preview i {
    color: var(--primary);
    font-size: 20px;
}

.attachment-preview span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* AI Draft Suggestion */
.ai-draft-suggestion {
    background: linear-gradient(135deg, rgba(0, 195, 209, 0.08), rgba(20, 83, 213, 0.08));
    border: 1px solid var(--accent);
    border-radius: var(--border-radius);
    padding: 16px;
    margin: 8px 0;
}

.ai-draft-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

.ai-draft-header i {
    font-size: 16px;
    color: var(--accent);
}

.draft-badge {
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.ai-draft-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    margin-bottom: 12px;
}

.ai-draft-content p {
    margin: 0 0 12px 0;
}

.ai-draft-content p:last-child {
    margin-bottom: 0;
}

.ai-draft-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.ai-draft-content li {
    margin-bottom: 4px;
}

.ai-draft-actions {
    display: flex;
    gap: 10px;
}

.draft-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.draft-btn.use {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    border: none;
}

.draft-btn.use:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.draft-btn.edit {
    background: var(--bg-card);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.draft-btn.edit:hover {
    background: var(--primary);
    color: white;
}

.draft-btn.dismiss {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.draft-btn.dismiss:hover {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: 16px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Direct Chat Input */
.direct-chat-input-container {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.input-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.toolbar-btn.ai-assist {
    margin-left: auto;
}

.toolbar-btn.ai-assist.active {
    background: linear-gradient(135deg, rgba(0, 195, 209, 0.1), rgba(20, 83, 213, 0.1));
    border-color: var(--accent);
    color: var(--primary);
}

.toolbar-btn.ai-assist.active i {
    color: var(--accent);
}

.direct-chat-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.direct-chat-input textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.direct-chat-input textarea:focus {
    border-color: var(--accent);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 12px;
    color: var(--text-muted);
}

.send-message-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.send-message-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Responsive */
@media (max-width: 1200px) {
    .patient-grid {
        grid-template-columns: 1fr;
    }

    .patient-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-card {
        flex: 1;
        min-width: 300px;
    }
}

@media (max-width: 768px) {
    .patient-profile {
        flex-direction: column;
        align-items: flex-start;
    }

    .patient-actions {
        width: 100%;
    }

    .patient-actions .btn-primary,
    .patient-actions .btn-secondary {
        flex: 1;
    }

    .data-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .wearable-grid {
        grid-template-columns: 1fr;
    }
}
