/* Kasaloma Twilio Campaign — campaign.css
   Inherits CSS variables from kcrm-style (--primary, --accent, etc.)
*/

/* ══ Nav link injected by JS ══ */
.ktc-nav-link {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
}
.ktc-nav-link:hover,
.ktc-nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.12);
}

/* ══ Page header ══ */
.ktc-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.ktc-page-title {
    display: flex;
    align-items: center;
    gap: 14px;
}
.ktc-title-icon { font-size: 32px; }
.ktc-page-title h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 2px;
}
.ktc-page-title p {
    font-size: 12px;
    color: var(--muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ══ Connection status dots ══ */
.ktc-status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ktc-status-dot.connected    { background: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
.ktc-status-dot.disconnected { background: #ef4444; box-shadow: 0 0 0 2px #fee2e2; }

/* ══ Tabs ══ */
.ktc-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.ktc-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-radius: 8px 8px 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    transition: color .15s, background .15s;
}
.ktc-tab:hover { color: var(--primary); background: var(--bg); }
.ktc-tab.active {
    color: var(--primary);
    background: #fff;
    border-color: var(--border);
    border-bottom-color: #fff;
}

/* ══ Cards ══ */
.ktc-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.ktc-card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.ktc-card-toolbar h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

/* ══ Forms ══ */
.ktc-form { display: flex; flex-direction: column; gap: 0; }
.ktc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.ktc-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 16px;
}
.ktc-field label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .4px;
}
.ktc-field input[type=text],
.ktc-field input[type=email],
.ktc-field input[type=url],
.ktc-field input[type=password],
.ktc-field textarea,
.ktc-field select {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text);
    background: #f8fafc;
    transition: border-color .2s;
}
.ktc-field input:focus,
.ktc-field textarea:focus,
.ktc-field select:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}
.ktc-field small {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
}
.req { color: #ef4444; }

.ktc-form-group-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.ktc-form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* ══ Buttons ══ */
.ktc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
}
.ktc-btn:hover { opacity: .88; transform: translateY(-1px); }
.ktc-btn.primary  { background: var(--primary); color: #fff; }
.ktc-btn.danger   { background: #ef4444;         color: #fff; }
.ktc-btn.large    { padding: 12px 28px; font-size: 14px; }
.ktc-btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: border-color .15s;
}
.ktc-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.ktc-btn-sm {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: background .15s;
}
.ktc-btn-sm:hover    { background: #e2e8f0; }
.ktc-btn-sm.danger   { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
.ktc-btn-sm.danger:hover { background: #fee2e2; }

/* ══ Notices ══ */
.ktc-notice {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
}
.ktc-notice.success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.ktc-notice.error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.ktc-notice.warning { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }

/* ══ Section header (connect page) ══ */
.ktc-section-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.ktc-section-icon { font-size: 28px; flex-shrink: 0; }
.ktc-section-header h3 { font-size: 16px; font-weight: 700; color: var(--primary); margin: 0 0 4px; }
.ktc-section-header p  { font-size: 13px; color: var(--muted); margin: 0; }
.ktc-connected-badge {
    margin-left: auto;
    background: #d1fae5;
    color: #065f46;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    align-self: flex-start;
}

.ktc-url-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: #1e40af;
    margin-bottom: 12px;
}

/* ══ Help box ══ */
.ktc-help-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    margin-top: 24px;
}
.ktc-help-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}
.ktc-help-steps {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ktc-help-steps li {
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
}
.ktc-help-steps code {
    background: #e2e8f0;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--primary);
}

/* ══ Template grid ══ */
.ktc-filter-pills {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ktc-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
    transition: all .15s;
}
.ktc-pill:hover,
.ktc-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.ktc-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.ktc-template-card {
    border: 1.5px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow .15s, transform .15s;
    background: #fff;
}
.ktc-template-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.10); transform: translateY(-2px); }

.ktc-tpl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    gap: 8px;
}
.ktc-tpl-name { font-size: 13px; font-weight: 700; color: var(--primary); }
.ktc-status-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}
.ktc-tpl-image { padding: 8px 14px 0; }
.ktc-tpl-image img { width: 100%; border-radius: 8px; max-height: 120px; object-fit: cover; }
.ktc-tpl-body { padding: 10px 14px; font-size: 12px; color: var(--text); line-height: 1.6; }
.ktc-tpl-vars { padding: 0 14px 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ktc-var-label { font-size: 10px; color: var(--muted); font-weight: 600; }
.ktc-tpl-vars code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 10px; color: var(--primary); }
.ktc-tpl-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 10px;
    border-top: 1px solid var(--border);
    background: #fafafa;
}
.ktc-tpl-meta { font-size: 11px; color: var(--muted); }
.ktc-tpl-actions { display: flex; gap: 6px; }

/* ══ Toggle switch ══ */
.ktc-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.ktc-toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.ktc-toggle input { opacity: 0; width: 0; height: 0; }
.ktc-toggle-slider {
    position: absolute; inset: 0;
    background: #cbd5e1;
    border-radius: 22px;
    cursor: pointer;
    transition: background .2s;
}
.ktc-toggle-slider:before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.ktc-toggle input:checked + .ktc-toggle-slider { background: var(--primary); }
.ktc-toggle input:checked + .ktc-toggle-slider:before { transform: translateX(18px); }
.ktc-toggle-label { font-size: 13px; color: var(--text); font-weight: 500; }

.ktc-image-url-field { transition: opacity .2s; }
.ktc-image-preview { margin-top: 8px; }
.ktc-image-preview img { max-width: 220px; border-radius: 8px; border: 1px solid var(--border); }

/* ══ Template selector (create campaign) ══ */
.ktc-template-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.ktc-tpl-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.ktc-tpl-option:hover { border-color: var(--primary); background: #f0f4f8; }
.ktc-tpl-option.selected { border-color: var(--primary); background: #eff6ff; }
.ktc-tpl-option input[type=radio] { flex-shrink: 0; }
.ktc-tpl-option-inner { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ktc-tpl-option-name { font-size: 13px; font-weight: 600; color: var(--text); }
.ktc-tpl-option-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}
.ktc-tpl-option-badge.img  { background: #eff6ff; color: #1d4ed8; }
.ktc-tpl-option-badge.text { background: #f0fdf4; color: #16a34a; }

/* WhatsApp bubble preview */
.ktc-tpl-preview-panel {
    background: #e5ddd5;
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}
.ktc-wa-bubble-wrap { display: flex; justify-content: flex-end; }
.ktc-wa-bubble {
    background: #fff;
    border-radius: 12px 2px 12px 12px;
    padding: 10px 14px;
    max-width: 320px;
    font-size: 13px;
    color: #1a1a1a;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.ktc-wa-bubble img { width: 100%; border-radius: 8px; margin-bottom: 8px; }

/* ══ Contact list (create campaign) ══ */
.ktc-contact-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}
.ktc-search-input {
    flex: 1;
    min-width: 180px;
    padding: 7px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.ktc-filter-sel {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: #f8fafc;
}
.ktc-selected-count {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: #eff6ff;
    padding: 4px 10px;
    border-radius: 20px;
}

.ktc-contact-list {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    max-height: 360px;
    overflow-y: auto;
    background: #f8fafc;
}
.ktc-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
}
.ktc-contact-item:last-child { border-bottom: none; }
.ktc-contact-item:hover { background: #eff6ff; }
.ktc-contact-item.no-phone { opacity: .5; cursor: not-allowed; }
.ktc-contact-item input[type=checkbox] { flex-shrink: 0; }

.ktc-ci-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ktc-ci-info { flex: 1; min-width: 0; }
.ktc-ci-name { font-size: 12px; font-weight: 600; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ktc-ci-meta { font-size: 11px; color: var(--muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ktc-wa-tag  { background: #dcfce7; color: #16a34a; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.ktc-ph-tag  { background: #dbeafe; color: #1d4ed8; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.ktc-no-tag  { background: #fef9c3; color: #854d0e; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; }

/* ══ Delivery stats (campaign detail) ══ */
.ktc-delivery-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 16px 0;
}
.ktc-ds-card {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    border-top: 3px solid var(--ds-color, #64748b);
}
.ktc-ds-num   { font-size: 28px; font-weight: 800; color: var(--ds-color, #64748b); line-height: 1; margin-bottom: 4px; }
.ktc-ds-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

.ktc-progress-bar-wrap {
    height: 8px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 8px 0 4px;
}
.ktc-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 10px;
    transition: width .5s ease;
    min-width: 4px;
}

.ktc-detail-meta {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0 16px;
    flex-wrap: wrap;
}

.ktc-msg-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

/* ══ Empty state ══ */
.ktc-empty-state {
    text-align: center;
    padding: 48px 20px;
}
.ktc-empty-icon { font-size: 48px; margin-bottom: 12px; }
.ktc-empty-state h4 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.ktc-empty-state p  { font-size: 13px; color: var(--muted); margin: 0 0 16px; }

/* ══ Responsive ══ */
@media (max-width: 768px) {
    .ktc-form-row { grid-template-columns: 1fr; }
    .ktc-template-grid { grid-template-columns: 1fr; }
    .ktc-delivery-stats { grid-template-columns: 1fr 1fr; }
    .ktc-page-header { flex-direction: column; align-items: flex-start; }
}

/* ══ Connected status banner ══ */
.ktc-connected-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.ktc-connected-banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ktc-connected-banner strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #15803d;
}
.ktc-connected-banner span {
    font-size: 12px;
    color: #16a34a;
}

/* ══ Multi-segment progress bar ══ */
.ktc-progress-multi-wrap {
    display: flex;
    height: 10px;
    border-radius: 10px;
    overflow: hidden;
    background: #e2e8f0;
    margin: 12px 0 6px;
    gap: 1px;
}
.ktc-progress-segment {
    height: 100%;
    min-width: 0;
    transition: width .5s ease;
}
.ktc-progress-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.ktc-progress-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}
.ktc-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ══ Delivery stats — 5 columns ══ */
.ktc-delivery-stats {
    grid-template-columns: repeat(5, 1fr);
}
@media(max-width:768px) {
    .ktc-delivery-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ══ Twilio push info banner (template form) ══ */
.ktc-twilio-push-info {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.ktc-push-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
.ktc-twilio-push-info strong { display: block; font-size: 13px; font-weight: 700; color: #1e40af; margin-bottom: 4px; }
.ktc-twilio-push-info span { font-size: 12px; color: #3b82f6; line-height: 1.5; }

/* ══ Readonly status display ══ */
.ktc-status-readonly { display: flex; flex-direction: column; gap: 5px; }
