/**
 * Winklyy Dashboard Styles
 * Extracted from views/dashboard.js for better maintainability
 */

/* ===== REDESIGNED DASHBOARD STYLES ===== */

/* Connectivity */
.connectivity-bar {
    position: fixed;
    top: 0;
    top: env(safe-area-inset-top, 0);
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 0.5rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0));
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.connectivity-bar.offline {
    background: var(--danger);
    color: white;
    transform: translateY(0);
}

/* AI Paused Banner */
.ai-paused-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--danger);
    color: white;
    padding: 0.75rem;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0));
    text-align: center;
    z-index: 300;
    display: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.ai-paused-banner.active {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.ai-paused-banner button {
    background: white;
    color: var(--danger);
    border: none;
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 36px;
}

.billing-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(243, 181, 98, 0.18);
    border-bottom: 1px solid rgba(243, 181, 98, 0.28);
    color: var(--text);
    padding: 0.65rem 0.9rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0));
    z-index: 299;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.billing-banner-text {
    color: var(--text2);
    font-size: 0.85rem;
    font-weight: 700;
}

.billing-banner button {
    background: var(--bg2);
    border: 1px solid rgba(243, 181, 98, 0.35);
    color: var(--text);
    padding: 0.35rem 0.85rem;
    border-radius: 10px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 36px;
}

/* Dashboard App */
.dashboard-app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.dashboard-app.has-banner {
    padding-top: calc(48px + env(safe-area-inset-top, 0));
}

.dashboard-app.has-billing {
    padding-top: calc(48px + env(safe-area-inset-top, 0));
}

.dashboard-app.has-banner.has-billing {
    padding-top: calc(96px + env(safe-area-inset-top, 0));
}

/* Scrollable Container */
.dashboard-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0));
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0));
    -webkit-overflow-scrolling: touch;
}

/* Header */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--success);
}

.ai-status.paused {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.25);
    color: var(--danger);
}

.ai-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.ai-status.paused .ai-dot {
    animation: none;
}

.ai-status-sep {
    opacity: 0.5;
}

#ai-status-convos {
    opacity: 0.8;
}

.location-indicator {
    opacity: 0.3;
    margin-left: 0.2rem;
}

.location-indicator svg {
    width: 14px;
    height: 14px;
}

.location-indicator.active {
    opacity: 1;
    color: var(--accent);
}

.location-indicator.active svg {
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.settings-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.settings-btn svg {
    width: 18px;
    height: 18px;
    stroke: var(--text2);
    stroke-width: 1.75;
    fill: none;
}

/* Quick Stats */
.quick-stats {
    display: flex;
    justify-content: space-around;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.85rem 0.5rem;
    margin-bottom: 1.25rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Pipeline */
.lead-funnel {
    margin-bottom: 1.05rem;
    background: rgba(26, 18, 34, 0.55);
    border: 1px solid rgba(56, 40, 71, 0.75);
    border-radius: 14px;
    padding: 0.85rem;
}

.mini-link {
    background: transparent;
    border: 1px solid rgba(56, 40, 71, 0.8);
    color: var(--text2);
    border-radius: 10px;
    padding: 0.3rem 0.6rem;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    min-height: 34px;
}

.funnel-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.funnel-pill {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(56, 40, 71, 0.75);
    background: rgba(18, 12, 22, 0.35);
    color: var(--text2);
    border-radius: 999px;
    padding: 0.3rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 800;
}

.funnel-pill strong {
    color: var(--text);
    font-weight: 900;
}

/* Needs Attention Section */
.needs-attention {
    margin-bottom: 1rem;
    display: none;
}

.needs-attention.has-items {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.attention-title {
    color: var(--warn) !important;
}

.attention-badge {
    background: var(--warn);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.attention-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.attention-item {
    background: var(--card);
    border: 2px solid var(--warn);
    border-radius: 14px;
    padding: 0.85rem;
    cursor: pointer;
}

.attention-item.booking {
    border-color: var(--success);
}

.attention-item.booking.past {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(168, 85, 247, 0.05));
}

.attention-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.attention-type {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.attention-type.reply {
    color: var(--warn);
}

.attention-type.booking {
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.attention-type.question {
    color: var(--accent);
}

.booking-countdown {
    font-size: 0.55rem;
    padding: 0.15rem 0.4rem;
    background: rgba(52, 211, 153, 0.15);
    border-radius: 6px;
    font-weight: 600;
}

.booking-countdown.urgent {
    background: rgba(248, 113, 113, 0.2);
    color: var(--danger);
}

.booking-pending {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    color: var(--warn);
    padding: 0.4rem 0.5rem;
    background: rgba(251, 191, 36, 0.1);
    border-radius: 6px;
    margin-bottom: 0.4rem;
}

.booking-pending.critical {
    color: var(--danger);
    background: rgba(248, 113, 113, 0.15);
}

.booking-pending svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
}

.attention-phone {
    font-size: 0.75rem;
    color: var(--text2);
}

.attention-preview {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.35;
    margin-bottom: 0.5rem;
}

.attention-actions {
    display: flex;
    gap: 0.5rem;
}

.attention-btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: 8px;
    border: none;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
}

.attention-btn.primary {
    background: var(--warn);
    color: #000;
}

.attention-btn.booking-primary {
    background: var(--success);
    color: #000;
}

.attention-btn.secondary {
    background: var(--bg2);
    color: var(--text2);
    border: 1px solid var(--border);
}

.attention-btn.view-convo {
    flex: 0 0 auto;
    background: var(--bg3);
    color: var(--text);
    padding: 0.5rem 0.75rem;
}

/* Enhanced Booking Card */
.booking-details {
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 8px;
}

.booking-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    padding: 0.25rem 0;
    color: var(--text);
}

.booking-row.address {
    color: var(--text2);
    font-size: 0.75rem;
}

.booking-icon {
    font-size: 0.62rem;
    width: 58px;
    letter-spacing: 0.06em;
    color: var(--muted);
    opacity: 0.9;
    text-align: left;
    flex: 0 0 auto;
}

.booking-duration {
    color: var(--muted);
    font-size: 0.7rem;
}

.booking-time {
    color: var(--text2);
    font-size: 0.8rem;
    font-weight: 500;
}

.booking-row.call-row {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.3rem;
}

.booking-call-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.booking-call-link:hover {
    text-decoration: underline;
}

.booking-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    padding: 0 0.25rem;
}

.confidence-label {
    font-size: 0.65rem;
    color: var(--muted);
}

.confidence-bar {
    flex: 1;
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    border-radius: 3px;
    transition: width 0.3s;
}

.confidence-pct {
    font-size: 0.65rem;
    color: var(--success);
    font-weight: 600;
    min-width: 28px;
}

.booking-actions {
    flex-wrap: wrap;
}

/* All Clear */
.all-clear {
    text-align: center;
    padding: 2rem 1rem;
    display: none;
}

.all-clear.active {
    display: block;
}

.all-clear-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.all-clear-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.all-clear-sub {
    font-size: 0.8rem;
    color: var(--muted);
}

/* AI Confidence Section */
.ai-confidence {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.confidence-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
}

.confidence-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.confidence-icon {
    font-size: 1rem;
}

.confidence-title {
    font-size: 0.85rem;
    font-weight: 500;
}

.confidence-count {
    font-size: 0.7rem;
    color: var(--muted);
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.confidence-toggle {
    font-size: 0.6rem;
    color: var(--muted);
    transition: transform 0.2s;
}

.confidence-toggle.expanded {
    transform: rotate(180deg);
}

.confidence-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.confidence-content.instant {
    transition: none;
}

.confidence-content.expanded {
    max-height: 400px;
}

.confidence-list {
    padding: 0.85rem;
    border-top: 1px solid var(--border);
}

.confidence-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 0.4rem;
    cursor: pointer;
}

.confidence-item.is-typing {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.confidence-item:last-child {
    margin-bottom: 0;
}

.confidence-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    flex-shrink: 0;
}

.confidence-info {
    flex: 1;
    min-width: 0;
}

.confidence-exchange {
    font-size: 0.75rem;
    color: var(--text2);
    line-height: 1.35;
}

.confidence-exchange .ai {
    color: var(--accent);
}

.confidence-exchange .ai.typing-pulse {
    animation: typingPulse 1.5s ease-in-out infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.confidence-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.2rem;
}

.confidence-time {
    font-size: 0.6rem;
    color: var(--muted);
}

.confidence-badge {
    font-size: 0.5rem;
    padding: 0.1rem 0.3rem;
    background: var(--glow);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 600;
}

.confidence-badge.warning {
    background: rgba(248, 113, 113, 0.2);
    color: var(--danger);
}

.confidence-item.flagged {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.confidence-item.flagged .confidence-avatar {
    background: var(--danger);
    color: white;
}

/* History Link */
.history-link-wrap {
    margin-bottom: 0.5rem;
}

.history-link {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
}

.history-toggle {
    font-size: 0.55rem;
    transition: transform 0.2s;
}

.history-toggle.expanded {
    transform: rotate(180deg);
}

.history-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.history-content.instant {
    transition: none;
}

.history-content.expanded {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.history-list {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.history-item.is-typing {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(168, 85, 247, 0.1));
}

.history-item:last-child {
    border-bottom: none;
}

.history-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.history-preview {
    font-size: 0.7rem;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-preview .ai {
    color: var(--accent);
}

.history-preview .ai.typing-pulse {
    animation: typingPulse 1.5s ease-in-out infinite;
}

.history-meta {
    text-align: right;
    flex-shrink: 0;
}

.history-time {
    font-size: 0.6rem;
    color: var(--muted);
}

.history-count {
    font-size: 0.55rem;
    padding: 0.1rem 0.35rem;
    background: var(--glow);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 600;
    margin-top: 0.15rem;
    display: inline-block;
}

.history-badge {
    font-size: 0.5rem;
    padding: 0.1rem 0.3rem;
    background: rgba(248, 113, 113, 0.2);
    color: var(--danger);
    border-radius: 4px;
    font-weight: 600;
    margin-top: 0.1rem;
    display: inline-block;
}

.history-item.flagged {
    background: rgba(248, 113, 113, 0.08);
}

.history-item.flagged .history-avatar {
    background: var(--danger);
    color: white;
}

/* Emergency FAB */
.emergency-fab {
    position: fixed;
    bottom: 1.5rem;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
    right: 1.25rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg2);
    border: 2px solid var(--border);
    cursor: pointer;
    z-index: 200;
    transition: all 0.2s;
    touch-action: manipulation;
}

.emergency-fab:active {
    transform: scale(0.95);
}

.emergency-fab svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    stroke: var(--text2);
    stroke-width: 2;
    fill: var(--text2);
}

.emergency-fab.paused {
    background: var(--danger);
    border-color: var(--danger);
}

.emergency-fab.paused svg {
    stroke: white;
    fill: white;
}

/* Conversation Overlay */
.conv-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.conv-overlay.active {
    transform: translateX(0);
    pointer-events: auto;
}

.conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0));
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(20,20,24,0.96), rgba(12,12,15,0.96));
    backdrop-filter: blur(10px);
}

.conv-actions{
    display:flex;
    align-items:center;
    gap:0.5rem;
}

.conv-menu-btn{
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
}
.conv-menu-btn:active{ transform: scale(0.96); }

.conv-back {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.conv-back:active {
    background: var(--bg3);
}

.conv-back svg {
    width: 18px;
    height: 18px;
    stroke: var(--text);
    stroke-width: 2;
    fill: none;
}

.conv-title {
    flex: 1;
    min-width: 0;
}

.conv-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: rgba(255,255,255,0.92);
    letter-spacing: 0.04em;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    flex: 0 0 auto;
}

.conv-info{
    padding: 0.8rem 0.85rem 0.7rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.conv-info-top{
    display:flex;
    align-items:center;
    gap:0.75rem;
}

.conv-info-top .conv-title{ flex:1; min-width:0; }

.conv-info-top .conv-status{
    margin-top: 0;
    font-size: 0.65rem;
    white-space: nowrap;
    flex: 0 0 auto;
    background: rgba(255, 109, 190, 0.10);
    border: 1px solid rgba(255, 109, 190, 0.18);
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--accent);
}

.conv-summary-row{
    margin-top: 0.55rem;
    display:flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.conv-summary{
    margin-top: 0;
    flex: 1;
    min-width: 0;
}

.conv-metrics{
    margin-top: 0;
    flex: 0 0 auto;
    display: none;
}

.conv-tools{
    margin-top: 0.65rem;
    display:flex;
    justify-content:flex-start;
}
.conv-tool-btn{
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 650;
    font-size: 0.85rem;
}
.conv-tool-btn:active{ transform: scale(0.98); }

.conv-menu-backdrop{
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0,0,0,0.55);
}
.conv-menu{
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 9001;
    background: linear-gradient(180deg, var(--bg2), var(--bg));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.6);
}
.conv-menu-title{
    font-weight: 800;
    margin: 2px 2px 10px;
    color: var(--text);
}
.conv-menu-item{
    width: 100%;
    text-align: left;
    padding: 12px 12px;
    border-radius: 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 700;
}
.conv-menu-item.danger{
    background: rgba(255, 71, 87, 0.12);
    border-color: rgba(255, 71, 87, 0.25);
    color: rgba(255,255,255,0.96);
}
.conv-menu-close{
    width: 100%;
    padding: 12px 12px;
    border-radius: 14px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    font-weight: 700;
}

.conv-name {
    font-weight: 750;
    font-size: 0.95rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-sub {
    font-size: 0.72rem;
    color: var(--text2);
    opacity: 0.9;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-summary{
    font-size: 0.78rem;
    color: rgba(255,255,255,0.86);
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-metrics{
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 2px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-status {
    font-size: 0.65rem;
    color: var(--accent);
    margin-top: 2px;
}

.conv-flag-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 0.4rem;
}

.conv-flag-btn:active {
    transform: scale(0.95);
    background: var(--warn);
}

.conv-flag-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--text2);
}

.conv-flag-btn.flagged {
    background: var(--warn);
    border-color: var(--warn);
}

.conv-flag-btn.flagged svg {
    stroke: #000;
}

.conv-flag-btn.blocked {
    background: var(--danger);
    border-color: var(--danger);
}

.conv-flag-btn.blocked svg {
    stroke: #fff;
}

.conv-ai-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--danger);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.conv-ai-toggle:active {
    transform: scale(0.95);
}

.conv-ai-toggle svg {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2;
    fill: white;
}

.conv-ai-toggle.paused {
    background: var(--success);
}

.conv-context {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: rgba(26, 18, 34, 0.65);
}

.conv-context-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.conv-stage {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text);
}

.conv-chip-row {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.conv-chip {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text2);
    border: 1px solid rgba(56, 40, 71, 0.7);
    background: rgba(18, 12, 22, 0.35);
    border-radius: 999px;
    padding: 0.25rem 0.5rem;
}

.conv-client-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.conv-client-kv {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 72px;
}

.conv-client-kv .k {
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.conv-client-kv .v {
    font-size: 0.82rem;
    color: var(--text2);
    font-weight: 800;
}

.conv-client-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-left: auto;
}

.conv-note-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.6rem;
}

.conv-note {
    flex: 1;
    min-width: 140px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.55rem 0.65rem;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
}

.conv-mini {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text2);
    border-radius: 12px;
    padding: 0.45rem 0.6rem;
    cursor: pointer;
    font-weight: 800;
    min-height: 34px;
}

.conv-mini.primary {
    background: var(--grad);
    border: none;
    color: white;
}

.conv-mini:active {
    transform: scale(0.98);
}

.conv-ptr {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.7rem;
    color: var(--text2);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.conv-ptr.visible {
    display: flex;
}

.conv-ptr.refreshing .conv-ptr-spinner {
    animation: spin 0.8s linear infinite;
}

.conv-ptr-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.conv-messages {
    flex: 1;
    padding: 0.85rem;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    -webkit-overflow-scrolling: touch;
}

.msg {
    max-width: 80%;
    padding: 0.6rem 0.85rem;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.msg.in {
    background: var(--bg2);
    color: var(--text);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.msg.out {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.msg.out.ai {
    background: var(--bg3);
    border: 1px solid var(--accent);
    color: var(--text);
}

.msg-ai-tag {
    font-size: 0.5rem;
    color: var(--accent);
    margin-top: 0.2rem;
}

.typing-indicator {
    display: none;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 18px;
    align-self: flex-end;
    margin: 0.25rem 0;
    color: #fff;
}

.typing-indicator.active {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

.conv-input-area.ai-typing textarea {
    opacity: 0.3 !important;
    pointer-events: none !important;
    background: #333 !important;
}

.conv-input-area.ai-typing .send-btn {
    opacity: 0.3 !important;
    pointer-events: none !important;
}

.conv-input-area.ai-typing {
    position: relative;
}

.conv-input-area.ai-typing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10;
    pointer-events: none;
}

.conv-input-area {
    padding: 0.65rem;
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.conv-input-hint {
    font-size: 0.65rem;
    color: var(--muted);
    text-align: center;
    margin-bottom: 0.4rem;
}

.conv-input-hint button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    padding: 0.3rem;
}

.conv-input {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.conv-input textarea {
    flex: 1;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 0.6rem 0.85rem;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    resize: none;
    max-height: 100px;
}

.conv-input textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn svg {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2;
    fill: none;
}

.conv-correction {
    display: none;
    padding: 0.75rem;
    background: var(--card);
    border-top: 1px solid var(--warn);
}

.conv-correction.active {
    display: block;
}

.conv-correction-label {
    font-size: 0.65rem;
    color: var(--warn);
    margin-bottom: 0.4rem;
}

.conv-correction-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.conv-correction-actions {
    display: flex;
    gap: 0.4rem;
}

.conv-correction-btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: 8px;
    border: none;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.conv-correction-btn.cancel {
    background: var(--bg2);
    color: var(--text2);
}

.conv-correction-btn.send {
    background: var(--warn);
    color: #000;
}

/* Confirm Modal */
.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 600;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.confirm-modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.confirm-modal {
    background: var(--card);
    border-radius: 16px;
    width: 100%;
    max-width: 320px;
    padding: 1.25rem;
    transform: scale(0.9);
    transition: transform 0.2s;
}

.confirm-modal-backdrop.open .confirm-modal {
    transform: scale(1);
}

.confirm-modal-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
}

.confirm-modal-msg {
    font-size: 0.85rem;
    color: var(--text2);
    text-align: center;
    margin-bottom: 1.25rem;
    line-height: 1.4;
}

.confirm-modal-actions {
    display: flex;
    gap: 0.75rem;
}

.confirm-modal-btn {
    flex: 1;
    padding: 0.75rem;
    border-radius: 10px;
    border: none;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

.confirm-modal-btn:active {
    transform: scale(0.97);
}

.confirm-modal-btn.cancel {
    background: var(--bg2);
    color: var(--text);
}

.confirm-modal-btn.confirm {
    background: var(--accent);
    color: white;
}

.confirm-modal-btn.danger {
    background: var(--danger);
    color: white;
}

/* Settings Panel */
.settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s;
}

.settings-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 85vw);
    background: var(--card);
    border-left: 1px solid var(--border);
    z-index: 450;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.settings-panel.open {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.85rem;
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0));
    border-bottom: 1px solid var(--border);
}

.settings-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.settings-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.settings-close svg {
    width: 16px;
    height: 16px;
    stroke: var(--text2);
    stroke-width: 2;
    fill: none;
}

.settings-content {
    flex: 1;
    padding: 0.85rem;
    overflow-y: auto;
}

.settings-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem;
    background: var(--bg2);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.settings-user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.settings-user-info {
    flex: 1;
    min-width: 0;
}

.settings-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-user-status {
    font-size: 0.7rem;
    color: var(--success);
}

.settings-user-status.paused {
    color: var(--danger);
}

.settings-section {
    margin-bottom: 1.25rem;
}

.settings-section-title {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.settings-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    cursor: pointer;
}

.settings-toggle-item input {
    display: none;
}

.settings-toggle-item span:first-child {
    font-size: 0.9rem;
    color: var(--text);
}

.settings-toggle-track {
    width: 44px;
    height: 24px;
    background: var(--bg3);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}

.settings-toggle-thumb {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--text2);
    border-radius: 10px;
    top: 2px;
    left: 2px;
    transition: transform 0.2s, background 0.2s;
}

.settings-toggle-item input:checked + .settings-toggle-track {
    background: var(--accent);
}

.settings-toggle-item input:checked + .settings-toggle-track .settings-toggle-thumb {
    transform: translateX(20px);
    background: white;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    min-height: 40px;
}

.settings-item-label {
    font-size: 0.85rem;
}

.settings-item svg {
    width: 16px;
    height: 16px;
    stroke: var(--muted);
    stroke-width: 2;
    fill: none;
}

.lang-toggle {
    display: flex;
    background: var(--bg);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--border);
}

.lang-btn {
    padding: 0.35rem 0.65rem;
    border: none;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
}

.lang-btn.active {
    background: var(--glow);
    color: var(--accent);
}

.learning-history {
    max-height: 180px;
    overflow-y: auto;
}

.learning-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.learning-item:last-child {
    border: none;
}

.learning-question {
    font-size: 0.7rem;
    color: var(--text2);
    margin-bottom: 0.2rem;
}

.learning-answer {
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.learning-answer.yes {
    color: var(--success);
}

.learning-answer.no {
    color: var(--danger);
}

.learning-time {
    font-size: 0.55rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.logout-btn {
    padding: 0.85rem;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border);
}

.logout-btn button {
    width: 100%;
    padding: 0.75rem;
    min-height: 44px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--danger);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

/* Emergency Modal */
.emergency-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.emergency-modal.active {
    display: flex;
}

.emergency-content {
    background: var(--card);
    border: 2px solid var(--danger);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
    max-width: 300px;
}

.emergency-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(248, 113, 113, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
}

.emergency-icon-wrap svg {
    width: 28px;
    height: 28px;
    stroke: var(--danger);
    stroke-width: 2;
    fill: none;
}

.emergency-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.emergency-text {
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 1.25rem;
    line-height: 1.45;
}

.emergency-btn {
    padding: 0.85rem;
    border-radius: 12px;
    border: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-bottom: 0.4rem;
}

.emergency-btn.danger {
    background: var(--danger);
    color: white;
}

.emergency-btn.secondary {
    background: var(--bg2);
    color: var(--text2);
}

/* Language visibility */
[data-lang="en"] {
    display: none;
}

html[lang="en"] [data-lang="en"] {
    display: inline;
}

html[lang="en"] [data-lang="fr"] {
    display: none;
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg2) 25%, var(--bg3) 50%, var(--bg2) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive */
@media (max-width: 375px) {
    .stat-value {
        font-size: 1.1rem;
    }
    .quick-stats {
        padding: 0.65rem 0.35rem;
    }
}

@media (min-width: 769px) {
    .dashboard-app {
        max-width: 100%;
        margin: 0;
    }
    .emergency-fab {
        position: absolute;
        right: 1.25rem;
        bottom: 1.5rem;
    }
    .settings-panel {
        position: absolute;
        right: 0;
    }
    .conv-overlay {
        position: absolute;
    }
    .emergency-modal {
        position: absolute;
    }
    .ai-paused-banner {
        position: absolute;
    }
}
