@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
    /* Core - Eco-Brutalism Structure */
    --border-width: 2px;
    --border-color: #1F2937; /* Blackish */
    --border-radius-card: 24px;
    --border-radius-pill: 999px;
    --shadow-offset: 4px;
    --shadow-color: #1F2937;
    
    /* Greenery Theme (Default) */
    --bg-color: #FFFDF7; /* Creamy Off-White */
    --primary-color: #7FB069; /* Sage Green */
    --highlight-color: #C5E063; /* Zesty Lime */
    --secondary-color: #E6E1D3; /* Muted Earthy Beige */
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    
    /* Love Theme Colors */
    --love-bg: #FFF0F3; /* Pale Blush Pink */
    --love-primary: #FF8FAB; /* Warm Pink */
    --love-secondary: #FF5A5F; /* Soft Red */
    --love-highlight: #FFC0CB;
}

/* Greenery Theme (Formerly Dark Theme) - Soothing Pastels */
body.dark-theme {
    --bg-color: #EBF5DF; /* Pastel Green */
    --primary-color: #5B8C5A; /* Natural Green */
    --highlight-color: #AED581; /* Fresh Green */
    --secondary-color: #DCECC9; /* Sage-ish */
    --text-primary: #2C3E2D; /* Dark Green-Grey */
    --text-secondary: #556B58; /* Medium Green-Grey */
    --border-color: #1A332A; /* Deep Forest */
    --shadow-color: #1A332A; /* Deep Forest */
    
    /* Love Theme - Keep it pink/cute but compatible */
    --love-bg: #FFF0F5;
    --love-primary: #FF8FAB;
    --love-secondary: #FF5A5F;
    --love-highlight: #FFC0CB;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    /* Cute background pattern using radial gradients to mimic dots/leaves */
    background-image: radial-gradient(var(--primary-color) 2px, transparent 2px), radial-gradient(var(--primary-color) 2px, transparent 2px);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
}

/* Base UI Elements - Brutalist Style */
.btn-icon, .btn-send, .btn-attachment, .btn-ai, .btn-save-api, .modal-close, .theme-toggle, .btn-ai-settings-header, .btn-presence-toggle {
    border: var(--border-width) solid var(--border-color);
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--shadow-color);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-icon:active, .btn-send:active, .btn-attachment:active, .btn-ai:active, .btn-save-api:active, .modal-close:active, .theme-toggle:active, .btn-ai-settings-header:active, .btn-presence-toggle:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow-color);
}

/* Main Container */
.container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    height: 100%;
    background: var(--bg-color);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-card);
    box-shadow: 8px 8px 0 var(--shadow-color);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Sidebar */
.sidebar {
    width: 400px;
    background: var(--secondary-color);
    border-right: var(--border-width) solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

/* Sidebar Header */
.sidebar-header {
    padding: 24px;
    background: var(--bg-color);
    border-bottom: var(--border-width) solid var(--border-color);
}

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

.sidebar-header h2 {
    font-weight: 900;
    font-size: 28px;
    letter-spacing: -0.5px;
    /* Text stroke effect for "sticker" look */
    -webkit-text-stroke: 1px var(--border-color);
    color: var(--primary-color);
    text-shadow: 2px 2px 0 var(--border-color);
}

.header-buttons {
    display: flex;
    gap: 12px;
}

.theme-toggle, .btn-ai-settings-header, .btn-presence-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-primary);
}

.theme-toggle:hover, .btn-ai-settings-header:hover, .btn-presence-toggle:hover {
    background: var(--highlight-color);
}

.btn-presence-toggle.online {
    background: #ecfdf5; /* Very light green */
    border-color: #00a884;
    color: #00a884;
}

/* Status Indicator */
.status-indicator {
    background: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-pill);
    padding: 6px 6px 6px 16px; /* Reduced right padding for button */
    display: flex;
    align-items: center;
    justify-content: space-between; /* Push button to right */
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 2px 2px 0 var(--shadow-color);
    color: var(--text-primary);
}

.status-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 16px;
}

.status-toggle-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
}

.status-toggle-btn.online {
    color: #00a884;
    background: #e6fffa;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #fbbf24;
    border: 2px solid var(--border-color);
}

.status-indicator.connected .status-dot {
    background-color: var(--highlight-color);
}

.status-indicator.disconnected .status-dot {
    background-color: #ef4444;
}

/* QR Section */
.qr-section {
    padding: 24px;
    background: var(--highlight-color);
    border-bottom: var(--border-width) solid var(--border-color);
    text-align: center;
    display: none;
}

.qr-section.active {
    display: block;
}

.qr-code-wrapper {
    background: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-card);
    padding: 16px;
    margin: 16px auto;
    width: 260px;
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 4px 0 var(--shadow-color);
}

.qr-code-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Search Bar */
.search-bar {
    padding: 16px 24px;
    background: var(--bg-color);
    border-bottom: var(--border-width) solid var(--border-color);
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 44px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 18px;
    pointer-events: none;
    z-index: 5;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 52px;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-pill);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 16px;
    outline: none;
    box-shadow: 2px 2px 0 var(--shadow-color);
    transition: all 0.2s;
    background: white;
    color: var(--text-primary);
}



.search-bar input:focus {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--shadow-color);
}

/* Contacts List */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: var(--secondary-color);
    /* Dotted background pattern */
    background-image: radial-gradient(#d1ccbf 2px, transparent 2px);
    background-size: 20px 20px;
    scrollbar-width: none; /* Firefox */
}

.contacts-list::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}



.contact-item {
    background: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-card);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--shadow-color);
    transition: all 0.2s;
}



.contact-item:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--shadow-color);
}

.contact-item.active {
    background: var(--highlight-color);
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow-color);
}

.contact-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: var(--border-width) solid var(--border-color);
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.contact-last-message {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.contact-badge {
    background: var(--primary-color);
    color: white;
    border: 2px solid var(--border-color);
    border-radius: 99px;
    padding: 4px 10px;
    font-weight: 800;
    font-size: 12px;
    box-shadow: 2px 2px 0 var(--shadow-color);
}

/* Special Chat Indicator in List */
.contact-item.love-theme .contact-name::after {
    content: ' 💖';
}
.contact-item.love-theme {
    border-color: var(--border-color);
}
.contact-item.love-theme.active {
    background: var(--love-highlight);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    position: relative;
    /* Vine pattern background (CSS radial) */
    background-image: 
        radial-gradient(circle at 100% 150%, var(--bg-color) 24%, transparent 25%),
        radial-gradient(circle at 0% 150%, var(--bg-color) 24%, transparent 25%),
        radial-gradient(circle at 50% 100%, #f0f7e6 10%, transparent 11%),
        radial-gradient(circle at 100% 50%, #f0f7e6 5%, transparent 6%),
        radial-gradient(circle at 0% 50%, #f0f7e6 5%, transparent 6%);
    background-size: 60px 60px;
}



/* Chat Header */
.chat-header {
    padding: 16px 32px;
    background: white;
    border-bottom: var(--border-width) solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}



.btn-back-mobile {
    display: none; /* Hidden on desktop */
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: var(--border-width) solid var(--border-color);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--shadow-color);
    color: var(--text-primary);
    font-size: 18px;
    flex-shrink: 0;
    z-index: 10;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-back-mobile:active {
    transform: translateY(-50%) translate(2px, 2px);
    box-shadow: 0 0 0 var(--shadow-color);
}



.chat-info {
    background: var(--primary-color);
    padding: 8px 32px;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-pill);
    box-shadow: 4px 4px 0 var(--shadow-color);
    text-align: center;
    min-width: 200px;
}

.chat-info h3 {
    color: white;
    font-weight: 900;
    font-size: 20px;
    text-shadow: 1px 1px 0 var(--border-color);
}

.chat-info span {
    color: #f0fdf4;
    font-weight: 700;
    font-size: 12px;
}

/* Messages */
.messages-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages-container:not(.has-messages) {
    justify-content: center;
    align-items: center;
}

.message {
    display: flex;
    margin-bottom: 8px;
}

.message.incoming {
    justify-content: flex-start;
}

.message.outgoing {
    justify-content: flex-end;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    min-width: 0; /* Prevent flex overflow */
}

.message.incoming .message-wrapper {
    align-items: flex-start;
}

.message.outgoing .message-wrapper {
    align-items: flex-end;
}

.message-bubble {
    /* width: 100%; Removed to allow bubble to size to content */
    padding: 16px 24px;
    border: var(--border-width) solid var(--border-color);
    box-shadow: 4px 4px 0 var(--shadow-color);
    font-weight: 600;
    position: relative;
    word-wrap: break-word; /* Legacy support */
    overflow-wrap: break-word; /* Modern standard */
    word-break: break-word; /* Ensure wrapping */
    cursor: pointer; /* Indicate clickable */
    transition: transform 0.1s;
    max-width: 100%; /* Ensure it doesn't overflow wrapper */
}

.message-bubble:active {
    transform: scale(0.98);
}

/* Reaction Button */
.reaction-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
}

.message.incoming .reaction-btn {
    right: -40px;
}

.message.outgoing .reaction-btn {
    left: -40px;
}

.message-bubble:hover .reaction-btn,
.reaction-btn:hover {
    opacity: 1;
}

.reaction-btn:hover {
    transform: translateY(-50%) scale(1.1);
}

/* Reaction Picker */
.reaction-picker {
    position: absolute;
    bottom: 100%;
    background: white;
    border-radius: 24px;
    padding: 8px;
    display: none; /* Hidden by default */
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 20;
    margin-bottom: 8px;
    white-space: nowrap;
}

.message.incoming .reaction-picker {
    left: 0;
}

.message.outgoing .reaction-picker {
    right: 0;
}

.reaction-picker.show {
    display: flex;
    animation: popIn 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.reaction-option {
    cursor: pointer;
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: transform 0.2s;
}

.reaction-option:hover {
    transform: scale(1.2);
    background: #f3f4f6;
}

/* Reaction Display */
.reaction-display {
    position: absolute;
    bottom: -10px;
    right: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 14px;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.message.outgoing .reaction-display {
    right: auto;
    left: 10px;
}

.reaction-display.has-reaction {
    display: flex;
    animation: popIn 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.message.incoming .message-bubble {
    background: white;
    border-radius: 24px 24px 24px 0;
    color: var(--text-primary);
}



.message.outgoing .message-bubble {
    background: var(--primary-color);
    border-radius: 24px 24px 0 24px;
    color: white;
}

.message-meta {
    font-size: 11px;
    margin-top: 6px;
    font-weight: 800;
    opacity: 0.8;
    text-align: right; /* Default right alignment */
    display: none; /* Hidden by default */
    color: var(--text-secondary);
    padding: 0 4px;
}

.message.outgoing .message-meta {
    text-align: right;
    color: var(--text-secondary); /* Or keep it subtle */
}

.message.incoming .message-meta {
    text-align: left;
}

.message-meta.show {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 0.8; transform: translateY(0); }
}

/* Message Input Area */
.message-input-container {
    padding: 24px;
    background: white;
    border-top: var(--border-width) solid var(--border-color);
    display: none;
    position: relative; /* Anchor for absolute elements like reply preview */
    z-index: 20;
}

.chat-area.chat-active .message-input-container {
    display: block;
}



#messageForm {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.btn-attachment, .btn-ai {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}



.btn-ai {
    background: #e0e7ff; /* Light indigo for AI magic */
}



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

#messageInput {
    flex: 1;
    border: var(--border-width) solid var(--border-color);
    border-radius: 30px; /* Pill-like */
    padding: 14px 24px;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 600;
    outline: none;
    resize: none;
    min-height: 54px;
    box-shadow: inset 4px 4px 0 rgba(0,0,0,0.05);
    background: white;
    color: var(--text-primary);
}



#messageInput:focus {
    background: #f9fafb;
    border-color: var(--border-color);
}

.btn-send {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-send:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 
========================================
   SPECIAL CHAT OVERRIDE (LOVE THEME) 
========================================
*/

/* Active Chat Screen - Love Theme Override */
.chat-area.love-theme {
    background-color: var(--love-bg);
    /* Hearts background pattern */
    background-image: radial-gradient(var(--love-primary) 15%, transparent 16%), radial-gradient(var(--love-primary) 15%, transparent 16%);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    opacity: 1;
}

/* Override Header */
.chat-area.love-theme .chat-info {
    background: var(--love-primary);
}

/* Override Outgoing Bubbles */
.chat-area.love-theme .message.outgoing .message-bubble {
    background: var(--love-primary);
    color: white;
}

/* Override Send Button */
.chat-area.love-theme .btn-send {
    background: var(--love-secondary);
}

.chat-area.love-theme .btn-send:hover {
    background: #ff4046;
}

/* Icon Override for Love Theme */
.chat-area.love-theme .btn-send i::before {
    content: "\f004"; /* fa-heart */
}

.chat-area.love-theme .message.incoming .message-bubble {
    border-color: var(--border-color);
    background: #fff;
    color: #1F2937;
}



/* Link Colors */
.message-link {
    color: inherit;
    text-decoration: underline;
    font-weight: 800;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 41, 55, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-card);
    width: 90%;
    max-width: 500px;
    box-shadow: 12px 12px 0 var(--shadow-color);
    overflow: hidden;
}

.modal-header {
    background: var(--primary-color);
    padding: 20px 24px;
    border-bottom: var(--border-width) solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: white;
    font-weight: 900;
    text-shadow: 2px 2px 0 var(--border-color);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.api-key-input, .provider-select, .model-select {
    width: 100%;
    padding: 12px 16px;
    border: var(--border-width) solid var(--border-color);
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    outline: none;
    background: white;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
    color: var(--text-primary);
}

/* Fix for form inputs to make room for absolute buttons */
.api-key-input {
    padding-right: 50px;
}

.model-select {
    padding-right: 50px;
}



.btn-save-api {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    color: white;
    font-weight: 800;
    font-size: 18px;
    border-radius: var(--border-radius-pill);
    cursor: pointer;
}

/* Modal Close Button Fix */
.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.modal-close:hover {
    background: var(--secondary-color);
}

/* Form Group Buttons (Eye & Refresh) */
.btn-toggle-visibility, .btn-refresh-models {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 38px;
    height: 38px;
    background: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: 8px; /* Slightly squarer than pill */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: 2px 2px 0 var(--shadow-color);
    transition: all 0.1s;
}

.btn-toggle-visibility:hover, .btn-refresh-models:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--shadow-color);
    background: #f9fafb;
}

.btn-toggle-visibility:active, .btn-refresh-models:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--shadow-color);
}

/* File Preview */
.file-preview {
    padding: 12px 24px;
    background: var(--secondary-color);
    border-top: var(--border-width) solid var(--border-color);
    display: none; /* Hidden by default */
}

.file-preview-content {
    background: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    display: inline-block;
    position: relative;
    box-shadow: 4px 4px 0 var(--shadow-color);
}

.file-preview-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Media styling in messages */
.media-image, .media-video {
    border-radius: 12px;
    border: 2px solid var(--border-color);
    max-width: 100%;
    max-height: 300px; /* Limit height to prevent taking up too much space */
    object-fit: contain; /* Maintain aspect ratio */
    margin-bottom: 8px;
    display: block;
    background: #000; /* Dark background for videos/letterboxing */
}

.media-sticker {
    max-width: 128px;
    max-height: 128px;
    margin-bottom: 8px;
    display: block;
    border: none;
    border-radius: 0;
    background: transparent;
}

/* Shredder Modal Styles */
.shredder-modal {
    max-width: 400px;
    background: #f3f4f6; /* Light grey for machine look */
}

.shredder-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    position: relative;
    height: 150px;
}

.paper-message {
    background: white;
    padding: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 200px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    z-index: 1;
    transition: transform 0.8s ease-in, opacity 0.8s ease-in;
}

.shredder-machine {
    width: 240px;
    height: 60px;
    background: #374151; /* Dark grey machine */
    border-radius: 8px;
    position: absolute;
    bottom: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.shredder-slot {
    width: 210px;
    height: 4px;
    background: #111827;
    margin-top: 10px;
    border-radius: 2px;
}

.shredder-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.btn-shred-confirm {
    width: 100%;
    padding: 16px;
    background: #ef4444; /* Red for destructive action */
    color: white;
    font-weight: 800;
    font-size: 18px;
    border-radius: var(--border-radius-pill);
    border: var(--border-width) solid var(--border-color);
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--shadow-color);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-shred-confirm:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow-color);
}

/* Shredding Animation */
.shredding .paper-message {
    transform: translateY(100px);
    opacity: 0;
    /* Create strips effect with clip-path (simulated) */
    clip-path: polygon(
        0% 0%, 10% 0%, 10% 100%, 0% 100%,
        20% 0%, 30% 0%, 30% 100%, 20% 100%,
        40% 0%, 50% 0%, 50% 100%, 40% 100%,
        60% 0%, 70% 0%, 70% 100%, 60% 100%,
        80% 0%, 90% 0%, 90% 100%, 80% 100%
    );
}

/* Message Actions (Shredder Button on Message) */
.message-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
}

.message.outgoing .message-actions {
    left: -40px; 
}

.btn-shred {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.message-bubble:hover + .message-actions,
.message-actions:hover {
    opacity: 1;
}

/* Revoked Message Style */
.message-bubble.revoked {
    background: #f3f4f6; /* Greyed out */
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    box-shadow: none;
}

.message.outgoing .message-bubble.revoked {
    background: rgba(255,255,255,0.8); /* Keeping outgoing revoked light */
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: #ef4444;
    color: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: 12px;
    padding: 16px 24px;
    box-shadow: 8px 8px 0 var(--shadow-color);
    z-index: 2000;
    font-weight: 800;
    transform: translateX(200%);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.toast.show {
    transform: translateX(0);
}

/* Link Preview Panel */
.link-preview-panel {
    width: 0; /* Hidden by default */
    background: var(--bg-color);
    border-left: var(--border-width) solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease-in-out;
    overflow: hidden;
    position: relative;
}

.link-preview-panel.open {
    width: 400px; /* Panel width when open */
}

.preview-header {
    padding: 16px 24px;
    background: var(--secondary-color);
    border-bottom: var(--border-width) solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.preview-controls {
    display: flex;
    gap: 8px;
}

.btn-icon-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: var(--border-width) solid var(--border-color);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    box-shadow: 2px 2px 0 var(--shadow-color);
}

.btn-icon-small:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--shadow-color);
}

.btn-icon-small:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--shadow-color);
}

.preview-content {
    flex: 1;
    position: relative;
    background: white;
}

.iframe-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary-color);
    font-size: 32px;
    z-index: 1;
}

#previewIframe {
    width: 100%;
    height: 100%;
    border: none;
    position: relative;
    z-index: 2;
    background: white;
}

/* Suggestion Chips */
.suggestion-chips {
    position: absolute;
    bottom: 100%;
    right: 0;
    left: 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 24px 12px 24px; /* Match container padding */
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    z-index: 5;
    pointer-events: none; /* Allow clicking through empty space */
}

.suggestion-chips::-webkit-scrollbar {
    display: none;
}

.suggestion-chip {
    background: white;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-pill);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--shadow-color);
    transition: all 0.1s;
    color: var(--text-primary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    pointer-events: auto; /* Re-enable clicks on chips */
}

.suggestion-chip i {
    font-size: 10px;
    color: var(--primary-color);
}

.suggestion-chip:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--shadow-color);
    background: #f9fafb;
}

.suggestion-chip:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--shadow-color);
}

/* Love Theme Override for Chips */
.chat-area.love-theme .suggestion-chip {
    border-color: var(--love-secondary);
    color: var(--love-secondary);
}

.chat-area.love-theme .suggestion-chip:hover {
    background: #fff0f5;
}

/* Responsive */
@media (max-width: 1024px) {
    .link-preview-panel.open {
        width: 350px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    .container {
        border: none;
        border-radius: 0;
    }
    .sidebar {
        width: 100%;
        position: absolute;
        height: 100%;
        transform: translateX(0);
        transition: transform 0.3s;
    }
    .sidebar.hidden-mobile {
        transform: translateX(-100%);
    }
    .header-top h2 {
        font-size: 24px;
    }
    .btn-back-mobile {
        display: flex;
    }
    
    /* On mobile, panel takes full width */
    .link-preview-panel {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        width: 0;
        z-index: 50;
    }
    
    .link-preview-panel.open {
        width: 100%;
    }
}

/* Animations */
@keyframes floatingHearts {
    0% {
        opacity: 0;
        transform: translateY(0) rotate(0deg);
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) rotate(20deg);
    }
}

/* Loading Spinner */
.loading-container {
    padding: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-spinner, .media-spinner i {
    width: 40px;
    height: 40px;
    border: 4px solid var(--secondary-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.media-spinner {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 20px;
}

.media-spinner i {
    width: 20px;
    height: 20px;
    border-width: 3px;
    margin-bottom: 0;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 0;
}
.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    color: var(--primary-color);
    -webkit-text-stroke: 2px var(--border-color);
}
.empty-state h2 {
    font-weight: 900;
}

/* Quoted Message in Bubble */
.quoted-message {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    border-left: 4px solid var(--primary-color);
}

.message.outgoing .quoted-message {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: white;
}

.quoted-content {
    flex: 1;
    min-width: 0;
}

.quoted-author {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 2px;
    color: var(--primary-color);
}

.message.outgoing .quoted-author {
    color: white;
}

.quoted-text {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

/* Reply Preview in Footer - Pinned Polaroid Style */
.reply-preview {
    position: absolute;
    bottom: 100%;
    left: 16px;
    width: calc(100% - 32px);
    max-width: 400px;
    background: white;
    border: var(--border-width) solid var(--border-color);
    padding: 12px;
    /* Rotation for the "tossed on desk" look */
    transform: rotate(-2deg) translateY(10px); 
    box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
    z-index: 5; /* Sit behind the input form z-index if needed, or on top */
    display: none; /* Flex when active */
    align-items: center;
    justify-content: space-between;
    
    /* Animation */
    transform-origin: top left;
    animation: swingIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Tape Effect */
.reply-preview::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%) rotate(2deg);
    width: 60px;
    height: 24px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    backdrop-filter: blur(2px);
}

.reply-content {
    display: flex;
    align-items: stretch;
    gap: 12px;
    flex: 1;
    min-width: 0;
    /* Inner "photo" frame look */
    background: #f8fafc;
    padding: 8px;
    border: 1px solid #e2e8f0;
}

.reply-bar {
    width: 4px;
    background: var(--primary-color);
    border-radius: 4px;
}

.reply-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.reply-author {
    font-weight: 800;
    font-size: 13px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace; /* Typewriter vibe */
}

.reply-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Courier New', monospace;
}

.reply-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: var(--border-width) solid var(--border-color);
    background: #ef4444;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 2px 2px 0 var(--shadow-color);
    transition: all 0.1s;
    z-index: 10;
}

.reply-close:hover {
    transform: scale(1.1);
}

@keyframes swingIn {
    from { 
        transform: rotate(-10deg) translateY(-20px); 
        opacity: 0;
    }
    to { 
        transform: rotate(-2deg) translateY(10px); 
        opacity: 1;
    }
}