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

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

:root {
    --bg-primary: #0B1120;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(30, 41, 59, 0.6);
    --border-subtle: rgba(148, 163, 184, 0.08);
    --border-default: rgba(148, 163, 184, 0.12);
    --border-hover: rgba(96, 165, 250, 0.3);
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent: #60A5FA;
    --accent-hover: #93C5FD;
    --accent-glow: rgba(96, 165, 250, 0.15);
    --success: #34D399;
    --danger: #F87171;
    --warning: #FBBF24;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 20px rgba(96, 165, 250, 0.08);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes borderGlow {
    0%, 100% { border-color: rgba(96, 165, 250, 0.15); }
    50% { border-color: rgba(96, 165, 250, 0.35); }
}

/* ─── Login ─── */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}
.login-body::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(96, 165, 250, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 50%, rgba(52, 211, 153, 0.04) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

.login-container {
    width: 100%; max-width: 420px; padding: 20px;
    position: relative; z-index: 1;
    animation: fadeIn 0.6s ease-out;
}

.login-box {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.login-icon {
    text-align: center; font-size: 48px; margin-bottom: 8px;
    filter: drop-shadow(0 4px 12px rgba(96, 165, 250, 0.3));
}

.login-box h1 {
    text-align: center;
    background: linear-gradient(135deg, var(--accent) 0%, #A78BFA 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px; font-size: 26px; font-weight: 800;
    letter-spacing: -0.5px;
}

.login-subtitle {
    text-align: center; color: var(--text-muted);
    margin-bottom: 32px; font-size: 14px; font-weight: 400;
}

/* ─── Topbar ─── */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 0 24px; height: 56px;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky; top: 0; z-index: 100;
    transition: background var(--transition);
}

.topbar-left { display: flex; align-items: center; gap: 32px; height: 100%; }

.topbar-brand {
    font-size: 18px; font-weight: 800;
    background: linear-gradient(135deg, var(--accent) 0%, #A78BFA 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px; white-space: nowrap;
}

.topbar-nav { display: flex; align-items: center; gap: 2px; height: 100%; }

.nav-link {
    display: flex; align-items: center; height: 100%;
    padding: 0 16px; color: var(--text-muted);
    font-size: 13px; font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}
.nav-link:hover {
    color: var(--text-primary);
    background: rgba(96, 165, 250, 0.06);
    border-bottom-color: rgba(96, 165, 250, 0.3);
}
.nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(96, 165, 250, 0.08);
    font-weight: 600;
}
.nav-link.active::after {
    content: '';
    position: absolute; bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 20px; height: 2px;
    background: var(--accent);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.4);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user {
    color: var(--text-secondary); font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px; white-space: nowrap;
}

/* ─── Breadcrumb ─── */
.breadcrumb-bar {
    background: rgba(30, 41, 59, 0.4);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 24px;
    font-size: 12px; color: var(--text-muted);
    font-weight: 500;
    backdrop-filter: blur(8px);
}

/* ─── Container ─── */
.container {
    max-width: 1440px; margin: 0 auto; padding: 28px 28px;
    animation: fadeIn 0.4s ease-out;
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
}
.page-header h2 {
    font-size: 22px; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* ─── Stats ─── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px; margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: 22px 18px; text-align: center;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out backwards;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.3s; }
.stat-card:nth-child(7) { animation-delay: 0.35s; }

.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0; transition: opacity var(--transition);
}
.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 24px rgba(96, 165, 250, 0.06);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon { font-size: 24px; margin-bottom: 8px; opacity: 0.9; }
.stat-value {
    font-size: 30px; font-weight: 800;
    background: linear-gradient(135deg, var(--accent) 0%, #93C5FD 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}
.stat-label {
    font-size: 11px; color: var(--text-muted); margin-top: 6px;
    text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-weight: 400; }

/* ─── Grid ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.section-title {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
    letter-spacing: -0.2px;
}

/* ─── Chart ─── */
.chart-container {
    display: flex; align-items: flex-end; gap: 6px; height: 150px;
    padding: 16px 12px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    backdrop-filter: blur(8px);
}
.chart-bar-group {
    display: flex; flex-direction: column; align-items: center;
    flex: 1; min-width: 30px;
    animation: fadeIn 0.5s ease-out backwards;
}
.chart-bar-value { font-size: 10px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.chart-bar {
    width: 26px; border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--accent) 0%, rgba(96, 165, 250, 0.4) 100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 4px;
    position: relative;
}
.chart-bar:hover {
    background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.3);
}
.chart-bar-label { font-size: 9px; color: var(--text-muted); margin-top: 6px; white-space: nowrap; font-weight: 500; }

/* ─── Empty state ─── */
.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.4; filter: grayscale(30%); }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-primary); font-weight: 600; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

/* ─── Table ─── */
.table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border-subtle);
    animation: fadeIn 0.4s ease-out;
}
.table th, .table td {
    padding: 14px 18px; text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}
.table th {
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-muted);
    font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.6px;
}
.table tr:last-child td { border-bottom: none; }
.table tr {
    transition: background var(--transition);
}
.table tr:hover td {
    background: rgba(96, 165, 250, 0.04);
}
.actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

/* ─── Tags ─── */
.tag {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 100px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.2px;
}
.tag-rdp { background: rgba(96, 165, 250, 0.12); color: #93C5FD; }
.tag-anydesk { background: rgba(52, 211, 153, 0.12); color: #6EE7B7; }
.tag-admin { background: rgba(167, 139, 250, 0.12); color: #C4B5FD; }
.tag-user { background: rgba(148, 163, 184, 0.1); color: var(--text-secondary); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px; border: none; border-radius: var(--radius-sm);
    font-size: 13px; cursor: pointer; font-weight: 600;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    transition: all var(--transition);
    position: relative; overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    opacity: 0; transition: opacity var(--transition);
}
.btn:hover::after { opacity: 1; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #818CF8 100%);
    color: #0F172A;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(96, 165, 250, 0.35);
}

.btn-secondary {
    background: rgba(51, 65, 85, 0.6);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}
.btn-secondary:hover {
    background: rgba(71, 85, 105, 0.6);
    border-color: var(--border-hover);
}

.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; justify-content: center; }

.btn-logout {
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border-default);
    padding: 6px 16px; border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(248, 113, 113, 0.06);
}

.btn-edit { background: rgba(52, 211, 153, 0.1); color: var(--success); border: none; cursor: pointer; }
.btn-edit:hover { background: rgba(52, 211, 153, 0.18); }
.btn-delete { background: rgba(248, 113, 113, 0.1); color: var(--danger); border: none; cursor: pointer; }
.btn-delete:hover { background: rgba(248, 113, 113, 0.18); }
.btn-icon { padding: 6px 10px; font-size: 14px; }

/* ─── Form ─── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 6px;
    color: var(--text-secondary); font-size: 13px; font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 13px; font-family: 'Inter', 'Segoe UI', sans-serif;
    transition: all var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ─── Filters ─── */
.filtro-bar {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: 20px; margin-bottom: 24px;
}
.filtro-bar form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filtro-bar .form-group { margin: 0; }

/* ─── Modal ─── */
.modal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.modal-content {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(24px);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 680px; width: 92%; max-height: 90vh; overflow-y: auto;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(96, 165, 250, 0.06);
    animation: slideDown 0.3s ease-out;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.btn-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 22px; cursor: pointer; padding: 4px 8px;
    line-height: 1; transition: all var(--transition);
    border-radius: var(--radius-sm);
}
.btn-close:hover { color: var(--text-primary); background: rgba(148, 163, 184, 0.1); }

/* ─── Alert ─── */
.alert {
    padding: 14px 18px; border-radius: var(--radius-md);
    margin-bottom: 18px; font-size: 13px; font-weight: 500;
    animation: slideDown 0.3s ease-out;
}
.alert-error {
    background: rgba(248, 113, 113, 0.08);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.15);
}

/* ─── Tree View (admin_grupos) ─── */
.tree-view {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: 12px;
}

.tree-group {
    margin-bottom: 2px;
}

.tree-group-header {
    cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition);
}
.tree-group-header:hover {
    background: rgba(96, 165, 250, 0.06);
}

.tree-group.collapsed > .tree-servidores,
.tree-group.collapsed > .tree-group { display: none; }

.tree-servidores { padding-left: 20px; }

.tree-servidor {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    transition: all var(--transition);
    cursor: pointer;
}
.tree-servidor:hover {
    background: rgba(96, 165, 250, 0.06);
}

.tree-serv-actions {
    margin-left: auto; display: none; gap: 4px;
}
.tree-servidor:hover .tree-serv-actions { display: flex; }

.act-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    cursor: pointer; font-size: 12px; font-weight: 500;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    padding: 4px 12px; border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all var(--transition);
}
.act-btn:hover { background: rgba(51, 65, 85, 0.8); }
.act-edit:hover { border-color: var(--accent); color: var(--accent); }
.act-clone:hover { border-color: #38BDF8; color: #38BDF8; }
.act-delete:hover { border-color: var(--danger); color: var(--danger); }

/* ─── Tag Select (user admin) ─── */
.tag-select {
    border: 1px solid var(--border-default) !important;
    border-radius: var(--radius-sm) !important;
    font-family: 'Inter', 'Segoe UI', sans-serif !important;
    transition: all var(--transition) !important;
    cursor: pointer;
}

/* ─── User link ─── */
.user-link {
    transition: color var(--transition);
}
.user-link:hover { color: var(--accent-hover); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.25); }

/* ─── Selection ─── */
::selection {
    background: rgba(96, 165, 250, 0.25);
    color: var(--text-primary);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .topbar { padding: 0 16px; }
    .topbar-nav { gap: 0; }
    .nav-link { padding: 0 10px; font-size: 12px; }
    .container { padding: 20px 16px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
}
