/* RealSys Admin - Design System */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #0f172a;
    --accent: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --bg: #f1f5f9;
    --card: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #2563eb;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,.08);
    --transition: all .2s ease;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text); position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100; transition: var(--transition); }
.sidebar-brand { padding: 1.5rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: .75rem; }
.sidebar-brand .logo { width: 36px; height: 36px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 1rem; }
.sidebar-brand h2 { color: #fff; font-size: 1.15rem; font-weight: 700; }
.sidebar-brand span { font-size: .7rem; color: var(--sidebar-text); display: block; }

.sidebar-nav { padding: .75rem 0; }
.nav-section { padding: .5rem 1.25rem; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: #475569; font-weight: 600; margin-top: .5rem; }
.nav-link { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; color: var(--sidebar-text); font-size: .85rem; font-weight: 500; transition: var(--transition); border-left: 3px solid transparent; }
.nav-link:hover { color: #e2e8f0; background: rgba(255,255,255,.04); }
.nav-link.active { color: #fff; background: rgba(37,99,235,.15); border-left-color: var(--primary); }
.nav-link .icon { width: 20px; text-align: center; opacity: .7; }
.nav-link.active .icon { opacity: 1; }
.nav-link .badge { margin-left: auto; background: var(--primary); color: #fff; font-size: .65rem; padding: .1rem .45rem; border-radius: 10px; font-weight: 600; }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 0 2rem; height: 64px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-left h1 { font-size: 1.2rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-user { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-light); }
.topbar-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }

.content-area { padding: 2rem; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: .95rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 var(--radius) var(--radius); }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 1.25rem; border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: .75rem; }
.stat-card .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green { background: #dcfce7; color: var(--success); }
.stat-card .stat-icon.amber { background: #fef3c7; color: var(--warning); }
.stat-card .stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-light); margin-top: .25rem; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th { padding: .65rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); background: #f8fafc; border-bottom: 1px solid var(--border); }
table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .85rem; vertical-align: middle; }
table tbody tr:hover { background: #f8fafc; }
table tbody tr:last-child td { border-bottom: none; }

/* Badges & Status */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 20px; font-size: .7rem; font-weight: 600; gap: .3rem; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1.1rem; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; cursor: pointer; transition: var(--transition); text-decoration: none; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: .5rem; }

/* Forms */
.form-group { margin-bottom: 1.15rem; }
.form-group label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .35rem; color: var(--text); }
.form-control { width: 100%; padding: .6rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .88rem; transition: var(--transition); background: var(--card); color: var(--text); }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Alerts */
.alert { padding: .85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; font-size: .85rem; display: flex; align-items: flex-start; gap: .5rem; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Pagination */
.pagination { display: flex; gap: .25rem; justify-content: center; padding: 1rem; }
.pagination a, .pagination span { padding: .4rem .7rem; border-radius: var(--radius-sm); font-size: .82rem; border: 1px solid var(--border); color: var(--text-light); }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Filters bar */
.filters-bar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filters-bar .form-control { width: auto; min-width: 180px; padding: .45rem .75rem; font-size: .82rem; }
.filters-bar .search-input { min-width: 260px; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-light); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3 { font-size: 1rem; margin-bottom: .35rem; color: var(--text); }
.empty-state p { font-size: .85rem; }

/* Portal cards */
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.portal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; transition: var(--transition); }
.portal-card:hover { box-shadow: var(--shadow-lg); }
.portal-card .portal-icon { width: 48px; height: 48px; border-radius: 10px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 1rem; }
.portal-card h4 { font-size: 1rem; margin-bottom: .25rem; }
.portal-card .portal-type { font-size: .75rem; color: var(--text-muted); }
.portal-card .portal-actions { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }

/* Mapper visual */
.mapper-container { display: grid; grid-template-columns: 1fr auto 1fr; gap: .75rem; align-items: start; }
.mapper-col { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.mapper-col-header { padding: .75rem 1rem; background: #f8fafc; font-weight: 700; font-size: .82rem; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.mapping-row { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: .5rem; align-items: center; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.mapping-arrow { color: var(--primary); font-weight: 700; text-align: center; width: 30px; }
.mapping-row select { font-size: .8rem; padding: .4rem .5rem; }
.mapping-remove { cursor: pointer; color: var(--danger); font-size: 1rem; opacity: .6; }
.mapping-remove:hover { opacity: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Responsive */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: .35rem; border-radius: 6px; color: var(--text); transition: var(--transition); }
.menu-toggle:hover { background: #f1f5f9; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; backdrop-filter: blur(2px); }

@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; }
}
@media (max-width: 768px) {
    .menu-toggle { display: flex; }
    .sidebar { transform: translateX(-100%); width: 280px; z-index: 100; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .content-area { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .topbar-right span:not(.avatar) { display: none; }
}
