/* Admin Dashboard Styles */
:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f1f5f9;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--light);
    display: flex;
    min-height: 100vh;
    color: var(--dark);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 4px;
}

.sidebar-subtitle {
    font-size: 13px;
    color: var(--secondary);
}

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

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--secondary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--light);
    color: var(--dark);
}

.nav-item.active {
    background: var(--light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-item .icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.user-role {
    font-size: 12px;
    color: var(--secondary);
}

.btn-logout {
    width: 100%;
    padding: 8px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #dc2626;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

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

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.btn-icon:hover {
    background: var(--light);
}

.btn-icon .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Content */
.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px var(--shadow);
}

.stat-icon {
    font-size: 40px;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-label {
    font-size: 13px;
    color: var(--secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

/* Card */
.card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
    box-shadow: 0 1px 3px var(--shadow);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.card-body {
    padding: 24px;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--light);
    border-radius: 8px;
}

.status-label {
    font-weight: 600;
    color: var(--dark);
}

.status-badge {
    font-size: 20px;
}

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

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

.status-badge.status-error {
    color: var(--danger);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: var(--light);
}

.activity-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border-radius: 6px;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
}

.activity-time {
    font-size: 12px;
    color: var(--secondary);
}

/* Table */
.table-container {
    overflow-x: auto;
}

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

.data-table thead {
    background: var(--light);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--dark);
}

.data-table tbody tr:hover {
    background: var(--light);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover {
    background: var(--light);
}

.btn-sm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h3 {
    font-size: 20px;
    font-weight: 700;
}

/* Integrations Grid */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.integration-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

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

.integration-header h4 {
    font-size: 18px;
    font-weight: 600;
}

.integration-desc {
    color: var(--secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.integration-stats {
    padding: 16px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 16px;
}

.integration-stats span {
    font-size: 13px;
    color: var(--secondary);
}

.integration-stats strong {
    color: var(--dark);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.98);
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
}

/* Oculta todo o conteúdo quando modal está ativo */
body:has(.modal.active) .sidebar,
body:has(.modal.active) .main-content {
    filter: blur(10px);
    pointer-events: none;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 24px;
    color: var(--dark);
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.form-help {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--secondary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px;
    color: var(--secondary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover {
    background: var(--light);
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Colored Stat Card Variants ───────────────────────── */
.stat-card {
    border-top: 3px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.stat-card.stat-blue  { border-top-color: var(--primary); }
.stat-card.stat-green { border-top-color: var(--success); }
.stat-card.stat-orange{ border-top-color: var(--warning); }
.stat-card.stat-purple{ border-top-color: #8b5cf6; }

.stat-icon-wrap {
    font-size: 30px;
    width: 58px;
    height: 58px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon-wrap.blue   { background: rgba(14,165,233,0.12); }
.stat-icon-wrap.green  { background: rgba(16,185,129,0.12); }
.stat-icon-wrap.orange { background: rgba(245,158,11,0.12); }
.stat-icon-wrap.purple { background: rgba(139,92,246,0.12); }

.stat-trend {
    font-size: 12px;
    color: var(--success);
    margin-top: 3px;
    font-weight: 500;
}
.stat-trend.neutral { color: var(--secondary); }
.stat-trend.down    { color: var(--danger); }

/* ── Secondary KPI Row ────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px var(--shadow);
}
.kpi-icon  { font-size: 28px; flex-shrink: 0; }
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}
.kpi-label {
    font-size: 11px;
    color: var(--secondary);
    margin-top: 2px;
    line-height: 1.3;
}

/* ── Charts Row ───────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.charts-row .card { margin-bottom: 0; }
.chart-body { padding: 16px 20px 20px !important; position: relative; height: 240px; }
.chart-body canvas { max-height: 100%; }

/* Card header with subtitle */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header-sub {
    font-size: 12px;
    color: var(--secondary);
    font-weight: 400;
}

/* ── Dashboard bottom 2-col row ───────────────────────── */
.dashboard-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.dashboard-bottom-row .card { margin-bottom: 0; }

/* ── New Status List  ─────────────────────────────────── */
.status-list { display: flex; flex-direction: column; gap: 10px; }

.status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: var(--light);
    border-radius: 8px;
}
.status-row-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}
.status-row-value {
    font-size: 13px;
    color: var(--secondary);
}

/* ── Status Dots (pulsing) ────────────────────────────── */
.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
}
.status-dot.ok {
    background: var(--success);
    animation: pulse-ok 2.4s ease-in-out infinite;
}
.status-dot.error   { background: var(--danger); }
.status-dot.warn    { background: var(--warning); animation: pulse-warn 2s ease-in-out infinite; }

@keyframes pulse-ok {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.45); }
    55%       { box-shadow: 0 0 0 7px rgba(16,185,129,0); }
}
@keyframes pulse-warn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.45); }
    55%       { box-shadow: 0 0 0 7px rgba(245,158,11,0); }
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1200px) {
    .kpi-grid        { grid-template-columns: repeat(2, 1fr); }
    .charts-row      { grid-template-columns: 1fr; }
    .dashboard-bottom-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .main-content { margin-left: 200px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .kpi-grid   { grid-template-columns: 1fr 1fr; }
    .header     { padding: 16px; }
    .content    { padding: 16px; }
}
