/* ═══════════════════════════════════════════
 *  ZetaTeta CRM Panel — Dark Theme Styles
 * ═══════════════════════════════════════════ */

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

/* ── Variables ── */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1f2e;
    --bg-card-hover: #232640;
    --bg-input: #12141e;
    --border: #2a2d3e;
    --border-light: #363a50;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --text-muted: #5c6078;
    --green: #2A5C3F;
    --green-light: #3fcc7c;
    --green-pale: rgba(63, 204, 124, 0.1);
    --yellow: #f0b429;
    --yellow-pale: rgba(240, 180, 41, 0.1);
    --red: #ef4444;
    --red-pale: rgba(239, 68, 68, 0.1);
    --blue: #3b82f6;
    --blue-pale: rgba(59, 130, 246, 0.1);
    --purple: #8b5cf6;
    --radius: 12px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════
 *  SIDEBAR
 * ═══════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar__logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 2px;
    border-bottom: 1px solid var(--border);
}

.sidebar__logo-text {
    font-size: 20px;
    font-weight: 800;
    color: var(--green-light);
    letter-spacing: -0.5px;
}

.sidebar__logo-dot {
    color: var(--green-light);
    font-size: 8px;
    margin-top: -10px;
}

.sidebar__logo-crm {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-left: 8px;
    padding: 3px 8px;
    background: var(--bg-card);
    border-radius: 4px;
}

.sidebar__nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.sidebar__link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.sidebar__link--active {
    background: var(--green-pale);
    color: var(--green-light);
}

.sidebar__link--active svg {
    stroke: var(--green-light);
}

.sidebar__badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.sidebar__footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar__status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar__status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.sidebar__status-dot--connected {
    background: var(--green-light);
    box-shadow: 0 0 8px rgba(63, 204, 124, 0.4);
}

.sidebar__status-dot--disconnected {
    background: var(--red);
}

/* ═══════════════════════════════════════════
 *  MOBILE HEADER
 * ═══════════════════════════════════════════ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 99;
}

.mobile-header__toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.mobile-header__title {
    font-weight: 700;
    font-size: 16px;
    color: var(--green-light);
}

/* ═══════════════════════════════════════════
 *  MAIN CONTENT
 * ═══════════════════════════════════════════ */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    max-width: 1200px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page--active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page__title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.page__subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.page__actions {
    display: flex;
    gap: 10px;
}

/* ═══════════════════════════════════════════
 *  STAT CARDS
 * ═══════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.stat-card__icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-card--primary .stat-card__icon { background: var(--blue-pale); }
.stat-card--success .stat-card__icon { background: var(--green-pale); }
.stat-card--warning .stat-card__icon { background: var(--yellow-pale); }
.stat-card--info .stat-card__icon { background: rgba(139, 92, 246, 0.1); }

.stat-card__value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card__label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* ═══════════════════════════════════════════
 *  CARDS
 * ═══════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.card__action {
    background: none;
    border: none;
    color: var(--green-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.card__action:hover { opacity: 0.8; }

.card__body {
    padding: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ═══════════════════════════════════════════
 *  DISTRIBUTION BARS
 * ═══════════════════════════════════════════ */
.distribution { display: flex; flex-direction: column; gap: 16px; }

.distribution__bar { display: flex; align-items: center; gap: 12px; }

.distribution__label { flex: 0 0 160px; font-size: 13px; color: var(--text-secondary); }

.distribution__track {
    flex: 1;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.distribution__fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.distribution__fill--high { background: var(--green-light); }
.distribution__fill--medium { background: var(--yellow); }
.distribution__fill--low { background: var(--red); }

.distribution__count {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 28px;
    text-align: right;
}

/* ═══════════════════════════════════════════
 *  PRODUCT STATS
 * ═══════════════════════════════════════════ */
.product-stats { display: flex; flex-direction: column; gap: 16px; }

.product-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: 10px;
}

.product-stat__name { font-size: 14px; color: var(--text-secondary); }
.product-stat__count { font-size: 20px; font-weight: 800; color: var(--text-primary); }

/* ═══════════════════════════════════════════
 *  TABLE
 * ═══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

.table__empty {
    text-align: center;
    padding: 40px 16px !important;
    color: var(--text-muted) !important;
    font-style: italic;
}

/* Score badge */
.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
}

.score-badge--high { background: var(--green-pale); color: var(--green-light); }
.score-badge--medium { background: var(--yellow-pale); color: var(--yellow); }
.score-badge--low { background: var(--red-pale); color: var(--red); }

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge--new { background: var(--blue-pale); color: var(--blue); }
.status-badge--called { background: var(--green-pale); color: var(--green-light); }
.status-badge--scheduled { background: var(--yellow-pale); color: var(--yellow); }
.status-badge--not_needed { background: var(--red-pale); color: var(--red); }

/* Product badge */
.product-badge { font-weight: 600; }
.product-badge--teta { color: #8b5cf6; }
.product-badge--zeta { color: #f59e0b; }
.product-badge--bundle { color: var(--green-light); }

/* ═══════════════════════════════════════════
 *  FILTERS
 * ═══════════════════════════════════════════ */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-input,
.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.filter-input { min-width: 240px; }
.filter-select { min-width: 160px; }

.filter-input:focus,
.filter-select:focus {
    border-color: var(--green-light);
    box-shadow: 0 0 0 3px rgba(63, 204, 124, 0.1);
}

.filter-input::placeholder { color: var(--text-muted); }

/* ═══════════════════════════════════════════
 *  MODAL
 * ═══════════════════════════════════════════ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal--open {
    display: flex;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal__content {
    position: relative;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.3s ease;
}

.modal__content--wide { width: 680px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal__title { font-size: 18px; font-weight: 700; }

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.modal__close:hover { background: var(--bg-primary); color: var(--text-primary); }

.modal__body { padding: 24px; }

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

/* ═══════════════════════════════════════════
 *  BUTTONS
 * ═══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-light); color: #000; }

.btn--outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn--outline:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--ghost:hover { color: var(--text-primary); }

.btn--sm { padding: 6px 12px; font-size: 12px; }

.btn--danger { background: var(--red-pale); color: var(--red); }
.btn--danger:hover { background: var(--red); color: #fff; }

/* ═══════════════════════════════════════════
 *  FORM ELEMENTS
 * ═══════════════════════════════════════════ */
.form-group { margin-bottom: 20px; }

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--green-light);
    box-shadow: 0 0 0 3px rgba(63, 204, 124, 0.1);
}

.form-textarea { resize: vertical; }
.form-hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.input-group { display: flex; gap: 8px; }
.input-group .form-input { flex: 1; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ═══════════════════════════════════════════
 *  QUESTIONS LIST
 * ═══════════════════════════════════════════ */
.questions-list { display: flex; flex-direction: column; gap: 12px; }

.question-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: var(--transition);
}

.question-item:hover { border-color: var(--border-light); }

.question-item__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.question-item__order {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--green-pale);
    color: var(--green-light);
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
}

.question-item__text {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.question-item__actions {
    display: flex;
    gap: 6px;
}

.question-item__category {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-muted);
    margin-bottom: 10px;
}

.question-item__options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.question-item__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.question-item__option-score {
    font-weight: 700;
    color: var(--green-light);
    font-size: 12px;
}

.question-item--inactive { opacity: 0.5; }

/* Edit options in modal */
.edit-options { display: flex; flex-direction: column; gap: 10px; }

.edit-option-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.edit-option-row .form-input:first-child { flex: 1; }
.edit-option-row .form-input:last-of-type { width: 80px; }

.edit-option-remove {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

/* ═══════════════════════════════════════════
 *  SETTINGS
 * ═══════════════════════════════════════════ */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.connection-result {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.connection-result--success {
    background: var(--green-pale);
    color: var(--green-light);
}

.connection-result--error {
    background: var(--red-pale);
    color: var(--red);
}

/* ═══════════════════════════════════════════
 *  TOAST
 * ═══════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
    box-shadow: var(--shadow);
    min-width: 280px;
}

.toast--success { background: #166534; color: #bbf7d0; border: 1px solid #22c55e; }
.toast--error { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
.toast--info { background: #1e3a5f; color: #bfdbfe; border: 1px solid #3b82f6; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ═══════════════════════════════════════════
 *  RESPONSE DETAIL (Modal body)
 * ═══════════════════════════════════════════ */
.detail-section {
    margin-bottom: 24px;
}

.detail-section__title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row__label {
    font-size: 13px;
    color: var(--text-muted);
}

.detail-row__value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-score {
    text-align: center;
    padding: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    margin-bottom: 20px;
}

.detail-score__value {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
}

.detail-score__label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

.detail-ai-text {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.detail-answer {
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: 10px;
    margin-bottom: 8px;
}

.detail-answer__question {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.detail-answer__response {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.detail-answer__score {
    font-weight: 700;
    color: var(--green-light);
}

.detail-notes {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    outline: none;
}

.detail-notes:focus {
    border-color: var(--green-light);
}

.detail-status-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-status-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    transition: var(--transition);
}

.detail-status-btn:hover { border-color: var(--green-light); color: var(--text-primary); }
.detail-status-btn--active { background: var(--green-pale); border-color: var(--green-light); color: var(--green-light); }

/* ═══════════════════════════════════════════
 *  PAGINATION
 * ═══════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 20px;
}

.pagination__btn {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.pagination__btn:hover { border-color: var(--green-light); color: var(--text-primary); }
.pagination__btn--active { background: var(--green-pale); color: var(--green-light); border-color: var(--green-light); }
.pagination__btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ═══════════════════════════════════════════
 *  RESPONSIVE
 * ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar--open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .main {
        margin-left: 0;
        padding: 72px 16px 32px;
    }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .filters { flex-direction: column; }
    .filter-input, .filter-select { min-width: 100%; }

    .modal__content { max-width: 100%; margin: 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
