/* ========== DEAR DIARY PAGE - MOBILE-FIRST MESSAGING ========== */

/* Page Background */
#diary-page {
    background: linear-gradient(180deg, #fcf9f3 0%, #FFE5D9 100%);
    min-height: 100vh;
    padding: 16px 10px;
}

/* New Message Form */
.new-message-form {
    background: white;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 10px;
}

.form-group:last-of-type {
    margin-bottom: 8px;
}

/* Select with feedback wrapper */
.select-with-feedback {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    color: var(--text-dark);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.author-select:focus {
    outline: none;
    border-color: #c5aef0;
}

/* Auto-select feedback indicator */
.auto-select-feedback {
    color: #4caf50;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

/* Posting as badge */
.posting-as-badge {
    font-size: 0.85rem;
    font-weight: 400;
    color: #b491de;
    opacity: 0.7;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.message-textarea {
    width: 100%;
    min-height: 50px;
    max-height: 300px;
    padding: 10px 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.message-textarea:focus {
    outline: none;
    border-color: #c5aef0;
}

.message-textarea::placeholder {
    color: #aaa;
}

.char-counter {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: right;
    margin-top: 4px;
}

.char-counter.warning {
    color: #eb7093;
    font-weight: 500;
}

.diary-post-btn {
    width: 100%;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 300;
    background: transparent;
    color: var(--lavender-floral);
    border: 1px solid var(--lavender-floral);
    border-radius: 40px;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    letter-spacing: 0.03em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.diary-post-btn:hover {
    background: var(--lavender-floral);
    color: white;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(180, 145, 222, 0.25);
}

.diary-post-btn:active {
    transform: translateY(0) scale(1);
}

.diary-post-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Messages Container */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message Card */
.message-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-author {
    font-size: 0.85rem;
    font-weight: 600;
}

.message-author.sagar {
    color: #4ECDC4;
}

.message-author.lilly {
    color: #eb7093;
}

.message-timestamp {
    font-size: 0.75rem;
    color: var(--text-light);
    cursor: help;
    position: relative;
}

.message-timestamp:hover .timestamp-tooltip {
    display: block;
}

.timestamp-tooltip {
    display: none;
    position: absolute;
    top: -35px;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 10;
}

.timestamp-tooltip::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 10px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid rgba(0, 0, 0, 0.8);
}

.message-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-dark);
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text.editing {
    margin-bottom: 0;
}

.edit-textarea {
    width: 100%;
    min-height: 60px;
    max-height: 300px;
    padding: 10px 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    margin-bottom: 8px;
}

.edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.edit-actions button {
    padding: 5px 14px;
    font-size: 0.8rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.save-edit-btn {
    background: linear-gradient(135deg, #c5aef0 0%, #eb7093 100%);
    color: white;
}

.cancel-edit-btn {
    background: #f5f5f5;
    color: var(--text-dark);
}

.save-edit-btn:hover,
.cancel-edit-btn:hover {
    transform: translateY(-1px);
}

.edited-indicator {
    font-size: 0.7rem;
    color: var(--text-light);
    font-style: italic;
    margin-left: 5px;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.message-action-btn {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: 500;
}

.message-action-btn:hover {
    color: var(--text-dark);
    background: #f5f5f5;
}

.message-action-btn.reply-btn:hover {
    color: #4ECDC4;
}

.message-action-btn.edit-btn:hover {
    color: #c5aef0;
}

.message-action-btn.delete-btn:hover {
    color: #eb7093;
}

.message-action-btn.active {
    color: #4ECDC4;
    background: rgba(78, 205, 196, 0.1);
}

/* Reply Section */
.replies-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f5f5f5;
}

.replies-toggle {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.replies-toggle:hover {
    color: var(--text-dark);
    background: #f5f5f5;
}

.replies-toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.replies-toggle-icon.expanded {
    transform: rotate(90deg);
}

/* Reply Form */
.reply-form {
    margin-top: 10px;
    padding: 10px;
    background: #fcfcfc;
    border-radius: 6px;
    border: 1px solid #f5f5f5;
}

.reply-form .form-group {
    margin-bottom: 8px;
}

.reply-form .author-select {
    font-size: 0.8rem;
    padding: 6px 10px;
}

.reply-textarea {
    width: 100%;
    min-height: 40px;
    max-height: 150px;
    padding: 8px 10px;
    font-size: 0.8rem;
    line-height: 1.5;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
}

.reply-textarea:focus {
    outline: none;
    border-color: #c5aef0;
}

.reply-form .char-counter {
    font-size: 0.7rem;
    margin-top: 3px;
}

.reply-form-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.reply-form-actions button {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.75rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.submit-reply-btn {
    background: #eb7093;
    color: white;
}

.cancel-reply-btn {
    background: #f5f5f5;
    color: var(--text-dark);
}

.submit-reply-btn:hover,
.cancel-reply-btn:hover {
    transform: translateY(-1px);
}

.reply-limit-notice {
    font-size: 0.7rem;
    color: var(--text-light);
    font-style: italic;
    padding: 8px;
    text-align: center;
}

/* Replies List */
.replies-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reply-card {
    background: #fcfcfc;
    border-left: 3px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    margin-left: 8px;
}

/* Threaded reply (reply to a reply) visual indication */
.reply-card.threaded-reply {
    margin-left: 24px;
    border-left-color: #c5aef0;
    background: #fafafa;
}

.thread-indicator {
    color: #c5aef0;
    font-size: 0.9rem;
    margin-right: 6px;
    font-weight: bold;
}

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.reply-author {
    font-size: 0.8rem;
    font-weight: 600;
}

.reply-author.sagar {
    color: #4ECDC4;
}

.reply-author.lilly {
    color: #eb7093;
}

.reply-timestamp {
    font-size: 0.7rem;
    color: var(--text-light);
}

.reply-text {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-dark);
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

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

.reply-action-btn {
    background: none;
    border: none;
    font-size: 0.7rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
    transition: all 0.2s;
    font-weight: 500;
}

.reply-action-btn:hover {
    color: var(--text-dark);
    background: #f0f0f0;
}

.reply-action-btn.edit-btn:hover {
    color: #c5aef0;
}

.reply-action-btn.delete-btn:hover {
    color: #eb7093;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state p {
    font-size: 0.9rem;
    margin: 0;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.loading-spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #c5aef0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Desktop Styles */
@media (min-width: 768px) {
    #diary-page {
        padding: 20px 12px;
    }

    .new-message-form {
        padding: 16px;
        margin-bottom: 24px;
    }

    .message-card {
        padding: 14px;
    }

    .messages-container {
        gap: 12px;
    }
}

/* Larger Desktop */
@media (min-width: 1024px) {
    #diary-page {
        max-width: 800px;
        margin: 0 auto;
        padding: 24px;
    }
}
