/* ══════════════════════════════════════════════
   DESIGN SYSTEM & VARIABLES
   ══════════════════════════════════════════════ */
:root {
    --font-primary: 'Outfit', sans-serif;
    
    /* Cores Premium HSL — Tema Escuro (Padrão) */
    --bg-dark: hsl(200, 31%, 6%);
    --bg-card: hsl(200, 24%, 10%);
    --bg-input: hsl(200, 24%, 14%);
    
    --border-color: hsla(200, 24%, 20%, 0.4);
    --border-hover: hsla(200, 24%, 35%, 0.6);
    
    --accent: hsl(167, 100%, 33%); /* WhatsApp-like green */
    --accent-hover: hsl(167, 100%, 28%);
    --accent-glow: hsla(167, 100%, 33%, 0.25);
    
    --text-main: hsl(0, 0%, 93%);
    --text-muted: hsl(200, 15%, 70%);
    --text-dim: hsl(200, 15%, 50%);
    
    /* Cores de Status */
    --status-success: hsl(150, 84%, 37%);
    --status-success-bg: hsla(150, 84%, 37%, 0.15);
    --status-warning: hsl(35, 100%, 50%);
    --status-warning-bg: hsla(35, 100%, 50%, 0.15);
    --status-danger: hsl(350, 80%, 55%);
    --status-danger-bg: hsla(350, 80%, 55%, 0.15);
    --status-info: hsl(205, 90%, 55%);
    --status-info-bg: hsla(205, 90%, 55%, 0.15);
}

/* Tema Claro (Opcional - Ativado via Classe) */
body.light-theme {
    --bg-dark: hsl(210, 20%, 96%);      /* Cinza claro e limpo */
    --bg-card: hsl(0, 0%, 100%);        /* Cards puramente brancos */
    --bg-input: hsl(210, 20%, 98%);
    
    --border-color: hsla(200, 20%, 80%, 0.5);
    --border-hover: hsla(200, 20%, 60%, 0.8);
    
    --text-main: hsl(200, 30%, 15%);    /* Texto cinza bem escuro */
    --text-muted: hsl(200, 15%, 45%);
    --text-dim: hsl(200, 15%, 60%);
    
    --accent-glow: hsla(167, 100%, 33%, 0.12);
}

/* Transições Suaves ao Alternar Tema */
body, .bot-card, .stat-card, input, button, header, footer {
    transition: background-color 0.4s ease, border-color 0.4s ease, color 0.4s ease, transform 0.25s ease;
}

body.light-theme .glass-bg-decor {
    opacity: 0.12; /* Decoração mais suave no modo claro */
}

/* ══════════════════════════════════════════════
   RESET & BASE STYLES
   ══════════════════════════════════════════════ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Blur Elements */
.glass-bg-decor {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.25;
}
.decor-1 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    top: -100px;
    left: -150px;
}
.decor-2 {
    width: 500px;
    height: 500px;
    background: hsl(210, 80%, 40%);
    bottom: -150px;
    right: -150px;
}

/* Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    z-index: 1;
}

/* ══════════════════════════════════════════════
   COMPONENTS: HEADER
   ══════════════════════════════════════════════ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), hsl(210, 80%, 40%));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 8px 24px hsla(167, 100%, 33%, 0.2);
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Buttons */
.btn {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px hsla(167, 100%, 33%, 0.4);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: hsla(200, 24%, 20%, 0.3);
    border-color: var(--border-hover);
}

.btn-danger {
    background-color: var(--status-danger-bg);
    color: var(--status-danger);
    border: 1px solid hsla(350, 80%, 55%, 0.2);
}

.btn-danger:hover {
    background-color: var(--status-danger);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px hsla(350, 80%, 55%, 0.25);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ══════════════════════════════════════════════
   COMPONENTS: STATS BAR
   ══════════════════════════════════════════════ */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.text-success { color: var(--status-success); }
.text-warning { color: var(--status-warning); }

/* ══════════════════════════════════════════════
   COMPONENTS: BOTS GRID & CARDS
   ══════════════════════════════════════════════ */
.bots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    min-height: 250px;
}

.bot-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.bot-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.bot-info {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    flex: 1;
    min-width: 0;
}

.bot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background-color: hsla(200, 24%, 20%, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--accent);
    flex-shrink: 0;
}

.bot-title {
    min-width: 0;
    word-break: break-word;
}

.bot-title h2 {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}

.bot-title span {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Badges */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-connected {
    background-color: var(--status-success-bg);
    color: var(--status-success);
    border: 1px solid hsla(150, 84%, 37%, 0.2);
}

.badge-pending {
    background-color: var(--status-warning-bg);
    color: var(--status-warning);
    border: 1px solid hsla(35, 100%, 50%, 0.2);
}

.badge-disconnected {
    background-color: var(--status-danger-bg);
    color: var(--status-danger);
    border: 1px solid hsla(350, 80%, 55%, 0.2);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 1.5s infinite;
}

.badge-connected .pulse-dot { background-color: var(--status-success); }
.badge-pending .pulse-dot { background-color: var(--status-warning); }
.badge-disconnected .pulse-dot { background-color: var(--status-danger); }

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.6; }
}

/* QR Code Display */
.qr-container {
    background: #fff;
    padding: 1rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    margin: 0.5rem 0;
    animation: fadeIn 0.4s ease-out;
}

.qr-image {
    width: 180px;
    height: 180px;
    object-fit: contain;
}

.qr-caption {
    font-size: 0.75rem;
    color: #4b5563; /* Gray in white background */
    margin-top: 0.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Card Details */
.bot-details {
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid hsla(200, 24%, 20%, 0.2);
    padding-bottom: 0.5rem;
}

.detail-label {
    color: var(--text-muted);
}

.detail-value {
    font-weight: 500;
    color: var(--text-main);
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
}

.card-actions button {
    flex: 1 1 calc(50% - 0.5rem);
    justify-content: center;
}

/* Empty/Loading States */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-dim);
    padding: 4rem 2rem;
    text-align: center;
    background-color: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: 20px;
}

.empty-state i {
    font-size: 3rem;
    color: hsla(200, 15%, 50%, 0.3);
}

/* ══════════════════════════════════════════════
   COMPONENTS: MODALS
   ══════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(6, 12, 16, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close:hover {
    color: #fff;
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input, .form-group select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-family: var(--font-primary);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-group select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group small {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ══════════════════════════════════════════════
   COMPONENTS: TOASTS
   ══════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    min-width: 280px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.toast-success { border-left: 4px solid var(--status-success); }
.toast-error { border-left: 4px solid var(--status-danger); }
.toast-info { border-left: 4px solid var(--status-info); }

.toast-icon {
    font-size: 1.25rem;
}
.toast-success .toast-icon { color: var(--status-success); }
.toast-error .toast-icon { color: var(--status-danger); }
.toast-info .toast-icon { color: var(--status-info); }

.toast-content {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ══════════════════════════════════════════════
   ANIMATIONS & KEYFRAMES
   ══════════════════════════════════════════════ */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive Footer */
.app-footer {
    margin-top: auto;
    padding-top: 3rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border-color);
}

/* Collapsible Logs Drawer inside Bot Cards */
.logs-drawer {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.75rem;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
}

body.light-theme .logs-drawer {
    background: rgba(0, 0, 0, 0.03);
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.log-item:last-child {
    border-bottom: none;
}

.log-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-right: 0.75rem;
}

.log-phone {
    font-weight: 600;
    color: var(--text-main);
}

.log-time {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.log-msg {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    transition: all 0.2s ease-in-out;
}

.log-msg.expanded {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    margin-top: 2px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border-left: 2px solid var(--accent);
}

.log-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 0.75rem;
}

.log-status-enviado {
    color: var(--status-success);
}

.log-status-erro {
    color: var(--status-danger);
}

/* Tabular Logs History & Test Send Form */
.logs-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-main);
}

.logs-table th {
    text-align: left;
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .logs-table th {
    background: rgba(0, 0, 0, 0.04);
}

.logs-table td {
    padding: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

.log-row-header {
    cursor: pointer;
    transition: background 0.2s ease;
}

.log-row-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

body.light-theme .log-row-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.log-row-details {
    display: none;
    background: rgba(0, 0, 0, 0.15);
}

body.light-theme .log-row-details {
    background: rgba(0, 0, 0, 0.02);
}

.log-row-details.active {
    display: table-row;
}

.log-row-details td {
    padding: 0.6rem;
    white-space: normal;
    word-break: break-word;
    border-left: 3px solid var(--accent);
    color: var(--text-muted);
    line-height: 1.3;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
}

.status-pill-enviado {
    background: rgba(37, 211, 102, 0.12);
    color: var(--status-success);
}

.status-pill-erro {
    background: rgba(239, 68, 68, 0.12);
    color: var(--status-danger);
}
