/* ========================================================================== */
/*  Super-Messages-AI  –  Responsive layout (mobile & desktop)                */
/* ========================================================================== */

:root {
    --smai-green-me: #e3f9e5;
    --smai-grey-other: #ffffff;
    --smai-grey-border: #e7e7e7;
    --smai-grey-bg: #f7f9fb;
    --smai-accent: #ff4a4a;
    --smai-text: #222;
    --smai-text-muted: #777;
    --smai-text-unread: #000;
    --smai-radius: 18px;
    --smai-top-offset: 140px;
}

/* Reset / Common */
#smai-threads, #smai-threads ul, #smai-threads li {
    list-style: none; margin: 0; padding: 0;
}
.smai-msg.sent { 
    background: linear-gradient(135deg, #e3f9e5, #d0f0c0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.smai-msg.received { 
    background: linear-gradient(135deg, #ffffff, #f0f0f0);
    border: 1px solid var(--smai-grey-border);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.smai-msg.unread .smai-msg-content { font-weight: 600; color: var(--smai-text-unread); }
.smai-msgtime {
    display: block; margin-top: 4px; font-size: 12px; color: var(--smai-text-muted);
}
.smai-typing {
    font-size: 12px;
    color: #777;
    margin: 5px 0;
}

/* Search and Message Input */
.smai-search-container { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
#smai-search { flex: 1; padding: 8px 12px; border: 1px solid var(--smai-grey-border); border-radius: 20px; font-size: 14px; outline: none; transition: border-color 0.2s ease; }
#smai-search:focus { border-color: #4094ff; box-shadow: 0 0 0 2px rgba(64, 148, 255, 0.2); }
.smai-search-button { padding: 8px 12px; border: none; background: #4094ff; color: #fff; border-radius: 20px; cursor: pointer; font-size: 14px; transition: background 0.2s ease, transform 0.1s ease; }
.smai-search-button:hover { background: #357abd; transform: translateY(-1px); }
.smai-search-button .fas { margin-right: 4px; }

#smai-text, #smai-reply-text { width: 100%; padding: 8px 12px; border: 1px solid var(--smai-grey-border); border-radius: 25px; font-size: 14px; resize: none; min-height: 40px; max-height: 100px; box-shadow: inset 0 1px 2px rgba(0,0,0,.05); transition: box-shadow 0.2s ease; }
#smai-text:focus, #smai-reply-text:focus { outline: none; border-color: #4094ff; box-shadow: inset 0 1px 2px rgba(0,0,0,.1), 0 0 0 2px rgba(64, 148, 255, 0.2); }

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    .smai-wrap { display: flex; flex-direction: column; height: 100vh; max-width: 100%; margin: 0; }
    .smai-side { position: fixed; inset: 0; z-index: 2000; width: 100%; background: #fff; overflow-y: auto; transform: translateX(-100%); transition: transform .3s ease; }
    .smai-side.open { transform: translateX(0); }
    .smai-side header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--smai-grey-border); }
    #smai-threads .smai-thread { display: flex; gap: 10px; padding: 12px 18px; cursor: pointer; animation: fadeIn 0.3s ease; }
    #smai-threads .smai-thread:hover { background: var(--smai-grey-bg); }
    #smai-threads .avatar { flex: 0 0 40px; height: 40px; border-radius: 50%; }
    #smai-threads .meta { flex: 1; }
    #smai-threads .meta .name { font-weight: 600; }
    #smai-threads .meta .ad-title { font-size: 12px; color: var(--smai-text-muted); }
    #smai-threads .smai-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 5px; }
    #smai-threads .smai-status[data-status="online"] { background: #00cc00; }
    #smai-threads .smai-status[data-status="offline"] { background: #ccc; }
    #smai-threads .smai-unread { margin-left: 5px; }

    .smai-main { flex: 1 1 auto; display: flex; flex-direction: column; height: 100%; }
    .smai-mobile-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: #fff; border-bottom: 1px solid var(--smai-grey-border); }
    .smai-mobile-header button { background: none; border: 0; font-size: 22px; line-height: 1; }
    .smai-msgs { flex: 1 1 auto; overflow-y: auto; background: var(--smai-grey-bg); padding: 12px 14px 74px; scroll-behavior: smooth; }
    .smai-msgs .smai-msg { animation: fadeIn 0.3s ease; }

    .smai-msg { display: inline-block; max-width: 75%; margin: 4px 0; padding: 10px 14px; border-radius: var(--smai-radius); font-size: 14px; line-height: 1.35; }
    .smai-msg.sent { margin-left: auto; }
    .smai-msg.received { margin-right: auto; }

    .smai-reply { position: fixed; left: 0; bottom: 0; width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; box-shadow: 0 -1px 4px rgba(0,0,0,.08); z-index: 10; }
    .smai-reply-actions { display: flex; align-items: center; gap: 10px; }
    .smai-reply button, .smai-reply label { flex: none; padding: 12px; border: none; border-radius: 50%; cursor: pointer; transition: background 0.2s ease, transform 0.1s ease; font-size: 14px; }
    .smai-reply #smai-reply-send { background: #1fd6cd; color: #fff; }
    .smai-reply #smai-reply-send:hover { background: #1ab7af; transform: scale(1.1); }
    .smai-reply #smai-block-conv { background: #ff4444; color: #fff; }
    .smai-reply #smai-block-conv:hover { background: #e03e3e; transform: scale(1.1); }
    .smai-reply #smai-unblock-conv { background: #44ff44; color: #fff; display: none; }
    .smai-reply #smai-unblock-conv:hover { background: #3de03d; transform: scale(1.1); }
    .smai-reply #smai-show-blocked { background: #6c757d; color: #fff; }
    .smai-reply #smai-show-blocked:hover { background: #5a6268; transform: scale(1.1); }
    .smai-reply #smai-voice { background: #6c757d; color: #fff; }
    .smai-reply #smai-voice.recording { background: #ff4444; animation: pulse 1s infinite; }
    .smai-reply #smai-voice:hover { background: #5a6268; transform: scale(1.1); }
    .smai-reply label[for="smai-reply-attachment"] { background: #6c757d; color: #fff; }
    .smai-reply label[for="smai-reply-attachment"]:hover { background: #5a6268; transform: scale(1.1); }
    .smai-reply-attachment-preview { margin-top: 5px; display: none; }
    .smai-reply-attachment-preview img { vertical-align: middle; max-width: 100px; max-height: 100px; }
}

/* Desktop (min-width: 769px) */
@media (min-width: 769px) {
    .smai-wrap { display: flex; max-width: 1260px; height: calc(100vh - var(--smai-top-offset)); margin: 0 auto; }
    .smai-side { position: static; width: 340px; overflow-y: auto; background: #fff; border-right: 1px solid var(--smai-grey-border); }
    #smai-threads .smai-thread { display: flex; gap: 14px; align-items: center; padding: 14px 22px; font-size: 15px; cursor: pointer; border-bottom: 1px solid var(--smai-grey-border); transition: background .15s; animation: fadeIn 0.3s ease; }
    #smai-threads .smai-thread:hover { background: var(--smai-grey-bg); }
    #smai-threads .smai-thread.active { background: #e8f3ff; border-left: 4px solid #4094ff; }
    #smai-threads .avatar { flex: 0 0 42px; height: 42px; border-radius: 50%; background: #d8d8d8; }
    #smai-threads .meta { flex: 1 1 auto; min-width: 0; }
    #smai-threads .meta .name { font-weight: 600; line-height: 1.2; }
    #smai-threads .meta .ad-title { font-size: 13px; color: var(--smai-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #smai-threads .smai-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 5px; }
    #smai-threads .smai-status[data-status="online"] { background: #00cc00; }
    #smai-threads .smai-status[data-status="offline"] { background: #ccc; }
    #smai-threads .smai-unread { margin-left: 5px; }

    .smai-main { flex: 1 1 auto; display: flex; flex-direction: column; background: var(--smai-grey-bg); height: 100%; position: relative; }
    .smai-msgs { flex: 1 1 auto; overflow-y: auto; padding: 32px 28px 200px; display: flex; flex-direction: column; gap: 12px; } /* Zwiększony padding-bottom do 200px */
    .smai-msgs::-webkit-scrollbar { width: 8px; }
    .smai-msgs::-webkit-scrollbar-thumb { background: #c6d1e1; border-radius: 4px; }
    .smai-msgs .smai-msg { animation: fadeIn 0.3s ease; }

    .smai-msg { display: block; clear: both; max-width: 60%; margin: 5px 0; padding: 10px 14px; border-radius: var(--smai-radius); font-size: 15px; line-height: 1.45; }
    .smai-msg.sent { margin-left: auto; }
    .smai-msg.received { margin-right: auto; }
    .smai-msgtime { font-size: 11px; color: var(--smai-text-muted); margin-top: 6px; text-align: right; }

    .smai-reply { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 16px 28px; background: #fff; border-top: 1px solid var(--smai-grey-border); box-shadow: 0 -1px 3px rgba(0,0,0,.05); z-index: 10; min-height: 80px; } /* Dodano min-height */
    .smai-reply-actions { display: flex; align-items: center; gap: 10px; }
    .smai-reply button, .smai-reply label { flex: none; padding: 12px; border: none; border-radius: 50%; cursor: pointer; transition: background 0.2s ease, transform 0.1s ease; font-size: 14px; }
    .smai-reply #smai-reply-send { background: #1fd6cd; color: #fff; }
    .smai-reply #smai-reply-send:hover { background: #1ab7af; transform: scale(1.1); }
    .smai-reply #smai-block-conv { background: #ff4444; color: #fff; }
    .smai-reply #smai-block-conv:hover { background: #e03e3e; transform: scale(1.1); }
    .smai-reply #smai-unblock-conv { background: #44ff44; color: #fff; display: none; }
    .smai-reply #smai-unblock-conv:hover { background: #3de03d; transform: scale(1.1); }
    .smai-reply #smai-show-blocked { background: #6c757d; color: #fff; }
    .smai-reply #smai-show-blocked:hover { background: #5a6268; transform: scale(1.1); }
    .smai-reply #smai-voice { background: #6c757d; color: #fff; }
    .smai-reply #smai-voice.recording { background: #ff4444; animation: pulse 1s infinite; }
    .smai-reply #smai-voice:hover { background: #5a6268; transform: scale(1.1); }
    .smai-reply label[for="smai-reply-attachment"] { background: #6c757d; color: #fff; }
    .smai-reply label[for="smai-reply-attachment"]:hover { background: #5a6268; transform: scale(1.1); }

    .smai-mobile-header, .smai-side.open, .fixed-mobile { display: none !important; }
}

.smai-top-bar-notification {
    position: fixed; top: 0; left: 0; right: 0; background: #ff4444; color: #fff; padding: 10px 20px; text-align: center; font-size: 14px; z-index: 10000; box-shadow: 0 2px 4px rgba(0,0,0,0.1); display: flex; justify-content: center; align-items: center; gap: 10px;
}
.smai-top-bar-notification .smai-close-notification { cursor: pointer; font-size: 16px; color: #fff; transition: color 0.2s ease; }
.smai-top-bar-notification .smai-close-notification:hover { color: #ddd; }

@media (min-width: 769px) {
    #smai-reply.smai-reply { bottom: 0; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.smai-blocked-user { margin: 5px 0; }
.smai-blocked-user button { margin-left: 10px; padding: 2px 5px; }
.smai-msg a { color: #0073aa; text-decoration: none; margin-top: 5px; display: inline-block; }
.smai-msg a:hover { text-decoration: underline; }
.smai-mark-read { margin-left: 10px; padding: 2px 5px; background: #ddd; border: none; border-radius: 50%; cursor: pointer; }
.smai-mark-read:hover { background: #ccc; }

/* Tooltip styles */
button[title], label[title] {
    position: relative;
}

button[title]:hover:after, label[title]:hover:after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1;
}
/* AI suggestions */
.smai-ai-suggestions{margin-top:6px;padding:6px;border:1px dashed #ccd;border-radius:6px;list-style:none}
.smai-ai-item{padding:.35rem .45rem;margin:.2rem 0;background:#f7f9ff;border-radius:6px;cursor:pointer}
.smai-ai-item:hover{background:#eef}
