/* SliceHub — Customer Inbox (SMS Skrzynka) */

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

:root {
    --bg:       #0f0f13;
    --surface:  #1a1a22;
    --surface2: #22222e;
    --border:   #2e2e3e;
    --accent:   #7c6af5;
    --accent2:  #a89cff;
    --green:    #34d399;
    --red:      #f87171;
    --yellow:   #fbbf24;
    --text:     #e2e2f0;
    --muted:    #7b7b99;
    --radius:   10px;
    --sans: 'Inter', system-ui, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────── */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 12px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.logo-icon { font-size: 24px; }
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: rgba(124,106,245,.15); color: var(--accent2); }
.nav-btn.danger.active { background: rgba(248,113,113,.12); color: var(--red); }
.nav-btn i { width: 16px; text-align: center; }
.nav-btn span:nth-child(2) { flex: 1; }

.badge {
    background: var(--accent);
    color: #fff;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}
.badge-red { background: var(--red); }
.badge:empty, .badge[data-count="0"] { display: none; }

.sidebar-stats {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-item { display: flex; justify-content: space-between; padding: 2px 4px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-val { font-weight: 600; font-size: 13px; }

.sidebar-search { padding: 8px 0 0; }
.sidebar-search input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}
.sidebar-search input:focus { border-color: var(--accent); }

/* ── Main panel ────────────────────────── */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* List */
#list-view { display: flex; flex-direction: column; height: 100%; }

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.list-header h2 { font-size: 18px; font-weight: 700; }
.list-actions { display: flex; gap: 8px; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-list::-webkit-scrollbar { width: 6px; }
.message-list::-webkit-scrollbar-track { background: transparent; }
.message-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    padding: 60px 0;
}
.empty-state i { font-size: 40px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* Message card */
.msg-card {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    position: relative;
}
.msg-card:hover { background: var(--surface2); border-color: var(--border); }
.msg-card.unread { border-left: 3px solid var(--accent); }
.msg-card.unread-cancel { border-left: 3px solid var(--red); }
.msg-card.selected { background: rgba(124,106,245,.1); border-color: var(--accent); }

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.msg-content { flex: 1; min-width: 0; }
.msg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.msg-phone { font-weight: 600; font-size: 14px; }
.msg-name { color: var(--muted); font-size: 12px; margin-left: 6px; }
.msg-time { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.msg-preview { color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 480px; }
.msg-intent { display: inline-block; font-size: 10px; font-weight: 600; border-radius: 4px; padding: 2px 6px; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.intent-eta_query      { background: rgba(52,211,153,.15); color: var(--green); }
.intent-cancel_request { background: rgba(248,113,113,.15); color: var(--red); }
.intent-stop           { background: rgba(251,191,36,.15);  color: var(--yellow); }
.intent-info_query     { background: rgba(124,106,245,.15); color: var(--accent2); }
.intent-reorder        { background: rgba(52,211,153,.15);  color: var(--green); }
.intent-other          { background: rgba(123,123,153,.1);  color: var(--muted); }
.intent-manager_reply  { background: rgba(124,106,245,.15); color: var(--accent2); }

.list-footer { padding: 12px 24px; display: flex; justify-content: center; }
.btn-load-more {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 8px;
    padding: 8px 24px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 13px;
    transition: all 0.15s;
}
.btn-load-more:hover { background: var(--surface2); color: var(--text); }

/* ── Detail view ────────────────────────── */
.detail-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 32px;
}
.detail-view.hidden { display: none; }

.btn-back {
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 4px 0;
    transition: color 0.15s;
}
.btn-back:hover { color: var(--text); }

.detail-header { margin-bottom: 16px; }
.detail-phone { font-size: 22px; font-weight: 700; }
.detail-contact { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-time { color: var(--muted); font-size: 12px; margin-top: 2px; }

.detail-intent-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    padding: 3px 10px;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-auto-reply {
    background: rgba(124,106,245,.07);
    border: 1px solid rgba(124,106,245,.2);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
}
.auto-reply-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.auto-reply-body { font-size: 14px; line-height: 1.55; color: var(--text); white-space: pre-wrap; }

.detail-order {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--muted);
}
.detail-order a { color: var(--accent2); text-decoration: none; }
.detail-order a:hover { text-decoration: underline; }

/* Reply box */
.reply-box {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.reply-box textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
.reply-box textarea:focus { border-color: var(--accent); }
.reply-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}
.reply-char-count { font-size: 12px; color: var(--muted); }
.reply-char-count.over { color: var(--red); }

.btn-primary {
    background: var(--accent);
    border: none;
    color: #fff;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transition: opacity 0.2s;
    max-width: 340px;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red);   }

/* Responsive */
@media (max-width: 700px) {
    .sidebar { width: 56px; min-width: 56px; }
    .logo-text, .nav-btn span:nth-child(2), .sidebar-stats, .sidebar-search { display: none; }
    .sidebar-logo { padding: 8px 4px; }
    .nav-btn { justify-content: center; padding: 10px; }
    .detail-view { padding: 16px; }
}
