/* ===========================================================
   ConnectTracker — Dark Tech Theme
   =========================================================== */

/* Reset e base */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Cores dark tech */
    --bg: #0b0d12;
    --bg-elevated: #11131a;
    --bg-card: #161922;
    --bg-input: #1f2330;

    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(34, 197, 94, 0.4);

    --text: #f0f2f7;
    --text-secondary: #9aa3b2;
    --text-muted: #6b7280;

    /* Neon accents */
    --primary: #22c55e;
    --primary-glow: rgba(34, 197, 94, 0.25);
    --primary-hover: #16a34a;
    --accent: #f97316;
    --accent-glow: rgba(249, 115, 22, 0.25);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.12);

    --radius: 18px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 24px rgba(34, 197, 94, 0.12);
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* ===========================================================
   Login
   =========================================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 30%, rgba(34, 197, 94, 0.08), transparent 35%),
        radial-gradient(circle at 80% 70%, rgba(249, 115, 22, 0.08), transparent 35%),
        var(--bg);
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 4px 20px var(--primary-glow);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), #16a34a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 26px;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px var(--primary-glow);
    letter-spacing: -1px;
}

.login-header h1 {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 8px;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.login-form input {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text);
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.login-form input::placeholder {
    color: var(--text-muted);
}

.login-form input:hover {
    border-color: var(--border-hover);
    background: #262a3a;
    box-shadow:
        0 6px 10px rgba(0, 0, 0, 0.25),
        0 0 12px rgba(34, 197, 94, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: #262a3a;
    box-shadow:
        0 6px 10px rgba(0, 0, 0, 0.25),
        0 0 0 3px var(--primary-glow),
        0 0 20px rgba(34, 197, 94, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ===========================================================
   Layout app
   =========================================================== */
.app-page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    height: 76px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #16a34a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.sidebar-brand span {
    font-weight: 800;
    color: var(--text);
    font-size: 17px;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.sidebar-section {
    margin: 20px 0 10px;
    padding: 0 16px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    text-decoration: none;
}

.sidebar-link.active {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.04));
    color: var(--primary);
    border-color: rgba(34, 197, 94, 0.25);
    box-shadow: 0 0 16px var(--primary-glow);
}

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

.icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
    line-height: 1;
}

.content {
    flex: 1;
    margin-left: 270px;
    padding: 24px 32px 40px;
    min-width: 0;
}

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

.content-header h1 {
    font-size: 26px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 8px 14px;
    min-width: 260px;
    transition: border-color 0.2s;
}

.search-box:hover,
.search-box:focus-within {
    border-color: var(--border-hover);
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: var(--text);
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
    box-shadow: 0 0 12px var(--primary-glow);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #16a34a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 11px;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.user-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
}

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

/* ===========================================================
   Cards e métricas
   =========================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 6px;
    letter-spacing: -0.3px;
}

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

.text-center {
    text-align: center;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow), 0 8px 28px rgba(0, 0, 0, 0.25);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.metric-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 700;
}

.metric-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -1px;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.metric-badge {
    position: absolute;
    top: 22px;
    right: 22px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--success-bg);
    color: var(--success);
}

.metric-badge.positive {
    background: var(--success-bg);
    color: var(--success);
}

.metric-badge.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

/* ===========================================================
   Botões
   =========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #16a34a);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-hover);
    color: var(--text);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-color: var(--border-hover);
    text-decoration: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #15803d);
    color: #fff;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.22);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: #fff;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.22);
}

.btn-warning:hover {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

.btn-danger {
    background: linear-gradient(135deg, var(--error), #b91c1c);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.22);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}

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

.btn-block {
    width: 100%;
}

.btn.active {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4);
}

/* ===========================================================
   Formulários
   =========================================================== */
.form-config {
    width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.2s;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--border-hover);
    background: #262a3a;
    box-shadow:
        0 6px 10px rgba(0, 0, 0, 0.25),
        0 0 12px rgba(34, 197, 94, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #262a3a;
    box-shadow:
        0 6px 10px rgba(0, 0, 0, 0.25),
        0 0 0 3px var(--primary-glow),
        0 0 20px rgba(34, 197, 94, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.form-group input::placeholder,
.form-group select option:first-child {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-status {
    font-size: 13px;
    font-weight: 600;
}

/* ===========================================================
   Tabelas
   =========================================================== */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.data-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 800;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.row-erro {
    background: var(--error-bg);
}

/* ===========================================================
   Status badges
   =========================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.status-enviado {
    background: var(--success-bg);
    color: var(--success);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.15);
}

.status-pendente {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-erro {
    background: var(--error-bg);
    color: var(--error);
}

.status-admin {
    background: rgba(59, 130, 246, 0.12);
    color: var(--info);
}

/* ===========================================================
   Alertas
   =========================================================== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.25);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.25);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.25);
}

/* ===========================================================
   User cell
   =========================================================== */
.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-cell strong {
    color: var(--text);
    font-weight: 700;
}

/* ===========================================================
   Paginação
   =========================================================== */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ===========================================================
   Responsive
   =========================================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    .content {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    .app-page {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 12px;
        gap: 8px;
    }

    .sidebar-link {
        white-space: nowrap;
    }

    .content {
        margin-left: 0;
        padding: 20px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .search-box {
        display: none;
    }

    .metrics-row {
        grid-template-columns: 1fr;
    }
}

/* ===========================================================
   Utilitários
   =========================================================== */
.d-block {
    display: block;
}

.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
}

.chart-container {
    position: relative;
    height: 300px;
}

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