/* sms/style.css */

/* --- Sidebar conversation list --- */

.conversation-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);  /* Gap between avatar and details */
    padding-bottom: var(--spacing-md) !important;  /* Space below each item */
}
.conversation-item .avatar {
    width: 40px;
    height: 40px;
    margin-right: 0;  /* Use gap instead */
}
.conversation-details {
    flex-grow: 1;
    overflow: hidden;
    margin-right: var(--spacing-sm);  /* Space before timestamp */
}
.timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-start;  /* Align timestamp to the top */
    padding-top: 2px;  /* Align roughly with contact name */
    transition: color 0.3s ease;
}

/* Active state handled by base .sidebar-list li.active */

.conversation-item.active .timestamp {
    color: var(--text-accent);  /* Use contrasting color for visibility */
}

.unread-count {
    background-color: var(--bg-accent);
    color: var(--text-accent);
    font-size: 0.7rem;
    font-weight: bold;
    padding: 1px 6px;  /* Slightly smaller padding */
    border-radius: 10px;
    margin-left: auto;  /* Push to the right */
    flex-shrink: 0;
    align-self: center;  /* Vertically center */
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.5;  /* Ensure text fits */
    min-width: 18px;  /* Ensure circle shape for single digit */
    text-align: center;
}
html[data-theme="dark"] .unread-count {
    color: var(--text-accent);  /* Ensure contrast */
}

/* --- Chat area --- */

#main-content {
    padding: 0 !important;  /* Override base padding */
}

header {
    /* Inherits base header styles */
    gap: var(--spacing-sm);  /* Gap between items */
}
header .avatar {
    width: 28px;
    height: 28px;
}
header .contact-info {
    flex-grow: 1;
    overflow: hidden;
}
header .contact-name {
    font-weight: 600;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Message list --- */

.message-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: var(--spacing-md) var(--spacing-md);  /* Consistent padding */
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);  /* Small gap between messages */
    /* Scrollbar handled by base */
    background-color: var(--bg-primary);  /* Ensure correct background */
}

.message {
    display: flex;
    margin-bottom: var(--spacing-sm);  /* Space below each message */
    max-width: 75%;  /* Max width of a message bubble */
}
.message.sent { margin-left: auto; flex-direction: row-reverse; }
.message.received { margin-right: auto; }

.message-bubble {
    padding: var(--spacing-md) var(--spacing-md);
    border-radius: 18px;  /* Bubble shape */
    position: relative;
    min-width: 120px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease, color 0.3s ease;
}
.message.sent .message-bubble {
    background-color: var(--bg-accent);  /* Use accent color */
    color: var(--text-accent);
    border-bottom-right-radius: 4px;  /* Tail effect */
}
.message.received .message-bubble {
    background-color: var(--bg-tertiary);  /* Use tertiary for received */
    color: var(--text-primary);
    border-bottom-left-radius: 4px;  /* Tail effect */
}
html[data-theme="dark"] .message.received .message-bubble {
    background-color: var(--bg-secondary);  /* Darker received bubble */
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.4;
    color: inherit;  /* Inherit from bubble */
    padding-bottom: 1.2em;  /* Space for timestamp below */
}

.message-time {
    display: block;  /* Or inline-block */
    font-size: 0.7rem;
    color: var(--text-secondary);
    position: absolute;  /* Position inside bubble */
    bottom: 5px;
    right: 12px;
    opacity: 0.8;
    transition: color 0.3s ease;
}
.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);  /* Lighter timestamp on sent bubble */
}
html[data-theme="dark"] .message.sent .message-time {
    color: rgba(26, 27, 38, 0.7);  /* Darker text on light blue */
}

/* --- Chat input area --- */

.chat-input-area {
    padding: var(--spacing-sm) var(--spacing-md);
}
.chat-input-area > div {
    /* Inherits base footer styles */
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 4px 0;
}

.chat-input-area #recipient-input,
.chat-input-area textarea {
    flex-grow: 1;
    border-radius: 18px;
    padding: 10px 15px;
    font-size: 0.95rem;
    overflow-y: auto;
    max-height: 100px;
    min-height: 45px;
    line-height: 1.4;
    resize: none;
    /* Base styles handle bg, color, border, focus */
}
/* Hide scrollbar until needed */
.chat-input-area textarea::-webkit-scrollbar { display: none }
.chat-input-area textarea:focus::-webkit-scrollbar { display: block }  /* Show on focus if scrollable */
.chat-input-area textarea { scrollbar-width: none }  /* Firefox */
.chat-input-area textarea:focus { scrollbar-width: thin }  /* Firefox */

.send-button {
    /* Inherits .icon-button, .primary */
    border-radius: 50%;  /* Ensure circular */
    width: 40px;
    height: 40px;
    padding: 8px;  /* Adjust padding for icon centering */
}
.send-button svg {
    width: 20px;
    height: 20px;
    fill: var(--icon-color-accent);  /* Ensure icon color */
}
.send-button:disabled {
    background-color: var(--text-secondary);  /* Grey out disabled */
    opacity: 0.6;
    cursor: not-allowed;
    border-color: transparent;
}
html[data-theme="dark"] .send-button:disabled {
    background-color: var(--bg-tertiary);
}

/* --- New message --- */
#new-message-button {
    margin-left: 4px;
}
.chat-input-area #recipient-input:disabled {
    display: none;  /* Hide recipient input when disabled */
}
/* .chat-input-area.composing-new .send-button { align-self: flex-end } */

/* --- Mobile adjustments --- */

@media (max-width: 767px) {
    .message { max-width: 85%; }
    .message-text { font-size: 0.9rem; }
    .chat-input-area { padding: var(--spacing-sm); }  /* Tighter padding */
}
