{
  "rules": {
    "chat": {
      ".read": "auth != null",
      ".write": "auth != null",
      
      "$uid": {
        "messages": {
          "$msgId": {
            ".validate": "newData.hasChildren(['sender', 'message', 'timestamp'])"
          }
        },
        "meta": {
          ".validate": "newData.hasChildren(['user_name', 'last_message'])"
        }
      }
    },

    "dashboard_stats": {
      ".read": "auth != null",
      ".write": false
    },

    "activation_codes": {
      ".read": "auth != null",
      ".write": false
    },

    "global_recent_searches": {
      ".read": "auth != null",
      ".write": "auth != null",
      ".indexOn": ["timestamp"]
    },

    "user_plans": {
      "$uid": {
        ".read": "auth != null && auth.uid == $uid",
        ".write": false
      }
    }
  }
}