/* ============================================================
   WDGAtende - Stylesheet Principal
   Paleta: WDG Sistemas
   Principal #01344C | Secundária #008BB6 | Laranja #FF9D00
   Fonte: Poppins (Google Fonts)
   ============================================================ */

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

/* ---- Variáveis — Paleta WDG Sistemas ---- */
:root {
    /* Cores principais */
    --primary:       #008BB6;       /* azul secundário WDG — botões, links */
    --primary-light: #00A8D9;       /* hover de botões */
    --primary-dark:  #006E92;       /* pressed state */
    --accent:        #FF9D00;       /* laranja WDG — destaques, badges */
    --accent-light:  #FFB733;       /* laranja claro */
    --sky:           #B3E5F5;       /* azul bem claro */
    --success:       #22C55E;
    --warning:       #FF9D00;       /* laranja WDG como warning */
    --danger:        #EF4444;
    --info:          #008BB6;

    --bg-body:       #EEEEEE;       /* cinza claro WDG */
    --bg-card:       #FFFFFF;
    --bg-sidebar:    #01344C;       /* azul principal WDG — sidebar */
    --sidebar-w:     240px;
    --sidebar-w-col: 70px;

    --text-main:     #202020;       /* escuro WDG */
    --text-muted:    #5A6A75;
    --text-light:    #96A7B0;
    --text-sidebar:  rgba(255,255,255,0.88);

    --border:        #D8E0E5;
    --shadow-sm:     0 1px 3px rgba(1,52,76,0.08);
    --shadow-md:     0 4px 16px rgba(1,52,76,0.12);
    --shadow-lg:     0 8px 32px rgba(1,52,76,0.18);

    --radius-sm:     6px;
    --radius-md:     12px;
    --radius-lg:     20px;

    --transition:    0.2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
input, select, textarea, button { font-family: inherit; }

/* ============================================================
   LAYOUT PRINCIPAL (Sidebar + Content)
   ============================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(175deg, #012438 0%, #01344C 50%, #008BB6 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
    box-shadow: 4px 0 20px rgba(1,52,76,0.25);
}

.sidebar-logo {
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
    min-height: 72px;
}

.sidebar-logo-img {
    width: 160px;
    height: auto;
    object-fit: contain;
    display: block;
    opacity: 0.95;
    transition: opacity 0.2s;
    /* drop-shadow garante visibilidade sobre qualquer fundo */
    filter: drop-shadow(0 0 1px rgba(255,255,255,0.3));
}

.sidebar-logo-img:hover {
    opacity: 0.75;
}

/* ---- Nav ---- */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 8px 4px;
    white-space: nowrap;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-link.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);  /* laranja WDG */
}

.nav-link .nav-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

/* Badge pulse — animação ao chegar novo atendimento */
@keyframes badgePulse {
    0%,100% { transform: scale(1);    background: var(--accent); }
    50%      { transform: scale(1.35); background: var(--accent-light); }
}

.nav-link .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,0.1); }

.sidebar-user .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF9D00, #FFB733);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-user .user-info { overflow: hidden; }
.sidebar-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user .user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

/* ---- Top Bar ---- */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    flex: 1;
}

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

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-size: 22px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.btn-menu-toggle:hover { background: var(--bg-body); }

/* ---- Page Content ---- */
.page-content {
    padding: 28px;
    flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.card-body {
    padding: 22px;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue    { background: #E8F6FB; color: var(--primary); }
.stat-icon.cyan    { background: #ECFEFF; color: var(--accent); }
.stat-icon.green   { background: #F0FDF4; color: var(--success); }
.stat-icon.orange  { background: #FFFBEB; color: var(--warning); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}
.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}
.stat-sub {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

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

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

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

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

tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    color: var(--text-main);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success  { background: #DCFCE7; color: #16A34A; }
.badge-warning  { background: #FEF9C3; color: #CA8A04; }
.badge-danger   { background: #FEE2E2; color: #DC2626; }
.badge-info     { background: #E0F2FE; color: #0284C7; }
.badge-secondary{ background: #F1F5F9; color: #64748B; }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
    box-shadow: 0 2px 8px rgba(1,52,76,0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 14px rgba(1,52,76,0.45);
}

.btn-secondary {
    background: #fff;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-secondary:hover { background: #E8F6FB; }

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

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #16A34A; }

.btn-icon {
    width: 36px; height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

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

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-main);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-control::placeholder { color: var(--text-light); }

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}
.alert-success { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.alert-danger   { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-warning  { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info     { background: #E0F2FE; color: #075985; border: 1px solid #BAE6FD; }

/* ============================================================
   AUTH PAGES (Login / Registro)
   ============================================================ */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #012438 0%, #008BB6 50%, #06B6D4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 44px 40px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(1,52,76,0.25);
    animation: fadeUp 0.4s ease;
}

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

.auth-logo {
    width: 100%;
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-img {
    width: 200px;          /* exibe em 200px — arquivo é 310px, então nitidez perfeita */
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto 10px;
    border-radius: 8px;    /* cantos levemente arredondados */
}

.auth-logo p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.auth-divider {
    text-align: center;
    margin: 20px 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================================
   WHATSAPP / QR CODE
   ============================================================ */
.qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    gap: 16px;
}

.qr-wrapper img {
    border: 4px solid var(--border);
    border-radius: var(--radius-md);
    max-width: 220px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}
.status-dot.connected    { background: var(--success); animation: none; }
.status-dot.disconnected { background: var(--danger);  animation: none; }
.status-dot.connecting   { background: var(--warning); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================================
   FILA DE ATENDIMENTO (Lista de espera)
   ============================================================ */
.queue-list { display: flex; flex-direction: column; gap: 1px; }

.queue-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    cursor: pointer;
}
.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: #F8FBFF; }

.queue-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.queue-info { flex: 1; min-width: 0; }
.queue-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.queue-phone { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.queue-time  { font-size: 11px; color: var(--text-light); white-space: nowrap; }

/* ============================================================
   CHAT VIEW (dentro do atendimento)
   ============================================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px - 56px);
    background: #EEEEEE;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg { display: flex; gap: 10px; max-width: 75%; }
.msg.from-client { align-self: flex-start; }
.msg.from-agent  { align-self: flex-end; flex-direction: row-reverse; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
}
.msg.from-client .msg-bubble {
    background: #fff;
    border-bottom-left-radius: 4px;
    color: var(--text-main);
}
.msg.from-agent .msg-bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-time {
    font-size: 10px;
    color: var(--text-light);
    align-self: flex-end;
    white-space: nowrap;
}

.chat-input-bar {
    padding: 14px 16px 28px;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--primary-light); }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 20px; }
.text-muted  { color: var(--text-muted); font-size: 13px; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }

/* ---- Scrollbar personalizada ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sky); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============================================================
   MOBILE OVERLAY (sidebar)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.show { display: block; }

    .main-content { margin-left: 0; }
    .btn-menu-toggle { display: flex; }

    .topbar { padding: 0 16px; }
    .page-content { padding: 16px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .auth-card { padding: 32px 22px; }
}

@media (max-width: 540px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 16px; }
    .topbar-title { font-size: 15px; }
    .msg { max-width: 90%; }
}
