/* ============================================
   WHATSAPP PANEL - STYLESHEET
   Aesthetic: Dark Industrial + Green Accent
============================================ */

:root {
    --bg-base:       #0d0f12;
    --bg-surface:    #13161b;
    --bg-card:       #181c22;
    --bg-hover:      #1e232b;
    --bg-input:      #1a1e25;

    --border:        #262b34;
    --border-light:  #2e3440;

    --text-primary:  #e8ecf1;
    --text-secondary:#8b95a3;
    --text-muted:    #535e6e;

    --green:         #25d366;
    --green-dark:    #1aab52;
    --green-glow:    rgba(37, 211, 102, 0.15);
    --green-dim:     rgba(37, 211, 102, 0.08);

    --blue:          #3b82f6;
    --yellow:        #f59e0b;
    --red:           #ef4444;
    --purple:        #8b5cf6;

    --sidebar-w:     240px;
    --topbar-h:      60px;
    --radius:        10px;
    --radius-sm:     6px;
    --transition:    0.18s ease;

    --font-display:  'Syne', sans-serif;
    --font-body:     'DM Sans', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }

/* ---- LAYOUT ---- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition);
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

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

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 34px; height: 34px;
    background: var(--green-dim);
    border: 1px solid var(--green);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--green);
    flex-shrink: 0;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer; padding: 4px;
    border-radius: 4px;
    transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text-primary); }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-section {
    margin-bottom: 4px;
    padding: 0 12px;
}

.nav-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 4px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition);
    margin-bottom: 2px;
    font-size: 13.5px;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(37,211,102,0.2);
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px; height: 34px;
    background: var(--green-dim);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 12px; font-weight: 700;
    color: var(--green);
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--text-muted);
    transition: color var(--transition);
    padding: 4px;
}
.logout-btn:hover { color: var(--red); }

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.content-body {
    padding: 28px;
    flex: 1;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.card-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.2px;
}

/* ---- STATS GRID ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-light); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon.green  { background: var(--green-dim); color: var(--green); }
.stat-icon.blue   { background: rgba(59,130,246,0.1); color: var(--blue); }
.stat-icon.yellow { background: rgba(245,158,11,0.1); color: var(--yellow); }
.stat-icon.red    { background: rgba(239,68,68,0.1); color: var(--red); }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: var(--purple); }

.stat-info { flex: 1; }
.stat-value {
    font-family: var(--font-display);
    font-size: 26px; font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}
.stat-label { font-size: 12px; color: var(--text-muted); }

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }

td {
    padding: 12px 14px;
    font-size: 13.5px;
    color: var(--text-secondary);
    vertical-align: middle;
}

td strong { color: var(--text-primary); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.badge-success   { background: rgba(37,211,102,0.12); color: var(--green); }
.badge-danger    { background: rgba(239,68,68,0.12);  color: var(--red); }
.badge-warning   { background: rgba(245,158,11,0.12); color: var(--yellow); }
.badge-info      { background: rgba(59,130,246,0.12); color: var(--blue); }
.badge-secondary { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--green);
    color: #000;
    font-weight: 600;
}
.btn-primary:hover { background: var(--green-dark); color: #000; }

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

.btn-danger {
    background: rgba(239,68,68,0.1);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 9px 13px;
    font-size: 13.5px;
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--bg-card); }

/* ---- ALERTS ---- */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.alert-icon { font-size: 15px; }
.alert-success { background: rgba(37,211,102,0.1); border: 1px solid rgba(37,211,102,0.25); color: var(--green); }
.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.25);  color: var(--red); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); color: var(--yellow); }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25); color: var(--blue); }

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-left h2 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.page-header-left p { font-size: 13px; color: var(--text-muted); }

/* ---- MODALS ---- */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer; font-size: 20px;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* ---- GRID ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---- QR CODE ---- */
.qr-container {
    text-align: center;
    padding: 24px;
}
.qr-container img {
    max-width: 240px;
    border: 6px solid #fff;
    border-radius: 8px;
}
.qr-instruction {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 14px;
}

/* ---- INSTANCE CARD ---- */
.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.instance-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color var(--transition);
}
.instance-card:hover { border-color: var(--border-light); }
.instance-card.connected { border-left: 3px solid var(--green); }
.instance-card.disconnected { border-left: 3px solid var(--red); }
.instance-card.qr_code { border-left: 3px solid var(--yellow); }

.instance-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.instance-name {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.instance-phone { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.instance-actions { display: flex; gap: 6px; margin-top: 14px; }

/* ---- FUNIL STEPS ---- */
.funnel-steps { display: flex; flex-direction: column; gap: 8px; }

.funnel-step {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-number {
    width: 28px; height: 28px;
    background: var(--green-dim);
    border: 1px solid rgba(37,211,102,0.3);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: var(--green);
    flex-shrink: 0;
}

.step-info { flex: 1; min-width: 0; }
.step-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.step-delay { font-size: 11px; color: var(--text-muted); }

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 20px;
}
.pagination a, .pagination span {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.pagination a:hover { background: var(--bg-hover); color: var(--text-primary); }
.pagination .current { background: var(--green-dim); color: var(--green); border-color: rgba(37,211,102,0.3); }

/* ---- TOGGLE SWITCH ---- */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.toggle input { display: none; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: all var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 2px; top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--green-dim); border-color: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--green); }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(37,211,102,0.06) 0%, transparent 70%);
    top: -100px; left: -100px;
    pointer-events: none;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 44px;
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand .brand-icon {
    margin: 0 auto 12px;
    width: 48px; height: 48px;
    border-radius: 12px;
    font-size: 20px;
}
.login-brand h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}
.login-brand p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ---- BOT RULE CARD ---- */
.bot-rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
    transition: border-color var(--transition);
}
.bot-rule-card:hover { border-color: var(--border-light); }
.bot-rule-trigger {
    flex: 1;
    min-width: 0;
}
.bot-rule-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.bot-rule-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .content-body { padding: 16px; }
}
