/* ═══════════════════════════════════════════════ */
/*  NegociBot — Calculadora de Distribuição        */
/*  Design: Dark Mode Premium / Glassmorphism      */
/* ═══════════════════════════════════════════════ */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-green: #22c55e;
    --accent-green-bg: rgba(34, 197, 94, 0.1);
    --accent-blue: #3b82f6;
    --accent-blue-bg: rgba(59, 130, 246, 0.1);
    --accent-purple: #a855f7;
    --accent-purple-bg: rgba(168, 85, 247, 0.1);
    --accent-orange: #f97316;
    --accent-orange-bg: rgba(249, 115, 22, 0.1);
    --accent-red: #ef4444;
    --accent-red-bg: rgba(239, 68, 68, 0.1);
    --accent-cyan: #06b6d4;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* ═══ HEADER ═══ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.header-top h1 {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #22c55e, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-top p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

/* ═══ ALERT BANNER ═══ */
.alert-banner {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown 0.3s ease;
}

.alert-banner.hidden { display: none; }

.alert-banner.danger {
    background: var(--accent-red-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-banner.success {
    background: var(--accent-green-bg);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.alert-banner.warning {
    background: var(--accent-orange-bg);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: #fdba74;
}

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

/* ═══ SUMMARY GRID ═══ */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

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

.summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.summary-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    transition: var(--transition);
}

.summary-value.green { color: var(--accent-green); }
.summary-value.red { color: var(--accent-red); }
.summary-value.blue { color: var(--accent-blue); }
.summary-value.purple { color: var(--accent-purple); }

/* ═══ SECTIONS ═══ */
.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
}

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

.section-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.section-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ═══ BUTTONS ═══ */
.btn-add {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(34, 197, 94, 0.3);
    background: var(--accent-green-bg);
    color: var(--accent-green);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-add:hover {
    background: rgba(34, 197, 94, 0.2);
    transform: translateY(-1px);
}

.btn-copy {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: var(--accent-blue-bg);
    color: var(--accent-blue);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-copy:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.btn-danger {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: transparent;
    color: var(--accent-red);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-danger:hover {
    background: var(--accent-red-bg);
}

.btn-toggle {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-toggle.active {
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--accent-green);
    background: var(--accent-green-bg);
}

.btn-toggle.inactive {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
    background: var(--accent-red-bg);
}

/* ═══ INPUTS ═══ */
input[type="number"],
input[type="text"],
select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.list-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.list-input-row label {
    font-size: 14px;
    color: var(--text-secondary);
}

.list-input-row input {
    width: 160px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
}

.select-tier {
    min-width: 140px;
}

.input-qty {
    width: 70px;
    text-align: center;
}

/* ═══ TIERS GRID ═══ */
.tiers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.tier-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    transition: var(--transition);
}

.tier-card:hover {
    border-color: var(--border-hover);
}

.tier-card .tier-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.tier-card .tier-name {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.tier-card .tier-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.tier-card .tier-info span {
    color: var(--text-primary);
    font-weight: 600;
}

.tier-card .tier-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.tier-card .tier-edit-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.tier-card .tier-edit-row label {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 70px;
}

.tier-card .tier-edit-row input {
    width: 90px;
    padding: 6px 8px;
    font-size: 13px;
}

/* Divisor dentro do card de tier */
.tier-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

/* Breakdown de dados por tier */
.tier-breakdown {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px;
    margin-top: 6px;
}

.tier-bk-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.tier-bk-label {
    font-size: 11px;
    color: var(--text-muted);
}

.tier-bk-value {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.tier-bk-bar {
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
}


/* ═══ CHIPS GRID ═══ */
.chips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.chip-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    position: relative;
}

.chip-card:hover {
    border-color: var(--border-hover);
}

.chip-card.disabled {
    opacity: 0.4;
}

.chip-card .chip-letter {
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip-card .chip-tier-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chip-card .chip-info {
    font-size: 11px;
    color: var(--text-muted);
}

.chip-card .chip-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

/* ═══ RESULT GRID ═══ */
.result-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result-row {
    display: grid;
    grid-template-columns: 50px 100px 1fr 80px 80px;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    animation: fadeIn 0.3s ease;
}

.result-row:hover {
    border-color: var(--border-hover);
}

.result-row .r-letter {
    font-size: 16px;
    font-weight: 800;
}

.result-row .r-tier {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    text-align: center;
}

.result-row .r-bar-wrap {
    position: relative;
    height: 24px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    overflow: hidden;
}

.result-row .r-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.result-row .r-bar-label {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.result-row .r-percent {
    font-size: 16px;
    font-weight: 800;
    text-align: right;
}

.result-row .r-contacts {
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    color: var(--text-secondary);
}

.result-header {
    display: grid;
    grid-template-columns: 50px 100px 1fr 80px 80px;
    gap: 12px;
    padding: 6px 14px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-header span:nth-child(4),
.result-header span:nth-child(5) {
    text-align: right;
}

/* ═══ EMPTY STATE ═══ */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══ MODAL ═══ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.hidden { display: none; }

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-header button {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.modal-header button:hover {
    background: var(--accent-red-bg);
    color: var(--accent-red);
}

#modalBody {
    padding: 20px;
}

#modalBody .form-group {
    margin-bottom: 14px;
}

#modalBody .form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

#modalBody .form-group input,
#modalBody .form-group select {
    width: 100%;
}

#modalBody .btn-save {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    margin-top: 8px;
}

#modalBody .btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* ═══ TIER COLORS ═══ */
.tier-color-0 { --tc: var(--accent-green); --tc-bg: var(--accent-green-bg); }
.tier-color-1 { --tc: var(--accent-blue); --tc-bg: var(--accent-blue-bg); }
.tier-color-2 { --tc: var(--accent-purple); --tc-bg: var(--accent-purple-bg); }
.tier-color-3 { --tc: var(--accent-orange); --tc-bg: var(--accent-orange-bg); }
.tier-color-4 { --tc: var(--accent-cyan); --tc-bg: rgba(6, 182, 212, 0.1); }

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.pulse { animation: pulse 0.4s ease; }

/* ═══ TOAST ═══ */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    z-index: 2000;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow);
}

.toast.success {
    background: #16a34a;
    color: #fff;
}

.toast.info {
    background: #2563eb;
    color: #fff;
}

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

/* ═══ RANDOMIZADOR — 2 NÍVEIS ═══ */

.rand-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease;
}

/* Blocos internos têm borda lateral colorida via inline style */
.rand-internal {
    border-left-width: 3px;
}

.rand-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rand-title span {
    font-weight: 600;
    color: var(--text-secondary);
}

.rand-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.rand-subtitle strong {
    font-weight: 800;
}

.rand-header {
    display: grid;
    grid-template-columns: 1fr 160px 100px;
    gap: 8px;
    padding: 5px 10px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.rand-header span:nth-child(2),
.rand-header span:nth-child(3) {
    text-align: right;
}

.rand-row {
    display: grid;
    grid-template-columns: 1fr 160px 100px;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.rand-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.rand-bm {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.rand-contacts {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
    font-weight: 500;
}

.rand-pct {
    font-size: 22px;
    font-weight: 900;
    text-align: right;
    letter-spacing: -1px;
    line-height: 1;
}

.rand-bar-wrap {
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 2px 10px 6px;
    overflow: hidden;
}

.rand-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.rand-equal-tag {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.02);
    text-align: center;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 600px) {
    body { padding: 0 10px 30px; }
    header { padding: 14px 0; }
    .header-top h1 { font-size: 18px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-value { font-size: 22px; }
    .result-row { grid-template-columns: 40px 80px 1fr 60px 60px; gap: 6px; padding: 8px 10px; }
    .result-header { grid-template-columns: 40px 80px 1fr 60px 60px; gap: 6px; }
    .chips-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .tiers-grid { grid-template-columns: 1fr; }
    .section-actions { width: 100%; }
    .list-input-row { flex-direction: column; align-items: flex-start; }
    .list-input-row input { width: 100%; }
    .rand-header { grid-template-columns: 1fr 100px 70px; }
    .rand-row { grid-template-columns: 1fr 100px 70px; }
    .rand-pct { font-size: 18px; }
}

