/* MeM Control Center — Dark Theme v1.0 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg:         #0d1526;
  --sidebar:    #0a1120;
  --card:       #162035;
  --card-hover: #1e2b44;
  --border:     #253555;
  --border2:    #2e4268;
  --mem-red:    #e63329;
  --mem-red2:   #c42a21;
  --text:       #e8eef8;
  --text-muted: #6b80a0;
  --text-dim:   #a0b4cc;
  --online:     #22c55e;
  --offline:    #ef4444;
  --warning:    #f59e0b;
  --header-h:   64px;
  --sidebar-w:  220px;
}

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

html, body {
  font-family: 'Inter', sans-serif;
  background: radial-gradient(ellipse at 70% 0%, rgba(37,53,85,.6) 0%, transparent 50%),
              radial-gradient(ellipse at 10% 90%, rgba(20,40,80,.4) 0%, transparent 45%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0a1120 0%, #0c1628 100%);
  border-right: 1px solid rgba(37,53,85,.8);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-mem {
  font-size: 26px;
  font-weight: 800;
  color: var(--mem-red);
  letter-spacing: -1px;
  line-height: 1;
}
.sidebar-logo .logo-sub {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 18px 20px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 450;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active {
  background: rgba(230,51,41,.18);
  color: #fff;
  border-left-color: var(--mem-red);
  font-weight: 600;
  text-shadow: 0 0 20px rgba(230,51,41,.3);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.nav-item.logout { color: var(--mem-red); margin-top: 4px; }
.nav-item.logout:hover { background: rgba(230,51,41,.1); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar-footer strong { color: var(--mem-red); display: block; font-size: 16px; font-weight: 800; }
.sidebar-footer span { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }

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

/* ── HEADER ──────────────────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: linear-gradient(90deg, #0c1628 0%, #0f1e38 100%);
  border-bottom: 1px solid rgba(37,53,85,.9);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.header-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 6px var(--online);
  animation: pulse 2s infinite;
}
.header-status .status-label { font-weight: 600; color: var(--online); }

.header-notif {
  position: relative;
  width: 36px; height: 36px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
}
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--mem-red);
  color: #fff;
  font-size: 9px; font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px; text-align: center;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  transition: background .15s;
}
.header-user:hover { background: rgba(255,255,255,.07); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--mem-red);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }
.user-chevron { color: var(--text-muted); font-size: 12px; }

/* ── PAGE CONTENT ────────────────────────────────────────────────────────── */
.content { padding: 32px 32px 24px; flex: 1; }

.page-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-title span { color: var(--mem-red); }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

/* ── APP GRID ────────────────────────────────────────────────────────────── */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.apps-grid.row2 { grid-template-columns: repeat(2, 1fr); }

/* ── APP CARD ────────────────────────────────────────────────────────────── */
.app-card {
  background: linear-gradient(160deg, #1c2e4a 0%, #142238 100%);
  border: 1px solid rgba(45,70,110,.7);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  cursor: pointer;
  position: relative;
}
.app-card:hover {
  border-color: rgba(80,130,220,.5);
  transform: translateY(-3px);
  box-shadow: 0 16px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(80,130,220,.2);
}

.card-img {
  height: 160px;
  position: relative;
  overflow: hidden;
}
.card-img-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform .4s ease;
  filter: brightness(.72) saturate(1.2);
}
.app-card:hover .card-img-bg { transform: scale(1.05); filter: brightness(.88) saturate(1.35); }
.card-img-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,0,0,.15) 0%, transparent 55%),
              linear-gradient(to top, rgba(0,0,0,.75) 0%, transparent 45%);
}
.card-icon-wrap {
  position: absolute;
  top: 16px; left: 16px;
  width: 50px; height: 50px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.15);
}

/* ── big bottom card ── */
.app-card.card-lg .card-img { height: 220px; }
.app-card.card-lg .card-icon-wrap { width: 60px; height: 60px; border-radius: 18px; font-size: 30px; }
.app-card.card-lg .card-name { font-size: 22px; }

.card-body { padding: 16px 18px; flex: 1; display: flex; flex-direction: column; }
.card-name { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.tag {
  background: rgba(80,130,220,.14);
  border: 1px solid rgba(80,130,220,.28);
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 10px;
  color: #a8c4f0;
  font-weight: 500;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 12px;
}
.status-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 500;
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 5px var(--online);
}
.status-dot.offline::before { background: var(--offline); box-shadow: 0 0 5px var(--offline); }
.status-dot.online { color: var(--online); }
.status-dot.offline { color: var(--offline); }
.last-access { color: var(--text-muted); }

.card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .4px;
  transition: opacity .15s, transform .1s;
  text-transform: uppercase;
  margin-top: auto;
}
.card-btn:hover { opacity: .9; transform: scale(.98); }
.card-btn svg { width: 14px; height: 14px; }

/* ── STATS BAR ───────────────────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  background: linear-gradient(135deg, #162035 0%, #1a2840 100%);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 20px 24px;
  margin-top: 20px;
}
.stat { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value.green { color: var(--online); }
.stat-sub { font-size: 11px; color: var(--text-muted); }
.stat-link { font-size: 11px; color: #4ade80; text-decoration: underline; cursor: pointer; }

/* ── TABLES (users, activity) ────────────────────────────────────────────── */
.table-card {
  background: linear-gradient(160deg, #162035 0%, #111c30 100%);
  border: 1px solid rgba(45,70,110,.7);
  border-radius: 14px;
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.table-title { font-size: 16px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 13px 20px;
  font-size: 13px;
  border-bottom: 1px solid rgba(30,42,64,.6);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.025); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-admin  { background: rgba(230,51,41,.15); color: var(--mem-red); }
.badge-user   { background: rgba(100,116,139,.15); color: var(--text-dim); }
.badge-active { background: rgba(34,197,94,.12); color: var(--online); }
.badge-inactive { background: rgba(239,68,68,.12); color: var(--offline); }

/* ── FORMS ───────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 520px;
}
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; letter-spacing: .5px; text-transform: uppercase; }
.form-control {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--mem-red); background: rgba(255,255,255,.07); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--card); }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px;
  border-radius: 9px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  cursor: pointer;
}
.btn:hover { opacity: .88; transform: scale(.98); }
.btn-primary { background: var(--mem-red); color: #fff; }
.btn-secondary { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--border2); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--offline); border: 1px solid rgba(239,68,68,.3); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }

/* ── LOGIN PAGE ──────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 20% 50%, rgba(230,51,41,.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 30%, rgba(30,60,120,.15) 0%, transparent 60%),
              var(--bg);
}
.login-box {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 44px 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-mem { font-size: 42px; font-weight: 900; color: var(--mem-red); letter-spacing: -2px; }
.login-logo .logo-sub { font-size: 10px; letter-spacing: 3px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

.login-btn {
  width: 100%;
  background: var(--mem-red);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
  margin-top: 6px;
}
.login-btn:hover { background: var(--mem-red2); transform: scale(.99); }

.alert {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: #86efac; }

/* ── ACTIONS ─────────────────────────────────────────────────────────────── */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

/* ── FLASH ───────────────────────────────────────────────────────────────── */
.flash { padding: 12px 18px; border-radius: 10px; margin-bottom: 20px; font-size: 13px; font-weight: 500; }
.flash-success { background: rgba(34,197,94,.1); border:1px solid rgba(34,197,94,.3); color:#86efac; }
.flash-error   { background: rgba(239,68,68,.1);  border:1px solid rgba(239,68,68,.3);  color:#fca5a5; }

/* ── PAGINATION ──────────────────────────────────────────────────────────── */
.pagination { display:flex; gap:6px; margin-top:16px; }
.page-link {
  padding: 6px 12px; border-radius: 7px; font-size:12px; font-weight:600;
  background: rgba(255,255,255,.05); border:1px solid var(--border2); color:var(--text-dim);
  cursor:pointer; transition: background .15s;
}
.page-link:hover, .page-link.active { background: var(--mem-red); color:#fff; border-color:transparent; }

/* ── MODAL ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.6); backdrop-filter:blur(4px);
  display:none; align-items:center; justify-content:center; z-index:999;
}
.modal-overlay.open { display:flex; }
.modal {
  background: var(--card); border:1px solid var(--border2);
  border-radius:16px; padding:28px 32px; width:90%; max-width:480px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal-title { font-size:18px; font-weight:700; margin-bottom:20px; }

/* ── ANIMATIONS ──────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.6; transform:scale(.8); }
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .apps-grid { grid-template-columns: repeat(2, 1fr); }
  .apps-grid.row2 { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); }
  .sidebar.open { transform: translateX(0); width: 220px; }
  .apps-grid, .apps-grid.row2 { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .content { padding: 20px 16px; }
  .header { padding: 0 16px; }
}
